发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
#!/bin/bash
cd ~
function kiop_info(){
echo " # #### #####"
echo " # # # # #"
echo " # # # # #"
echo " # # # #####"
echo " # # # #"
echo " # #### #"
}
kiop_info
#0.打包日期
set_date="2024-03-06"
set_version="5.2.24.0306"
kiopfile="kupdate.$set_version.tar.gz"
echo "-----------------##################-----------------"
#echo ------------------------
setupchk=""
#echo $1
function kiop_setup_check(){
#echo "您确实要升级KIOP系统吗?"
echo "Are you sure you want to update KIOP"
echo "KIOP Version:$set_version Date:$set_date"
read -p "yes setup no exit;please input [y/n]:" setupchk
if [ -z $setupchk ]
then
echo "not input exit;please input y/n"
exit
elif [ $setupchk = "y" -o $setupchk = "yes" ]
then
echo "welcome start setup kiop"
else
echo "not input [y] setup exit"
exit
fi
}
kiop_setup_check
#echo ------------------------
kiopbase="https://wise-software.oss-cn-beijing.aliyuncs.com/iop/kiop/kupdate/"
kiopdownloadpage=${kiopbase}${kiopfile}
savetmpfolder="/usr/coretmp"
#echo $kiopdownloadpage
#1.建立文件
savefolder="/usr/core"
kiopfolder="/usr/core/kiop"
function kiop_setup_mkdir(){
if [ ! -d "$savefolder" ]; then
mkdir $savefolder -p
echo "create folder $savefolder"
fi
if [ ! -d "$kiopfolder" ]; then
mkdir $kiopfolder -p
echo "create folder $kiopfolder"
fi
if [ ! -d "$savetmpfolder" ]; then
mkdir $savetmpfolder -p
echo "create folder $savetmpfolder"
fi
}
kiop_setup_mkdir
#2.下载文件
cd $savetmpfolder
function kiop_setup_download(){
if [ -f "$kiopfile" ]; then
echo "file exist,not download"
else
echo "start download file $kiopdownloadpage"
wget -O $kiopfile $kiopdownloadpage
fi
if [ -f "$kiopfile" ]; then
echo "download finish"
else
echo "download error;not find:$kiopdownloadpage"
echo "setup error"
echo "system exit"
exit
fi
}
kiop_setup_download
#3.判断服务是否存在
function kiop_systemctl_have(){
if systemctl list-unit-files --type=service | grep $1 ; then
return 1
fi
return 0
}
#4.判断supervisor中服务是否存在
function kiop_supervisor_have(){
if supervisorctl status | grep $1 ; then
return 1
fi
return 0
}
function kiop_supervisor_init(){
echo "supervisorctl check kiopweb/kiopmmu"
service_name="kiopweb"
kiop_supervisor_have $service_name
if [ $? = 1 ]; then
echo "supervisorctl restart $service_name"
supervisorctl restart $service_name
fi
service_name="kiopmmu"
kiop_supervisor_have $service_name
if [ $? = 1 ]; then
echo "supervisorctl restart $service_name"
supervisorctl restart $service_name
fi
}
echo 'start update kiop ********************************************************'
function kiop_setup_init(){
echo "tar file"
tar -zxvf $kiopfile -C $kiopfolder
echo "tar finish"
chmod -R 777 $kiopfolder/wwwroot
#检测kiopweb是否有这个服务
service_name="kiopweb"
kiop_systemctl_have $service_name
if [ $? = 1 ]; then
echo "systemctl restart $service_name"
systemctl restart $service_name
fi
#检测kiopmmu是否有这个服务
service_name="kiopmmu"
kiop_systemctl_have $service_name
if [ $? = 1 ]; then
echo "systemctl restart $service_name"
systemctl restart $service_name
fi
#检测supervisor是否有这个服务
service_name="supervisor"
kiop_systemctl_have $service_name
if [ $? = 1 ]; then
kiop_supervisor_init
fi
}
kiop_setup_init
echo 'end update kiop ********************************************************'
echo 'update kiop finish'
echo "-----------------##################-----------------"
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。