1
0

ref: 构建工具重构

This commit is contained in:
TsMask
2025-03-19 17:21:47 +08:00
parent f2e43b0fc4
commit b2f867b86c
211 changed files with 1047 additions and 105510 deletions

9
pkg/deb/DEBIAN/control Normal file
View File

@@ -0,0 +1,9 @@
Package: OMC
Version: {version}-{date}
Section: OMC-Team
Prioritt: optional
Architecture: {arch}
Maintainer: OMC-Team
Depends:
Description:
OMC is a management application for the 5GC core network.

54
pkg/deb/DEBIAN/postinst Normal file
View File

@@ -0,0 +1,54 @@
# !/bin/bash
# 安装后执行脚本
RootDir=/usr/local/etc/omc
# Perform post-installation configuration
echo ""
echo "Output: $RootDir"
echo "Please Run:"
echo " sudo systemctl start|stop|status|restart omc.service"
echo ""
# 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/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
rm -rf $RootDir/vendor
systemctl daemon-reload
systemctl enable omc.service
systemctl enable sshsvc.service
systemctl daemon-reload
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

23
pkg/deb/DEBIAN/postrm Normal file
View File

@@ -0,0 +1,23 @@
# !/bin/bash
# 卸载后执行脚本
case "$1" in
remove)
# 卸载操作
# 删除服务文件
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
# 移除相关文件
rm -rf /usr/local/bin/omc
rm -rf /usr/local/etc/omc
;;
upgrade)
# 更新操作
;;
esac

4
pkg/deb/DEBIAN/preinst Normal file
View File

@@ -0,0 +1,4 @@
# !/bin/bash
# 安装前执行脚本
rm -rf /usr/local/etc/omc/default

7
pkg/deb/DEBIAN/prerm Normal file
View File

@@ -0,0 +1,7 @@
# !/bin/bash
# 卸载前执行脚本
# 停止服务
systemctl daemon-reload
systemctl stop omc.service
systemctl stop sshsvc.service

0
pkg/rpm/BUILD/.gitkeep Normal file
View File

102
pkg/rpm/SPECS/omc.spec Normal file
View File

@@ -0,0 +1,102 @@
Name: omc
Version: {version}
Release: {date}
Summary: OMC-Team
License: GPL
Group: Applications/Communications
BuildArch: {arch}
# 软件说明
%description
OMC-Team for NE
# 打包前脚本 ========
%prep
rm -rf ${RPM_BUILD_ROOT} && mkdir -p ${RPM_BUILD_ROOT}
cp -rf ${RPM_BUILD_DIR}/* ${RPM_BUILD_ROOT}/
# 安装前脚本 ========
%pre
rm -rf /usr/local/etc/omc/default
# 安装后脚本 ========
%post
RootDir=/usr/local/etc/omc
# 执行安装后配置
echo ""
echo "Output: $RootDir"
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 " remove: "
echo " firewall-cmd --zone=public --remove-port=33030/tcp --permanent && firewall-cmd --reload"
echo ""
# 检查是否是第一次安装或是升级
if [ ! -f $RootDir/omc.yaml ]; then
# 第一次安装,执行相关操作
chmod +rx /usr/local/bin/omc
cp $RootDir/default/omc.yaml $RootDir/omc.yaml
cp $RootDir/default/oam_manager.yaml $RootDir/oam_manager.yaml
systemctl daemon-reload
systemctl enable omc.service
systemctl daemon-reload
systemctl stop omc.service
systemctl start omc.service
else
# 升级时的操作
systemctl daemon-reload
systemctl start omc.service
fi
# 卸载前脚本 ========
%preun
# 停止服务
systemctl daemon-reload
systemctl stop omc.service
# 卸载后脚本 ========
%postun
case "$1" in
0)
# 卸载操作
# 删除服务文件
systemctl daemon-reload
systemctl disable omc.service
rm -rf /lib/systemd/system/omc.service
systemctl daemon-reload
# 移除相关文件
rm -rf /usr/local/bin/omc
rm -rf /usr/local/etc/omc
;;
1)
# 更新操作
;;
esac
# 包含的文件 ========
%files
%defattr(-,root,root,-)
/usr/local/etc/omc/*
/usr/local/bin/omc
/lib/systemd/system/omc.service
# 更新日志 ========
%changelog
* Wed Jan 01 2025 omc <omc@example.com> - {version}
- Build package {date}.