diff --git a/pkg/rpm/SPECS/omc.spec b/pkg/rpm/SPECS/omc.spec index 56f9050..5c2134c 100644 --- a/pkg/rpm/SPECS/omc.spec +++ b/pkg/rpm/SPECS/omc.spec @@ -10,7 +10,7 @@ BuildArch: {arch} # 软件说明 %description -OMC-Team for NE +OMC is a management application for the 5GC core network. # 打包前脚本 ======== @@ -35,35 +35,62 @@ echo "Please Run:" echo " sudo systemctl start|stop|status|restart omc.service" echo "Setting Firewall:" echo " add: " -echo " firewall-cmd --zone=public --add-port=33030/tcp --permanent && firewall-cmd --reload" +echo " firewall-cmd --zone=public --add-port=80/tcp --permanent && firewall-cmd --reload" echo " remove: " -echo " firewall-cmd --zone=public --remove-port=33030/tcp --permanent && firewall-cmd --reload" +echo " firewall-cmd --zone=public --remove-port=80/tcp --permanent && firewall-cmd --reload" echo "" -# 检查是否是第一次安装或是升级 -if [ ! -f $RootDir/omc.yaml ]; then - # 第一次安装,执行相关操作 +# Check if this is the first installation or upgrade +if [ ! -f $RootDir/omc.conf ]; then + # First installation, perform the related operations chmod +rx /usr/local/bin/omc + cp $RootDir/default/omc.conf $RootDir/omc.conf cp $RootDir/default/omc.yaml $RootDir/omc.yaml - cp $RootDir/default/oam_manager.yaml $RootDir/oam_manager.yaml + cp $RootDir/default/sshsvc.yaml $RootDir/sshsvc.yaml + + # read environment parameter and to do + if [ -n "$M_PARAM" ] && [ -n "$C_PARAM" ]; then + bash $RootDir/script/setup.sh -i -m $M_PARAM -c $C_PARAM + elif [ -n "$C_PARAM" ]; then + bash $RootDir/script/setup.sh -i -c $C_PARAM + else + bash $RootDir/script/setup.sh -i + fi + if [ $? -ne 0 ]; then + echo "Initialization failure." + rm -rf $RootDir + exit 1 + fi systemctl daemon-reload systemctl enable omc.service + systemctl enable sshsvc.service systemctl daemon-reload - systemctl stop omc.service - systemctl start omc.service + systemctl restart omc.service + systemctl restart sshsvc.service else - # 升级时的操作 + # Operation when upgrading + + bash $RootDir/script/setup.sh -u + if [ $? -ne 0 ]; then + echo "Upgrade failed." + exit 1 + fi + systemctl daemon-reload systemctl start omc.service + systemctl start sshsvc.service fi +rm -rf $RootDir/vendor + # 卸载前脚本 ======== %preun # 停止服务 systemctl daemon-reload systemctl stop omc.service +systemctl stop sshsvc.service # 卸载后脚本 ======== @@ -75,7 +102,9 @@ case "$1" in # 删除服务文件 systemctl daemon-reload systemctl disable omc.service + systemctl disable sshsvc.service rm -rf /lib/systemd/system/omc.service + rm -rf /lib/systemd/system/sshsvc.service systemctl daemon-reload # 移除相关文件 @@ -91,9 +120,10 @@ esac # 包含的文件 ======== %files %defattr(-,root,root,-) +/lib/systemd/system/* +/usr/local/bin/* /usr/local/etc/omc/* -/usr/local/bin/omc -/lib/systemd/system/omc.service +/usr/local/omc/* # 更新日志 ========