1
0
Files
build.ems/pkg/rpm/SPECS/omc.spec

136 lines
3.2 KiB
RPMSpec

Name: omc
Version: {version}
Release: {date}
Summary: OMC-Team
License: Proprietary
Group: Applications/Communications
BuildArch: {arch}
# Software Description ========
%description
OMC for 4G/5G Core Network Software
# Pre-Packaging Script ========
%prep
rm -rf ${RPM_BUILD_ROOT} && mkdir -p ${RPM_BUILD_ROOT}
cp -rf ${RPM_BUILD_DIR}/* ${RPM_BUILD_ROOT}/
chmod 644 ${RPM_BUILD_ROOT}/usr/local/etc/omc/web/wiregasm/wiregasm.wasm
# Pre-Installation Scripts ========
%pre
rm -rf /usr/local/etc/omc/default
# Post-Installation Scripts ========
%post
RootDir=/usr/local/etc/omc
# Perform post-installation configuration
echo ""
echo "Output: $RootDir"
echo "Service:"
echo " sudo systemctl [start|stop|status|restart] omc.service"
echo "Firewall:"
echo " add: "
echo " firewall-cmd --zone=public --add-port=80/tcp --permanent && firewall-cmd --reload"
echo " remove: "
echo " firewall-cmd --zone=public --remove-port=80/tcp --permanent && firewall-cmd --reload"
echo ""
# Check if this is the first installation or upgrade
if [ ! -f $RootDir/machine.ini ]; 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/web/default/config.js $RootDir/web/config.js
# 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 daemon-reload
systemctl restart omc.service
else
# Operation when upgrading
if [ ! -f $RootDir/omc.conf ]; then
chmod +rx /usr/local/bin/omc
cp $RootDir/default/omc.conf $RootDir/omc.conf
cp $RootDir/default/omc.yaml $RootDir/omc.yaml
cp $RootDir/web/default/config.js $RootDir/web/config.js
fi
# Override Configuration
if ! grep -q "# route service configuration" $RootDir/omc.yaml; then
cp -rf $RootDir/default/omc.yaml $RootDir/omc.yaml
fi
systemctl stop omc.service
bash $RootDir/script/setup.sh -u
if [ $? -ne 0 ]; then
echo "Upgrade failed."
exit 1
fi
systemctl daemon-reload
systemctl restart omc.service
fi
echo ""
# Pre-uninstallation script ========
%preun
# Stop Service
systemctl daemon-reload
systemctl stop omc.service
# Post-uninstallation script ========
%postun
case "$1" in
0)
# Uninstallation operations
# Deletion of service files
rm -rf /lib/systemd/system/omc.service
systemctl daemon-reload
# Removal of relevant documents
rm -rf /usr/local/bin/omc
rm -rf /usr/local/etc/omc
;;
1)
# Update Operation
;;
esac
# Included documents ========
%files
%defattr(-,root,root,-)
/lib/systemd/system/*
/usr/local/bin/*
/usr/local/etc/omc/*
/usr/local/omc/*
# Update Log ========
%changelog
* Wed Jan 01 2025 omc <omc@example.com> - {version}
- Build package {date}.