Browse Source

code improvements

pull/450/head
Daniel Gibbs 10 years ago
parent
commit
33a1839a62
  1. 92
      functions/fn_deps_detect

92
functions/fn_deps_detect

@ -9,7 +9,7 @@
local modulename="Backup" local modulename="Backup"
fn_check_root fn_check_root
fn_check_systemdir fn_check_systemdir
cd ${executabledir} cd "${executabledir}"
if [ "${executable}" == "./hlds_run" ];then if [ "${executable}" == "./hlds_run" ];then
executable=hlds_linux executable=hlds_linux
elif [ "${executable}" == "./srcds_run" ]||[ "${executable}" == "./dabds.sh" ]||[ "${executable}" == "./srcds_run.sh" ];then elif [ "${executable}" == "./srcds_run" ]||[ "${executable}" == "./dabds.sh" ]||[ "${executable}" == "./srcds_run.sh" ];then
@ -21,7 +21,7 @@ elif [ "${executable}" == "./runSam3_DedicatedServer.sh" ];then
elif [ "${executable}" == "./7DaysToDie.sh" ];then elif [ "${executable}" == "./7DaysToDie.sh" ];then
executable=7DaysToDie.x86 executable=7DaysToDie.x86
elif [ "${executable}" == "./ucc-bin" ];then elif [ "${executable}" == "./ucc-bin" ];then
if [ -f "${executabledir}/ucc-bin-real" ]; then if [ -f "${executabledir}/ucc-bin-real" ]; then
executable=ucc-bin-real executable=ucc-bin-real
elif [ -f "${executabledir}/ut2004-bin" ]; then elif [ -f "${executabledir}/ut2004-bin" ]; then
@ -29,55 +29,55 @@ elif [ "${executable}" == "./ucc-bin" ];then
else else
executable=ut-bin executable=ut-bin
fi fi
elif [ "${executable}" == "./ts3server_startscript.sh" ];then elif [ "${executable}" == "./ts3server_startscript.sh" ];then
executable=ts3server_linux_amd64
fi fi
readelf -d ${executable} |grep NEEDED|awk '{ print $5 }'|sed 's/\[//g'|sed 's/\]//g' > ${rootdir}/.depdetect_readelf readelf -d ${executable} |grep NEEDED|awk '{ print $5 }'|sed 's/\[//g'|sed 's/\]//g' > "${rootdir}/.depdetect_readelf"
echo "yum install " > ${rootdir}/.depdetect_centos_list_uniq echo "yum install " > "${rootdir}/.depdetect_centos_list_uniq"
echo "apt-get install " > ${rootdir}/.depdetect_ubuntu_list_uniq echo "apt-get install " > "${rootdir}/.depdetect_ubuntu_list_uniq"
echo "apt-get install " > ${rootdir}/.depdetect_debian_list_uniq echo "apt-get install " > "${rootdir}/.depdetect_debian_list_uniq"
while read lib; do while read lib; do
sharedlib=${lib} sharedlib=${lib}
if [ "${lib}" == "libm.so.6" ]||[ ${lib} == "libc.so.6" ]||[ ${lib} == "libpthread.so.0" ]||[ ${lib} == "libdl.so.2" ]||[ ${lib} == "libnsl.so.1" ]||[ "${lib}" == "libgcc_s.so.1" ]||[ "${lib}" == "librt.so.1" ]||[ "${lib}" == "ld-linux.so.2" ];then if [ "${lib}" == "libm.so.6" ]||[ "${lib}" == "libc.so.6" ]||[ "${lib}" == "libpthread.so.0" ]||[ "${lib}" == "libdl.so.2" ]||[ "${lib}" == "libnsl.so.1" ]||[ "${lib}" == "libgcc_s.so.1" ]||[ "${lib}" == "librt.so.1" ]||[ "${lib}" == "ld-linux.so.2" ];then
echo "glibc.i686" >> ${rootdir}/.depdetect_centos_list echo "glibc.i686" >> "${rootdir}/.depdetect_centos_list"
echo "lib32gcc1" >> ${rootdir}/.depdetect_ubuntu_list echo "lib32gcc1" >> "${rootdir}/.depdetect_ubuntu_list"
echo "lib32gcc1" >> ${rootdir}/.depdetect_debian_list echo "lib32gcc1" >> "${rootdir}/.depdetect_debian_list"
elif [ "${lib}" == "libstdc++.so.6" ];then elif [ "${lib}" == "libstdc++.so.6" ];then
echo "libstdc++.i686" >> ${rootdir}/.depdetect_centos_list echo "libstdc++.i686" >> "${rootdir}/.depdetect_centos_list"
echo "libstdc++6:i386" >> ${rootdir}/.depdetect_ubuntu_list echo "libstdc++6:i386" >> "${rootdir}/.depdetect_ubuntu_list"
echo "libstdc++6:i386" >> ${rootdir}/.depdetect_debian_list echo "libstdc++6:i386" >> "${rootdir}/.depdetect_debian_list"
elif [ "${lib}" == "libstdc++.so.5" ];then elif [ "${lib}" == "libstdc++.so.5" ];then
echo "compat-libstdc++-33.i686" >> ${rootdir}/.depdetect_centos_list echo "compat-libstdc++-33.i686" >> "${rootdir}/.depdetect_centos_list"
echo "libstdc++5:i386" >> ${rootdir}/.depdetect_ubuntu_list echo "libstdc++5:i386" >> "${rootdir}/.depdetect_ubuntu_list"
echo "libstdc++5:i386" >> ${rootdir}/.depdetect_debian_list echo "libstdc++5:i386" >> "${rootdir}/.depdetect_debian_list"
elif [ "${lib}" == "libspeex.so.1" ]||[ "${lib}" == "libspeexdsp.so.1" ];then elif [ "${lib}" == "libspeex.so.1" ]||[ "${lib}" == "libspeexdsp.so.1" ];then
echo "speex.i686" >> ${rootdir}/.depdetect_centos_list echo "speex.i686" >> "${rootdir}/.depdetect_centos_list"
echo "speex:i386" >> ${rootdir}/.depdetect_ubuntu_list echo "speex:i386" >> "${rootdir}/.depdetect_ubuntu_list"
echo "speex:i386" >> ${rootdir}/.depdetect_debian_list echo "speex:i386" >> "${rootdir}/.depdetect_debian_list"
elif [ "${lib}" == "libtier0.so" ]||[ "${lib}" == "Core.so" ]||[ "${lib}" == "Editor.so" ]||[ "${lib}" == "Engine.so" ]||[ "${lib}" == "liblua.so" ]||[ "${lib}" == "libsteam_api.so" ]||[ "${lib}" == "ld-linux-x86-64.so.2" ];then elif [ "${lib}" == "libtier0.so" ]||[ "${lib}" == "Core.so" ]||[ "${lib}" == "Editor.so" ]||[ "${lib}" == "Engine.so" ]||[ "${lib}" == "liblua.so" ]||[ "${lib}" == "libsteam_api.so" ]||[ "${lib}" == "ld-linux-x86-64.so.2" ];then
# Known shared libs what dont requires dependencies # Known shared libs what dont requires dependencies
: :
else else
unknownlib=1 unknownlib=1
echo "${lib}" >> ${rootdir}/.depdetect_unknown echo "${lib}" >> "${rootdir}/.depdetect_unknown"
fi fi
done < ${rootdir}/.depdetect_readelf done < "${rootdir}/.depdetect_readelf"
sort ${rootdir}/.depdetect_centos_list | uniq >> ${rootdir}/.depdetect_centos_list_uniq sort "${rootdir}/.depdetect_centos_list" | uniq >> "${rootdir}/.depdetect_centos_list_uniq"
sort ${rootdir}/.depdetect_ubuntu_list | uniq >> ${rootdir}/.depdetect_ubuntu_list_uniq sort "${rootdir}/.depdetect_ubuntu_list" | uniq >> "${rootdir}/.depdetect_ubuntu_list_uniq"
sort ${rootdir}/.depdetect_debian_list | uniq >> ${rootdir}/.depdetect_debian_list_uniq sort "${rootdir}/.depdetect_debian_list" | uniq >> "${rootdir}/.depdetect_debian_list_uniq"
if [ "${unknownlib}" == "1" ];then if [ "${unknownlib}" == "1" ];then
sort ${rootdir}/.depdetect_unknown | uniq >> ${rootdir}/.depdetect_unknown_uniq sort "${rootdir}/.depdetect_unknown" | uniq >> "${rootdir}/.depdetect_unknown_uniq"
fi fi
awk -vORS=' ' '{ print $1, $2 }' ${rootdir}/.depdetect_centos_list_uniq > ${rootdir}/.depdetect_centos_line awk -vORS=' ' '{ print $1, $2 }' "${rootdir}/.depdetect_centos_list_uniq" > "${rootdir}/.depdetect_centos_line"
awk -vORS=' ' '{ print $1, $2 }' ${rootdir}/.depdetect_ubuntu_list_uniq > ${rootdir}/.depdetect_ubuntu_line awk -vORS=' ' '{ print $1, $2 }' "${rootdir}/.depdetect_ubuntu_list_uniq" > "${rootdir}/.depdetect_ubuntu_line"
awk -vORS=' ' '{ print $1, $2 }' ${rootdir}/.depdetect_debian_list_uniq > ${rootdir}/.depdetect_debian_line awk -vORS=' ' '{ print $1, $2 }' "${rootdir}/.depdetect_debian_list_uniq" > "${rootdir}/.depdetect_debian_line"
echo "" echo ""
echo "Required Dependencies" echo "Required Dependencies"
@ -86,38 +86,38 @@ echo "${executable}"
echo "" echo ""
echo "CentOS" echo "CentOS"
echo "=================================" echo "================================="
cat ${rootdir}/.depdetect_centos_line cat "${rootdir}/.depdetect_centos_line"
echo "" echo ""
echo "" echo ""
echo "Ubuntu" echo "Ubuntu"
echo "=================================" echo "================================="
cat ${rootdir}/.depdetect_ubuntu_line cat "${rootdir}/.depdetect_ubuntu_line"
echo "" echo ""
echo "" echo ""
echo "Debian" echo "Debian"
echo "=================================" echo "================================="
cat ${rootdir}/.depdetect_debian_line cat "${rootdir}/.depdetect_debian_line"
echo "" echo ""
if [ "${unknownlib}" == "1" ];then if [ "${unknownlib}" == "1" ];then
echo "" echo ""
echo "Unknown shared Library" echo "Unknown shared Library"
echo "=================================" echo "================================="
cat ${rootdir}/.depdetect_unknown cat "${rootdir}/.depdetect_unknown"
fi fi
echo "" echo ""
echo "Required Librarys" echo "Required Librarys"
echo "=================================" echo "================================="
sort ${rootdir}/.depdetect_readelf |uniq sort "${rootdir}/.depdetect_readelf" |uniq
echo -en "\n" echo -en "\n"
rm -f ${rootdir}/.depdetect_centos_line rm -f "${rootdir}/.depdetect_centos_line"
rm -f ${rootdir}/.depdetect_centos_list rm -f "${rootdir}/.depdetect_centos_list"
rm -f ${rootdir}/.depdetect_centos_list rm -f "${rootdir}/.depdetect_centos_list"
rm -f ${rootdir}/.depdetect_centos_list_uniq rm -f "${rootdir}/.depdetect_centos_list_uniq"
rm -f ${rootdir}/.depdetect_debian_list rm -f "${rootdir}/.depdetect_debian_list"
rm -f ${rootdir}/.depdetect_debian_list_uniq rm -f "${rootdir}/.depdetect_debian_list_uniq"
rm -f ${rootdir}/.depdetect_readelf rm -f "${rootdir}/.depdetect_readelf"
rm -f ${rootdir}/.depdetect_ubuntu_list rm -f "${rootdir}/.depdetect_ubuntu_list"
rm -f ${rootdir}/.depdetect_ubuntu_list_uniq rm -f "${rootdir}/.depdetect_ubuntu_list_uniq"
rm -f ${rootdir}/.depdetect_unknown rm -f "${rootdir}/.depdetect_unknown"
rm -f ${rootdir}/.depdetect_unknown_uniq rm -f "${rootdir}/.depdetect_unknown_uniq"
Loading…
Cancel
Save