add: 打包脚本
This commit is contained in:
53
build/misc/rbkpkg.sh
Normal file
53
build/misc/rbkpkg.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
filename="$1"
|
||||
neType="$2"
|
||||
duration=180
|
||||
expectBin=/usr/bin/expect
|
||||
omcBin=/usr/local/omc/bin
|
||||
logFile=/tmp/actpkg`date +%Y%m%d`.log
|
||||
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 > ${logFile}
|
||||
spawn dpkg -i --force-all "$filename"
|
||||
set timeout ${duration}
|
||||
expect {
|
||||
"y/n" { send "y\n"; exp_continue }
|
||||
}
|
||||
EOF
|
||||
if [ ${neType} == "OMC" ]; then
|
||||
${omcBin}/setomc.sh -m upgrade >> ${logFile}
|
||||
fi
|
||||
;;
|
||||
rpm)
|
||||
if [ ${neType} == "OMC" ]; then
|
||||
systemctl stop restagent.service
|
||||
fi
|
||||
expect <<EOF > ${logFile}
|
||||
spawn rpm -Uvh "$filename"
|
||||
set timeout ${duration}
|
||||
expect {
|
||||
"y/n" { send "y\n"; exp_continue }
|
||||
}
|
||||
EOF
|
||||
if [ ${neType} == "OMC" ]; then
|
||||
${omcBin}/setomc.sh -m upgrade >> ${logFile}
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
|
||||
echo "The file does not have a .deb or .rpm extension"
|
||||
exit 100
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user