| #!/bin/bash |
| |
| |
| export readonly PASS=0 |
| export readonly FAIL=1 |
| |
| |
| |
| function t_Log |
| { |
| printf "[+] `date` -> $*\n" |
| } |
| |
| |
| |
| function t_CheckExitStatus |
| { |
| [ $1 -eq 0 ] && { t_Log "PASS"; return $PASS; } |
| |
| t_Log "FAIL" |
| exit $FAIL |
| } |
| |
| |
| |
| function t_InstallPackage |
| { |
| t_Log "Attempting yum install: $*" |
| /usr/bin/yum -y -d0 install "$@" |
| t_CheckExitStatus $? |
| } |
| |
| |
| |
| function t_RemovePackage |
| { |
| t_Log "Attempting yum remove: $*" |
| /usr/bin/yum -y -d0 remove "$@" |
| t_CheckExitStatus $? |
| } |
| |
| |
| |
| function t_Process |
| { |
| exec 7< $@ |
| |
| while read -u 7 f |
| do |
| |
| [[ "${f}" =~ readme|^_ ]] && continue; |
| |
| |
| [ -x ${f} ] && ${f} |
| |
| done |
| |
| return 0 |
| } |
| |
| |
| |
| |
| function t_CheckDeps |
| { |
| |
| |
| |
| return 0 |
| } |
| |
| |
| |
| |
| |
| function t_ServiceControl |
| { |
| /sbin/service $1 $2 |
| |
| |
| sleep 3 |
| } |
| |
| |
| function t_GetPkgRel |
| { |
| rpm -q --queryformat '%{RELEASE}' $1 |
| } |
| |
| |
| function t_DistCheck |
| { |
| rpm -q --queryformat '%{version}\n' centos-release |
| } |
| |
| |
| function t_GetPkgVer |
| { |
| rpm -q --queryformat '%{version}' $1 |
| } |
| |
| |
| function t_GetArch |
| { |
| rpm -q --queryformat '%{arch}\n' centos-release |
| } |
| |
| export -f t_Log |
| export -f t_CheckExitStatus |
| export -f t_InstallPackage |
| export -f t_RemovePackage |
| export -f t_Process |
| export -f t_CheckDeps |
| export -f t_ServiceControl |
| export -f t_GetPkgRel |
| export -f t_DistCheck |
| export -f t_GetPkgVer |
| export -f t_GetArch |