Files
be.ems/misc/actpkg.sh

45 lines
996 B
Bash

#!/bin/bash
filename="$1"
neType="$2"
duration=180
expectBin=/usr/bin/expect
extension=$(basename "${1}" | awk -F . '{print $NF}')
if [ ! -f ${expectBin} ]; then
echo "Please install software expect first"
exit 99
fi
case "${extension}" in
deb)
if [ ${neType} == "OMC" ]; then
systemctl stop restagent.service
fi
expect <<EOF
spawn dpkg -i --force-all "$filename"
set timeout ${duration}
expect {
"y/n" { send "n\n"; exp_continue }
}
EOF
;;
rpm)
if [ ${neType} == "OMC" ]; then
systemctl stop restagent.service
fi
expect <<EOF
spawn rpm -Uvh "$filename"
set timeout ${duration}
expect {
"y/n" { send "n\n"; exp_continue }
}
EOF
;;
*)
echo "The file does not have a .deb or .rpm extension"
exit 100
;;
esac