#!/bin/bash
readonly PACKAGE_NAME="Ascend-spc_pyACL"
readonly PYACL_PACKAGE_SHORT_NAME="pyACL"
spc_path="$(
cd "$(dirname "$0")/../.."
pwd
)"
if [ ! -d "$spc_path/backup/pyACL" ]; then
echo "ERROR" "The backup directory $spc_path/backup/pyACL/ does not exist. Rollback Precheck failed"
exit 1
fi
spc_install_path="$(
cd "$(dirname "$0")/../../backup/pyACL/pyACL/"
pwd
)"
install_path="$(
cd "$(dirname "$0")/../../../"
pwd
)"
if [ $(id -u) -ne 0 ]; then
log_dir="${HOME}/var/log/ascend_seclog"
else
log_dir="/var/log/ascend_seclog"
fi
log_file="${log_dir}/ascend_install.log"
function print() {
echo "[pyACL] [$(date +"%Y-%m-%d %H:%M:%S")] [$1]: $2" | tee -a $log_file
}
function log_init() {
if [ ! -f "$log_file" ]; then
touch $log_file
if [ $? -ne 0 ]; then
print "ERROR" "touch $log_file permission denied"
exit 1
fi
fi
chmod 640 $log_file
}
function dir_check() {
if [ ! -d "$1" ]; then
print "ERROR" "dir $2 is not installed, rollback failed"
exit 1
fi
}
function file_check() {
if [ ! -f "$1" ]; then
print "ERROR" "the source file $2 does not exist, rollback failed"
exit 1
fi
}
function deal_precheck() {
spc_python_path=$spc_path/backup/pyACL/python/site-packages/acl.so
acl_path=$install_path/python/site-packages
dir_check "${install_path}/spc" "spc"
dir_check "$install_path/pyACL" "pyACL"
dir_check "$acl_path" "python"
file_check "$spc_python_path" "acl.so"
spc_pyacl_path=$spc_install_path/version.info
file_check "$spc_pyacl_path" "version.info"
exit 0
}
log_init
deal_precheck