1 Commits
Author SHA1 Message Date
admin 795df854df Initial commit 2026-10-29 06:36:12 +00:00
54 changed files with 2 additions and 2173 deletions

No files matched your search

-21
View File
@@ -1,21 +0,0 @@
# ---> VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
.idea/
# Built Visual Studio Code Extensions
*.vsix
*.log
*.log
*.bak
*.exe
# Build Output
tmp/*
+2 -36
View File
@@ -1,37 +1,3 @@
# Quickstart Of Build # build.ems
## Platform OMC 打包脚本
OS: Ubuntu 18.04 / 22.04 (Recommendation)
Golang: go1.24.2 (or above)
Database: 10.6.16-MariaDB, Redis server v=5.0.5 (or above)
node.js: v20.18.0 (or above)
## Build Guide
### Pull Code
`pwd` default in `/root`
```bash
git clone https://xxx@git/ems.git omc.git
cd omc.git && ls
# be.ems build.ems fe.ems.vue3
cp build.ems/pkg-* .
```
### Build System Pageage Manager
Modify the information in the script as appropriate
```bash
# Universal
bash pkg.sh --web --api -v 2.2508.1
# RemoveChinese
bash pkg-remove-chinese.sh --web --api -v 2.2508.1
# Docker
bash pkg-docker.sh -v 2.2508.1
```
-163
View File
@@ -1,163 +0,0 @@
#!/bin/bash
# Check if Docker is installed
if command -v docker &> /dev/null; then
echo $(docker --version)
else
echo "Docker is not installed"
exit 1
fi
# Default Version
VERSION="1.0.0"
# Default Platform
PLATFORM="amd64"
# Default System
SYSTEM="ubuntu22.04"
# usage
usage() {
echo "Usage: bash $0 [OPTION]"
echo
echo "Build Software Package OPTION:"
echo " -v, --version Specify the version"
echo " -p, --platform Specify the platform architecture (amd64,arm64)"
echo " -s, --system Specify the system image (ubuntu22.04,alpine3.20)"
echo " -h Display this help message"
echo
exit 1
}
# Read command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-v|--version) VERSION="$2"; shift 2 ;; # Processing the version after -v
-p|--platform) PLATFORM="$2"; shift 2 ;; # Processing the platform after -p
-s|--system) SYSTEM="$2"; shift 2 ;; # Processing the system after -s
*) usage ;;
esac
done
# output result
echo "Version: $VERSION"
# =================== Compile System Information
# Determine if -p is passed in
if [ -n "$PLATFORM" ]; then
case $PLATFORM in
amd64) ;;
arm64) ;;
*)
echo "Error: platform be: $PLATFORM"
echo "can only be amd64/arm64"
exit 1
;;
esac
fi
echo "Platform: $PLATFORM"
# Determine if -s is passed in
if [ -n "$SYSTEM" ]; then
case $SYSTEM in
ubuntu22.04) ;;
alpine3.20) ;;
*)
echo "unknown system image: $SYSTEM"
exit 1
;;
esac
fi
echo "System: $SYSTEM"
# =================== Compile Variable Information
# Script Path
RootDir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# Compile Linux System Directory
BuildLinuxDir=${RootDir}/linux
# Compile Package Management Directory
BuildPackagelDir=${RootDir}/pkg
# Compile the build directory
BuildDir=${RootDir}/tmp
# Release Package directory
ReleaseDir=${RootDir}/release/docker/${PLATFORM}
# Release Package name file
ReleaseFileName=omc-r${VERSION}-docker-${SYSTEM}-${PLATFORM}
# =================== file processing
# Apply file handling
app() {
cd ${BuildDir}
# Database scripts within common are rebuild scripts
modeList="std lite"
for v in ${modeList}; do
# . /Located in the temporary directory
path=./linux/usr/local/etc/omc/database/${v}
cp -rf $path/common/* $path/install/
cp -rf $path/common/* $path/upgrade/
rm -rf $path/common
done
}
# =================== compile
docker_build() {
cd ${BuildDir}
# Replacement Tags {version} {arch}
sed -i "s/{version}/${VERSION}/g" ./${ReleaseFileName}/omc-docker.sh
sed -i "s/{arch}/${PLATFORM}/g" ./${ReleaseFileName}/omc-docker.sh
sed -i "s/{system}/${SYSTEM}/g" ./${ReleaseFileName}/omc-docker.sh
# check docker image
if ! docker images | grep -q "mariadb-$PLATFORM\s*10.6.21"; then
docker pull --platform linux/${PLATFORM} mariadb:10.6.21
docker tag mariadb:10.6.21 mariadb-$PLATFORM:10.6.21
fi
if [ ! -f ${BuildDir}/$ReleaseFileName/tar/mariadb_10.6.21_$PLATFORM.tar ]; then
docker save mariadb-$PLATFORM:10.6.21 -o ${BuildDir}/${ReleaseFileName}/tar/mariadb_10.6.21_$PLATFORM.tar
fi
if ! docker images | grep -q "keydb-$PLATFORM\s*6.3.4"; then
docker pull --platform linux/${PLATFORM} bitnami/keydb:6.3.4
docker tag bitnami/keydb:6.3.4 keydb-$PLATFORM:6.3.4
fi
if [ ! -f ${BuildDir}/$ReleaseFileName/tar/keydb_6.3.4_$PLATFORM.tar ]; then
docker save keydb-$PLATFORM:6.3.4 -o ${BuildDir}/${ReleaseFileName}/tar/keydb_6.3.4_$PLATFORM.tar
fi
# build omc
docker build --platform linux/${PLATFORM} --build-arg TARGETARCH=${PLATFORM} --build-arg VERSION=${VERSION} -t omc:${VERSION}-${SYSTEM}-${PLATFORM} .
docker save omc:${VERSION}-${SYSTEM}-${PLATFORM} -o ${BuildDir}/${ReleaseFileName}/tar/omc_${VERSION}-${SYSTEM}-${PLATFORM}.tar
# tar package
filename=${ReleaseFileName}.tar.gz
output=${ReleaseDir}/${filename}
tar -czf ${output} ./${ReleaseFileName}
echo "build success => ${output}"
# Generate HAX file
cd ${ReleaseDir}
md5sum ${filename} > ${filename}.md5
echo "md5 => $(cat ${filename}.md5)"
sha256sum ${filename} > ${filename}.sha256
echo "sha256 => $(cat ${filename}.sha256)"
}
# =================== building
echo
echo "building omc..."
mkdir -p ${BuildDir}/${ReleaseFileName}/tar
cp -rf ${BuildLinuxDir} ${BuildDir}
cp -rf ${BuildPackagelDir}/docker/linux ${BuildDir}
cp -rf ${BuildPackagelDir}/docker/tar/* ${BuildDir}/${ReleaseFileName}
cp -rf ${BuildPackagelDir}/docker/Dockerfile.${SYSTEM} ${BuildDir}/Dockerfile
app
docker_build
# bash build-docker.sh --version 2.2505.2 --platform amd64 --system ubuntu22.04
# bash build-docker.sh --version 2.2505.2 --platform amd64 --system alpine3.20
-187
View File
@@ -1,187 +0,0 @@
#!/bin/bash
# Default Version
VERSION="1.0.0"
# usage
usage() {
echo "Usage: bash $0 [OPTION]"
echo
echo "Build Software Package OPTION:"
echo " -v Specify the version"
echo " -h Display this help message"
echo
exit 1
}
# Read command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-v) VERSION="$2"; shift 2 ;; # Processing the version after -v
*) usage ;;
esac
done
# output result
echo "Version: $VERSION"
# =================== Compile System Information
# package manager
get_manager() {
if command -v rpm &> /dev/null; then
echo "rpm"
elif command -v dpkg &> /dev/null; then
echo "deb"
else
echo "unknown manager"
cat /etc/os-release
exit 1
fi
}
# Get the package manager of the current system
PACKAGE_MANAGER=$(get_manager)
echo "Package Manager: $PACKAGE_MANAGER"
# System Architecture
get_arch() {
ARCH_UNAME=$(uname -m)
case $ARCH_UNAME in
x86_64) echo "amd64" ;;
aarch64) echo "arm64" ;;
i386|i686) echo "i386" ;;
*)
echo "unknown architecture: $ARCH_UNAME"
exit 1
;;
esac
}
# Get the architecture of the current system
PACKAGE_ARCH=$(get_arch)
echo "Architecture: $PACKAGE_ARCH"
# Operating System Name Version
get_os_name_version() {
if [ -f /etc/os-release ]; then
. /etc/os-release
# 检查 $ID 是否为空
if [ -z "$ID" ]; then
echo "ID is not defined in /etc/os-release"
exit 1
fi
echo "$ID$VERSION_ID"
else
echo "unknown ID: /etc/os-release not found"
exit 1
fi
}
# Get the current operating system name version
OS_NAME=$(get_os_name_version)
echo "OS Version: $OS_NAME"
# =================== Compile Variable Information
# Compile Date
Date=`date +%Y%m%d`
# Script Path
RootDir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# Compile Linux System Directory
BuildLinuxDir=${RootDir}/linux
# Compile Package Management Directory
BuildPackagelDir=${RootDir}/pkg
# Compile the build directory
BuildDir=${RootDir}/tmp
# Release Package directory
ReleaseDir=${RootDir}/release/${PACKAGE_MANAGER}/${PACKAGE_ARCH}
# Release Package name file
ReleaseFileName=omc-r${VERSION}-${Date}-${OS_NAME}-${PACKAGE_ARCH}.${PACKAGE_MANAGER}
# =================== file processing
# Apply file handling . /Located in the temporary directory
app() {
# Database scripts within common are rebuild scripts
modeList="std lite"
for v in ${modeList}; do
path=./usr/local/etc/omc/database/${v}
cp -rf $path/common/* $path/install/
cp -rf $path/common/* $path/upgrade/
rm -rf $path/common
done
}
# =================== system package manager
# deb package manager
deb() {
cd ${BuildDir}
# Replacement Tags {version} {arch}
sed -i "s/{arch}/${PACKAGE_ARCH}/g" ./DEBIAN/control
sed -i "s/{version}/${VERSION}/g" ./DEBIAN/control
sed -i "s/{date}/${Date}/g" ./DEBIAN/control
# Packaging deb
chmod 755 -R ${BuildDir}
dpkg -b ${BuildDir} ${ReleaseDir}/${ReleaseFileName}
echo "build success => ${ReleaseDir}/${ReleaseFileName}"
# Generate HAX file
cd ${ReleaseDir}
md5sum ${ReleaseFileName} > ${ReleaseFileName}.md5
echo "md5 => $(cat ${ReleaseFileName}.md5)"
sha256sum ${ReleaseFileName} > ${ReleaseFileName}.sha256
echo "sha256 => $(cat ${ReleaseFileName}.sha256)"
}
# rpm package manager
rpm() {
cd ${BuildDir}
ARCH_UNAME=$(uname -m)
# Replacement Tags {version} {arch} {date}
sed -i "s/{version}/${VERSION}/g" ./SPECS/omc.spec
sed -i "s/{arch}/${ARCH_UNAME}/g" ./SPECS/omc.spec
sed -i "s/{date}/${Date}/g" ./SPECS/omc.spec
# Packaging rpm
chmod 755 -R ${BuildDir}
rpmbuild -bb -D "_topdir ${BuildDir}" ${BuildDir}/SPECS/omc.spec
# Moving package to the distribution directory
if [[ "$OS_NAME" = "kylinV10" ]]; then # kylin system has ky10 tags
mv ${BuildDir}/RPMS/${ARCH_UNAME}/omc-${VERSION}-${Date}.ky10.${ARCH_UNAME}.rpm ${ReleaseDir}/${ReleaseFileName}
else
mv ${BuildDir}/RPMS/${ARCH_UNAME}/omc-${VERSION}-${Date}.${ARCH_UNAME}.rpm ${ReleaseDir}/${ReleaseFileName}
fi
rm -rf ${BuildDir}/RPMS
echo "build success => ${ReleaseDir}/${ReleaseFileName}"
# Generate HAX file
cd ${ReleaseDir}
md5sum ${ReleaseFileName} > ${ReleaseFileName}.md5
echo "md5 => $(cat ${ReleaseFileName}.md5)"
sha256sum ${ReleaseFileName} > ${ReleaseFileName}.sha256
echo "sha256 => $(cat ${ReleaseFileName}.sha256)"
}
# =================== building
echo
echo "building omc..."
rm -rf ${BuildDir} && mkdir -p ${BuildDir}
cp -rf ${BuildPackagelDir}/${PACKAGE_MANAGER}/* ${BuildDir}
if [[ $PACKAGE_MANAGER = "deb" ]]; then
cp -rf ${BuildLinuxDir}/* ${BuildDir}
cd ${BuildDir}
app
deb
elif [[ $PACKAGE_MANAGER = "rpm" ]]; then
cp -rf ${BuildLinuxDir}/* ${BuildDir}/BUILD
cd ${BuildDir}/BUILD
app
rpm
else
echo "unknown runing: $PACKAGE_MANAGER"
exit 1
fi
# bash build.sh -v 2.2505.2
-11
View File
@@ -1,11 +0,0 @@
[Unit]
Description=omc execute script daemon
[Service]
ExecStart=/usr/local/etc/omc/script/omc_exec.sh
StandardOutput=append:/var/log/omc_exec.log
StandardError=append:/var/log/omc_exec.log
Type=oneshot
[Install]
WantedBy=multi-user.target
-18
View File
@@ -1,18 +0,0 @@
[Unit]
Description=omc service daemon
After=network-online.target kvdb.service
Wants=network-online.target
[Service]
Type=simple
LimitNOFILE=65535
LimitNPROC=65535
Restart=always
ExecStart=/usr/local/bin/omc -c /usr/local/etc/omc/omc.yaml
RestartSec=3
RestartPreventExitStatus=SIGTERM SIGKILL
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
-1
View File
@@ -1 +0,0 @@
占位
-72
View File
@@ -1,72 +0,0 @@
#!/bin/bash
ServiceList="omc"
BinDir="/usr/local/bin"
# Check if the service exists
check_service() {
systemctl list-unit-files | grep -q "$1.service"
return $?
}
case "$1" in
start)
for v in $ServiceList; do
if ! check_service "$v"; then
echo "Service $v does not exist"
continue
fi
systemctl start $v
if [ $? = 0 ]; then
echo "Starting $v process done"
else
echo "Failed to start $v"
fi
sleep 1
done
;;
status)
for v in $ServiceList; do
if ! check_service "$v"; then
echo "Service $v does not exist"
continue
fi
echo "=== Status of $v ==="
systemctl status --no-pager -n 20 $v
echo ""
done
;;
stop)
for v in $ServiceList; do
if ! check_service "$v"; then
echo "Service $v does not exist"
continue
fi
systemctl stop $v
if [ $? = 0 ]; then
echo "Stopping $v process done"
else
echo "Failed to stop $v"
fi
done
;;
restart)
$0 stop
sleep 1
$0 start
;;
version)
for v in $ServiceList; do
if [ -x "$BinDir/$v" ]; then
$BinDir/$v --version
else
echo "$v binary not found in $BinDir"
fi
done
;;
*)
echo "OMC Service Control"
echo "Usage: $0 start|status|stop|restart|version"
echo ""
;;
esac
@@ -1,33 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIFqzCCA5OgAwIBAgIUd84SMrVmGfyUArN/y78WQY518DIwDQYJKoZIhvcNAQEL
BQAwZTELMAkGA1UEBhMCQ04xDDAKBgNVBAgMAzVHQzEMMAoGA1UEBwwDNUdDMREw
DwYDVQQKDAhPTUMtVGVhbTERMA8GA1UECwwIT01DLVRlYW0xFDASBgNVBAMMC3d3
dy5vbWMubmV0MB4XDTI1MDQyNzA4NDEzMloXDTM1MDQyNTA4NDEzMlowZTELMAkG
A1UEBhMCQ04xDDAKBgNVBAgMAzVHQzEMMAoGA1UEBwwDNUdDMREwDwYDVQQKDAhP
TUMtVGVhbTERMA8GA1UECwwIT01DLVRlYW0xFDASBgNVBAMMC3d3dy5vbWMubmV0
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAm+870e0lMn8f9P/340HS
cXdEoCWsBGRSuYTZVymY3qeX2uRCfxgrV+y0l5HBYS7jfER6Fd58Ixesd9UXPH06
mWCycl2U1HTxE0miUMVeD37QPYldehy52R/TqXnsCJRBteYvLUlIr1xC0cZR+LYE
4uK0h4VrcANnHrU1c0r1EZIMU1ANZU0EqEOtjUU/+IT/fOUR8MHzTnu20/DpogHU
4v4nG2H94nj5MTzwvjLlTx5EU1VD0J93qHZHkzw+kOWCLDWH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gcYduoTCmntMe85DSviZD0bZ5Ez5ocsT2cTMBvltT1YZjU5F91H87qhzZlVqP9C5
Sml2mY+QYi9yifEYqp5Qth5W5bcp+QV/LecAS6Rv3xbkd5nV4v0oN8ekp40iA3+q
bqoyWol6pHym+3X0j3bHwWbBz1QG6H1rzi6n6fM08lfvT7bHvh+4iOQEm/ph/Alh
RNodAySNybYrYHj6i4VkgDxYg+FhYg==
-----END PRIVATE KEY-----
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
@@ -1,49 +0,0 @@
upstream lbHTTPByOMC {
server 127.0.0.1:33030 max_fails=3 fail_timeout=30s;
#server 127.0.0.2:33030 max_fails=3 fail_timeout=30s;
}
server {
listen 80;
listen [::]:80;
server_name www.omc.local;
client_max_body_size 100M;
keepalive_timeout 180s;
# access_log /var/log/nginx/host.access.log main;
location / {
root /usr/local/etc/omc/web;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /omc-api/ {
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_connect_timeout 180s;
proxy_send_timeout 180s;
proxy_read_timeout 180s;
proxy_pass http://lbHTTPByOMC/;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
return 301 http://$host$request_uri;
}
}
@@ -1,58 +0,0 @@
upstream lbHTTPSByOMC {
server 127.0.0.1:33443 max_fails=3 fail_timeout=30s;
#server 127.0.0.2:33443 max_fails=3 fail_timeout=30s;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.omc.net;
ssl_certificate /usr/local/etc/omc/certs/www.omc.net.crt;
ssl_certificate_key /usr/local/etc/omc/certs/www.omc.net.key;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_session_timeout 5m;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
#ssl_dhparam /usr/share/nginx/cert/dhparams.pem;
client_max_body_size 100M;
keepalive_timeout 180s;
# access_log /var/log/nginx/host.access.log main;
location / {
root /usr/local/etc/omc/web;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /omc-api/ {
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_connect_timeout 180s;
proxy_send_timeout 180s;
proxy_read_timeout 180s;
proxy_pass https://lbHTTPSByOMC/;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
return 301 https://$host$request_uri;
}
}
-33
View File
@@ -1,33 +0,0 @@
upstream lbByOMC {
server 127.0.0.1:33030 max_fails=3 fail_timeout=30s;
#server 127.0.0.2:33030 max_fails=3 fail_timeout=30s;
}
server {
listen 33040;
listen [::]:33040;
server_name omc;
client_max_body_size 100M;
keepalive_timeout 180s;
# access_log /var/log/nginx/host.access.log main;
location / {
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_connect_timeout 180s;
proxy_send_timeout 180s;
proxy_read_timeout 180s;
proxy_pass https://lbByOMC/;
}
}
-46
View File
@@ -1,46 +0,0 @@
basic:
dnn_data: internet
dnn_ims: ims
plmnId:
mcc: "460"
mnc: "60"
snssai:
sd: "460001"
sst: "1"
tac: "4388"
external:
amfn2_ip: 172.16.5.120
ims_sip_ip: 172.16.5.110
mmes1_ip: 172.16.5.220/20
mmes10_ip: 172.16.5.221/24
mmes11_ip: 172.16.5.220/24
ue_pool: 10.2.1.0/24
upf_driver_type: vmxnet3
upf_type: LightUPF
upfn3_card_name: eth0
upfn3_gw: 192.168.1.1
upfn3_ip: 172.16.5.190/24
upfn3_mac: "00:00:00:00:00:00"
upfn3_pci: "0000:00:00.0"
upfn6_card_name: eth0
upfn6_gw: 192.168.1.1
upfn6_ip: 172.16.5.191/24
upfn6_mac: "00:00:00:00:00:00"
upfn6_pci: "0000:00:00.0"
sbi:
amf_ip: 172.16.5.120
ausf_ip: 172.16.5.130
db_ip: 0.0.0.0
ims_ip: 172.16.5.110
lmf_ip: 172.16.5.200
mme_ip: 172.16.5.220
n3iwf_ip: 172.16.5.230
nef_ip: 172.16.5.210
nrf_ip: 172.16.5.180
nssf_ip: 172.16.5.170
omc_ip: 172.16.5.100
pcf_ip: 172.16.5.160
smf_ip: 172.16.5.150
smsc_ip: 172.16.5.240
udm_ip: 172.16.5.140
upf_ip: 172.16.5.190
-212
View File
@@ -1,212 +0,0 @@
#!/bin/bash
declare -A NE_LIST
# Default network element number ne_id = 001
# Defining a list of network elements
# Format: "ne_type, ne_ip, ne_port"
# -----------------------------------------
# ne_id 001 Network Elements
# -----------------------------------------
NE_LIST["001"]="\
OMC,172.16.5.100,33030
IMS,172.16.5.110,33030
AMF,172.16.5.120,33030
AUSF,172.16.5.130,33030
UDM,172.16.5.140,33030
SMF,172.16.5.150,33030
PCF,172.16.5.160,33030
UPF,172.16.5.190,33030
"
# -----------------------------------------
# ne_id 002 Network Elements
# -----------------------------------------
# NE_LIST["002"]="\
# IMS,172.16.15.110,33030
# AMF,172.16.15.120,33030
# AUSF,172.16.15.130,33030
# UDM,172.16.15.140,33030
# SMF,172.16.15.150,33030
# PCF,172.16.15.160,33030
# UPF,172.16.15.190,33030
# "
# Default SSH info
DEFAULT_SSH_USER="manager"
DEFAULT_SSH_PORT=22
# If you already have a password-free authorization, please set the password to ""
#DEFAULT_SSH_PWD=""
DEFAULT_SSH_PWD="bSQ21KY7cjn58JNkZ0UZM64EbSIPMQwfCTmzk3MTBvQ=" # admin123
# 5gc+omc use local 127.0.0.1
DEFAULT_SSH_LOCAL=false
# Default ne_host info
DEFAULT_TELNET_PORT=4100
DEFAULT_TELNET_PORT2=5002
DEFAULT_REDIS_PORT=6379
# Path to the output file
output_file="output.sql"
# Empty the contents of the file (if the file already exists)
> "$output_file"
# ======================= generate sql
# ne_info
# generate_ne_info 1 OMC 001 127.0.0.1 33030 1,2
generate_ne_info() {
local row_id=$1
local ne_type=$2
local ne_id=$3
local ip=$4
local port=$5
local ne_host=$6
local ne_name="${ne_type}_${ne_id}"
local ne_rmuid="4400HX${ne_type}${ne_id}"
echo "INSERT INTO ne_info VALUES (${row_id}, '${ne_type}', '${ne_id}', '${ne_rmuid}', '${ne_name}', '${ip}', ${port}, 'PNF', '-', '-', '-', '-', '${ne_host}', 1, '', '', 0, 'script', $(date +%s%3N));"
}
# ne_host
# generate_ne_host 1 OMC 001 127.0.0.1
generate_ne_host() {
local row_id=$1
local ne_type=$2
local ne_id=$3
local ip=$4
local ne_name="${ne_type}_${ne_id}"
local start_id=$row_id
local ssh_ip=$4
if [ "$DEFAULT_SSH_LOCAL" == true ]; then
ssh_ip="127.0.0.1"
fi
local ssh_type="2"
local ssh_password=""
if [ -n "$DEFAULT_SSH_PWD" ]; then
ssh_type="0"
ssh_password="$DEFAULT_SSH_PWD"
fi
# SSH
echo "INSERT INTO ne_host VALUES (${start_id}, 'ssh', '1', '${ne_name}_${DEFAULT_SSH_PORT}_${start_id}', '${ssh_ip}', ${DEFAULT_SSH_PORT}, '${DEFAULT_SSH_USER}', '${ssh_type}', '${ssh_password}', '', '', '', '', 'script', $(date +%s%3N), 'script', $(date +%s%3N));"
((start_id++))
# Telnet
echo "INSERT INTO ne_host VALUES (${start_id}, 'telnet', '1', '${ne_name}_${DEFAULT_TELNET_PORT}_${start_id}', '${ip}', ${DEFAULT_TELNET_PORT}, 'admin', '0', 'okzArqkFYlnVVdQYkNiqmiW+CGQrxg1AFmroR1bw1Kg=', '', '', '', '', 'script', $(date +%s%3N), 'script', $(date +%s%3N));"
((start_id++))
# Special network element type handling
case "$ne_type" in
"UDM")
echo "INSERT INTO ne_host VALUES (${start_id}, 'redis', '1', '${ne_name}_${DEFAULT_REDIS_PORT}_${start_id}', '${ip}', ${DEFAULT_REDIS_PORT}, 'udmdb', '0', 'jW965gWZK0mw6EtYfihMV9QqHjqa03vJ8VlVii9non8=', '', '', '0', '', 'script', $(date +%s%3N), 'script', $(date +%s%3N));"
;;
"UPF")
echo "INSERT INTO ne_host VALUES (${start_id}, 'telnet', '1', '${ne_name}_${DEFAULT_TELNET_PORT2}_${start_id}', '${ip}', ${DEFAULT_TELNET_PORT2}, 'admin', '0', '', '', '', '', '', 'script', $(date +%s%3N), 'script', $(date +%s%3N));"
;;
esac
}
# generate_ne_host_ids OMC 1
generate_ne_host_ids() {
local ne_type=$1
local start_id=$2
local ids="${start_id},$((start_id+1))"
case "$ne_type" in
"UDM")
ids="${ids},$((start_id+2))"
;;
"UPF")
ids="${ids},$((start_id+2))"
;;
esac
echo "$ids"
}
# ne_version
# generate_ne_version 1 OMC 001
generate_ne_version() {
local row_id=$1
local ne_type=$2
local ne_id=$3
echo "INSERT INTO ne_version VALUES (${row_id}, '${ne_type}', '${ne_id}', '-', '-', '-', '', '', '', '', '', '', '0', 'script', $(date +%s%3N), 'script', $(date +%s%3N));"
}
# ne_license
# generate_ne_license 1 OMC 001
generate_ne_license() {
local row_id=$1
local ne_type=$2
local ne_id=$3
echo "INSERT INTO ne_license VALUES (${row_id}, '${ne_type}', '${ne_id}', '', '', 0, '', '', '1', '', 'script', $(date +%s%3N), 'script', $(date +%s%3N));"
}
# =======================
# Execute output sql to file
execute_output() {
local row_id=1
local host_id=1
# empty the table
echo "DELETE FROM ne_host;" >> "$output_file"
echo "DELETE FROM ne_info;" >> "$output_file"
echo "DELETE FROM ne_version;" >> "$output_file"
echo "DELETE FROM ne_license;" >> "$output_file"
echo "" >> "$output_file"
# -----------------------------------------
# Example of accessing and parsing the elements
# -----------------------------------------
for ne_id in "${!NE_LIST[@]}"; do
echo "NEID: $ne_id:"
# Splitting the values by newline to get each device entry
IFS=$'\n' read -r -d '' -a devices <<< "${NE_LIST[$ne_id]}"
# Iterating over each device entry
for device in "${devices[@]}"; do
# Split device entry into name, IP, and port
IFS=',' read -r ne_type ne_ip ne_port <<< "$device"
echo "===> ${ne_type} ${ne_ip} ${ne_port}"
generate_ne_host "$host_id" "$ne_type" "$ne_id" "$ne_ip" >> "$output_file"
local host_ids=$(generate_ne_host_ids $ne_type $host_id)
generate_ne_info "$row_id" "$ne_type" "$ne_id" "$ne_ip" "$ne_port" "$host_ids" >> "$output_file"
generate_ne_version "$row_id" "$ne_type" "$ne_id" >> "$output_file"
generate_ne_license "$row_id" "$ne_type" "$ne_id" >> "$output_file"
echo "" >> "$output_file"
((row_id++))
case "$ne_type" in
"UDM"|"UPF")
host_id=$((host_id+3))
;;
*)
host_id=$((host_id+2))
;;
esac
done
done
}
execute_output
# Execute import sql to omc
execute_import() {
local OMCBinFile=/usr/local/bin/omc
local OMCEtcDir=/usr/local/etc/omc
local confFile=$OMCEtcDir/omc.yaml
source $OMCEtcDir/omc.conf
$OMCBinFile -c $confFile --sqlPath $output_file --sqlSource $MODE
}
execute_import
# Remove the output file
rm -rf $output_file
@@ -1 +0,0 @@
#!/bin/bash
-130
View File
@@ -1,130 +0,0 @@
#!/bin/bash
OMCBinFile=/usr/local/bin/omc
OMCEtcDir=/usr/local/etc/omc
confFile=$OMCEtcDir/omc.yaml
VariableFile=$OMCEtcDir/omc.conf
# Read the value of the variable from file
source $VariableFile
# Initializing variables
T_PARAM=""
R_PARAM=false
C_PARAM=""
M_PARAM=""
# usage
usage() {
echo "Usage: bash $0 [OPTION]"
echo
echo "Program Initialization OPTION:"
echo " -i, --install Specify the install"
echo " -u, --upgrade Specify the upgrade"
echo " -r, --remote Specify the remote database"
echo " -m, --mode Available the mode (std/lite)"
echo " -c, --customize Available the customize (omc/agt/ba)"
echo " -h Display this help message"
echo
exit 1
}
# =========================
while [[ $# -gt 0 ]]; do
case "$1" in
-i|--install)
T_PARAM="install"
shift
;;
-u|--upgrade)
T_PARAM="upgrade"
shift
;;
-r|--remote)
R_PARAM=true
shift
;;
-m|--mode)
M_PARAM="$2"
shift 2 # 跳过 -m 参数和值
;;
-c|--customize)
C_PARAM="$2"
shift 2 # 跳过 -c 参数和值
;;
-h)
usage
;;
*)
echo "Error: Unknown option: $1"
usage
;;
esac
done
# Make sure -i or -u comes first.
if [ -z "$T_PARAM" ]; then
echo "Error: You must specify -i (install) or -u (upgrade) first."
usage
fi
# echo "Type parameter: $T_PARAM"
# Determine if -m is passed in
if [ -n "$M_PARAM" ]; then
# Check that mode is within the std range
if [[ "$M_PARAM" != "std" && "$M_PARAM" != "lite" ]]; then
echo "Error: M_PARAM can only be 'std' or 'lite'."
exit 1
fi
sed -i "s/MODE=.*/MODE=${M_PARAM}/" $VariableFile
sed -i "s/serverVersion: \"std\"/serverVersion: \"${M_PARAM}\"/" $confFile
sed -i "/database:/,/defaultDataSourceName:/s/\"std\"/\"${M_PARAM}\"/" $confFile
MODE=$M_PARAM
fi
# echo "Mode parameter: $MODE"
# Determine if -c is passed in
if [ -n "$C_PARAM" ]; then
# Check if customize is within the omc/agt/ba range
if [[ "$C_PARAM" != "omc" && "$C_PARAM" != "agt" && "$C_PARAM" != "ba" ]]; then
echo "Error: C_PARAM can only be 'omc', 'agt' or 'ba'."
exit 1
fi
sed -i "s/VENDORS=.*/VENDORS=${C_PARAM}/" $VariableFile
VENDORS=$C_PARAM
fi
# echo "Customize parameter: $VENDORS"
# ========================= Specify the mode pre-determination
if [[ "$T_PARAM" == "install" ]]; then
case "$MODE" in
std)
# Check if MySQL or MariaDB is installed when not a remote database
if [ "$R_PARAM" = false ]; then
if ! command -v mysql &>/dev/null && ! command -v mariadb &>/dev/null; then
echo "MySQL or MariaDB not installed"
exit 1
fi
fi
;;
lite)
cp -rf $OMCEtcDir/default/omc_db.sqlite $OMCEtcDir/database/omc_db.sqlite
;;
esac
fi
# ========================= Execute the catalog sql file according to the schema
$OMCBinFile -c $confFile --sqlPath $OMCEtcDir/database/$MODE/$T_PARAM --sqlSource $MODE
# ========================= Customize
if [[ -d $OMCEtcDir/vendor ]]; then
if [[ "$T_PARAM" == "install" ]]; then
cp -rf $OMCEtcDir/vendor/$VENDORS/web/* $OMCEtcDir/web/background
cp -rf $OMCEtcDir/vendor/$VENDORS/static/* /usr/local/omc/static
fi
$OMCBinFile -c $confFile --sqlPath $OMCEtcDir/vendor/$VENDORS/database/$MODE/$T_PARAM --sqlSource $MODE
fi
# bash setup.sh -i -m std -c omc
@@ -1,41 +0,0 @@
#!/bin/bash
# Defining a list of SSH
# ssh_user,ssh_ip
# ssh_user,ssh_ip,ssh_port
SSH_LIST=(
"manager,172.16.5.100"
"manager,172.16.5.110"
"manager,172.16.5.120"
"manager,172.16.5.130"
"manager,172.16.5.140"
"manager,172.16.5.150"
"manager,172.16.5.160"
"manager,172.16.5.190"
)
DEFAULT_SSH_PORT=22
# Create .ssh directory if it doesn't exist
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# Check if the SSH key already exists
if [ ! -f ~/.ssh/id_rsa ]; then
# Generate SSH key
ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
fi
for v in "${SSH_LIST[@]}"; do
IFS=',' read -r ssh_user ssh_ip ssh_port <<< "$v"
if [ -z "$ssh_port" ]; then
ssh_port=$DEFAULT_SSH_PORT
fi
echo "===> ${ssh_user} ${ssh_ip} ${ssh_port}"
# Copy public key content
cat ~/.ssh/id_rsa.pub | ssh -p ${ssh_port} ${ssh_user}@${ssh_ip} "\
mkdir -p ~/.ssh && chmod 700 ~/.ssh && \
touch ~/.ssh/authorized_keys && chmod 775 ~/.ssh/authorized_keys && \
cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
done
View File
Whitespace-only changes.
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
-106
View File
@@ -1,106 +0,0 @@
#!/bin/bash
# front-end Catalog
WebDir=/root/omc.git/fe.ems.vue3
WebBranch=main-v2
# back-end catalog
ApiDir=/root/omc.git/be.ems
ApiBranch=main-v2
# Package Catalog
BuildDir=/root/omc.git/build.ems
BuildBranch=main-v2
BuildTmpDir=/root/omc.git/build.ems/tmp
# Default Version Value
VERSION="2.2508.1"
# usage
usage() {
echo "Usage: bash $0 [OPTION]"
echo
echo "Build Software Package OPTION:"
echo " -v Specify the version"
echo " -webBranch Web Branch ($WebBranch)"
echo " -apiBranch Api Branch ($ApiBranch)"
echo " -h Display this help message"
echo
exit 1
}
# Read command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-v) VERSION="$2"; shift 2 ;;
-webBranch) WebBranch="$2"; shift 2 ;;
-apiBranch) ApiBranch="$2"; shift 2 ;;
*) usage ;;
esac
done
# =================== build branch
echo
cd $BuildDir
git checkout .
git pull
git checkout $BuildBranch
git pull
# clear tmp dir
rm -rf ${BuildTmpDir} && mkdir -p ${BuildTmpDir}
echo "===> build checkout directory: $BuildDir"
# =================== Web
echo
cd $WebDir
git checkout .
git pull
git checkout $WebBranch
git pull
# cp -rf $WebDir $BuildTmpDir/omc_web
mkdir -p $BuildTmpDir/omc_web
cp -rf $WebDir/src $BuildTmpDir/omc_web
cp -rf $WebDir/public $BuildTmpDir/omc_web
cp -rf $WebDir/index.html $BuildTmpDir/omc_web
cp -rf $WebDir/.env.production $BuildTmpDir/omc_web
cp -rf $WebDir/.env.development $BuildTmpDir/omc_web
cp -rf $WebDir/package.json $BuildTmpDir/omc_web
cp -rf $WebDir/tsconfig.json $BuildTmpDir/omc_web
cp -rf $WebDir/tsconfig.node.json $BuildTmpDir/omc_web
cp -rf $WebDir/vite.config.ts $BuildTmpDir/omc_web
echo "===> web source code to $BuildTmpDir/omc_web"
# =================== Api
echo
cd $ApiDir
git checkout .
git pull
git checkout $ApiBranch
git pull
# cp -rf $ApiDir $BuildTmpDir/omc_api
mkdir -p $BuildTmpDir/omc_api
cp -rf $ApiDir/features $BuildTmpDir/omc_api
cp -rf $ApiDir/lib $BuildTmpDir/omc_api
cp -rf $ApiDir/src $BuildTmpDir/omc_api
cp -rf $ApiDir/swagger_docs $BuildTmpDir/omc_api
cp -rf $ApiDir/go.sum $BuildTmpDir/omc_api
cp -rf $ApiDir/go.mod $BuildTmpDir/omc_api
cp -rf $ApiDir/main.go $BuildTmpDir/omc_api
echo "===> omc source code to $BuildTmpDir/omc_api"
# Vendor Database
output=$BuildDir/linux/usr/local/etc/omc
dirs="database default vendor"
for v in ${dirs}; do
rm -rf ${output}/${v}
cp -rf ${ApiDir}/build/${v} ${output}/${v}
done
echo
echo "===> vendor data copy to $output"
# =================== build docker image
echo
# bash $BuildDir/build-docker.sh -v $VERSION -p amd64 -s ubuntu22.04
bash $BuildDir/build-docker.sh -v $VERSION -p amd64 -s alpine3.20
# Compile the front-end and back-end and then package the version
# bash pkg-docker.sh -v 2.2505.2
-116
View File
@@ -1,116 +0,0 @@
#!/bin/bash
# front-end Catalog
WebDir=/root/omc.git/fe.ems.vue3
WebBranch=main-v2
BuildWeb=""
# back-end catalog
ApiDir=/root/omc.git/be.ems
ApiBranch=main-v2
BuildApi=""
# Package Catalog
BuildDir=/root/omc.git/build.ems
BuildBranch=main-v2
# Default Version Value
VERSION="2.2508.1"
# usage
usage() {
echo "Usage: bash $0 [OPTION]"
echo
echo "Build Software Package OPTION:"
echo " -v Specify the version"
echo " --web Build Web ($WebDir)"
echo " --api Build Api ($ApiDir)"
echo " -h Display this help message"
echo
exit 1
}
# Read command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-v) VERSION="$2"; shift 2 ;;
--web) BuildWeb="build"; shift ;;
--api) BuildApi="build"; shift ;;
*) usage ;;
esac
done
# =================== build branch
echo
cd $BuildDir
git checkout .
git pull
git checkout $BuildBranch
git pull
# =================== Web
echo
# Determine if --web is passed in
if [ -n "$BuildWeb" ]; then
cd $WebDir
git checkout .
git pull
git checkout $WebBranch
git pull
# RemoveChinese
rm -rf ./public/alarmHelp/zh
rm -rf ./public/nbStateImput/zh.xlsx
find ./public -type f \( -name "*.js" -o -name "*.json" \) -exec sed -i 's/[一-龥、,。?!“”()【】·]//g' {} +
find ./src -type f \( -name "*.ts" -o -name "*.vue" -o -name "*.js" -o -name "*.json" \) -exec sed -i 's/[一-龥、,。?!“”()【】·]//g' {} +
npm install --registry https://registry.npmmirror.com
npm run build
output=$BuildDir/linux/usr/local/etc/omc/web
rm -rf $output && cp -rf dist $output
echo "===> web build dist copy to $output"
fi
# =================== Api
echo
# Determine if --api is passed in
if [ -n "$BuildApi" ]; then
cd $ApiDir
git checkout .
git pull
git checkout $ApiBranch
git pull
# RemoveChinese
find ./build/database -type f -name '*.sql' -exec sed -i 's/[一-龥、,。?!“”()【】·]//g' {} +
find ./features -type f -name '*.go' -exec sed -i 's/[一-龥、,。?!“”()【】·]//g' {} +
find ./lib -type f -name '*.go' -exec sed -i 's/[一-龥、,。?!“”()【】·]//g' {} +
find ./src -type f -name '*.go' -exec sed -i 's/[一-龥、,。?!“”()【】·]//g' {} +
find ./build/vendor -type f -name '*.sql' -exec sed -i 's/[一-龥、,。?!“”()【】·]//g' {} +
find ./build/vendor -type f -name '*.sql' -exec sed -i "s/'true' WHERE \`config_id\`/'false' WHERE \`config_id\`/g" {} +
find ./build/vendor -type f -name '*.sql' -exec sed -i "s/'1' WHERE \`menu_id\`/'0' WHERE \`menu_id\`/g" {} +
find ./build/vendor -type f -name 'zh_*' -exec rm -f {} \;
MOD_CONFIG="be.ems/src/framework/config"
go build -o omc -v -ldflags "-s -w -X '$MOD_CONFIG.Version=$VERSION' -X '$MOD_CONFIG.BuildTime=$(date)' -X '$MOD_CONFIG.GoVer=$(go version)'"
output=$BuildDir/linux/usr/local/bin
cp -rf omc $output/omc
echo "===> go build omc copy to $output"
# Vendor Database
output=$BuildDir/linux/usr/local/etc/omc
dirs="database default vendor"
for v in ${dirs}; do
rm -rf ${output}/${v}
cp -rf ${ApiDir}/build/${v} ${output}/${v}
done
echo
echo "===> vendor data copy to $output"
fi
# =================== deb/rpm
echo
bash $BuildDir/build.sh -v $VERSION
# Compile the front-end and back-end and then package the version
# bash pkg-remove-chinese.sh --web --api -v 2.2503.2
# Packaged version of just the last compiled file/build directory
# bash pkg-remove-chinese.sh -v 2.2503.2
-105
View File
@@ -1,105 +0,0 @@
#!/bin/bash
# front-end Catalog
WebDir=/root/omc.git/fe.ems.vue3
WebBranch=main-v2
BuildWeb=""
# back-end Catalog
ApiDir=/root/omc.git/be.ems
ApiBranch=main-v2
BuildApi=""
# Package Catalog
BuildDir=/root/omc.git/build.ems
BuildBranch=main-v2
# Default Version Value
VERSION="2.2508.1"
# usage
usage() {
echo "Usage: bash $0 [OPTION]"
echo
echo "Build Software Package OPTION:"
echo " -v Specify the version"
echo " --web Build Web ($WebDir) Branch ($WebBranch)"
echo " --api Build Api ($ApiDir) Branch ($ApiBranch)"
echo " -h Display this help message"
echo
exit 1
}
# Read command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-v) VERSION="$2"; shift 2 ;;
--web) BuildWeb="build"; shift ;;
--api) BuildApi="build"; shift ;;
*) usage ;;
esac
done
# =================== build branch
echo
cd $BuildDir
git checkout .
git pull
git checkout $BuildBranch
git pull
echo "===> build checkout directory: $BuildDir"
# =================== Web
echo
# Determine if --web is passed in
if [ -n "$BuildWeb" ]; then
cd $WebDir
git checkout .
git pull
git checkout $WebBranch
git pull
# remote replication
#scpDir=/root/omc.git/fe.ems.vue3
#scp -r -P 18422 root@192.168.9.58:$scpDir/dist $WebDir/
# local compilation
npm install --registry https://registry.npmmirror.com
npm run build
output=$BuildDir/linux/usr/local/etc/omc/web
rm -rf $output && cp -rf dist $output
echo "===> web build dist copy to $output"
fi
# =================== Api
echo
# Determine if --api is passed in
if [ -n "$BuildApi" ]; then
cd $ApiDir
git checkout .
git pull
git checkout $ApiBranch
git pull
MOD_CONFIG="be.ems/src/framework/config"
go build -o omc -v -ldflags "-s -w -X '$MOD_CONFIG.Version=$VERSION' -X '$MOD_CONFIG.BuildTime=$(date)' -X '$MOD_CONFIG.GoVer=$(go version)'"
output=$BuildDir/linux/usr/local/bin
cp -rf omc $output/omc
echo "===> go build omc copy to $output"
# Vendor Database
output=$BuildDir/linux/usr/local/etc/omc
dirs="database default vendor"
for v in ${dirs}; do
rm -rf ${output}/${v}
cp -rf ${ApiDir}/build/${v} ${output}/${v}
done
echo
echo "===> vendor data copy to $output"
fi
# =================== deb/rpm
echo
bash $BuildDir/build.sh -v $VERSION
# Compile the front-end and back-end and then package the version
# bash pkg.sh --web --api -v 2.2503.2
# Packaged version of just the last compiled file/build directory
# bash pkg.sh -v 2.2503.2
-8
View File
@@ -1,8 +0,0 @@
Package: OMC
Version: {version}-{date}
Section: OMC-Team
Prioritt: optional
Architecture: {arch}
Maintainer: OMC-Team
Depends:
Description: OMC for 4G/5G Core Network Software
-60
View File
@@ -1,60 +0,0 @@
# !/bin/bash
# Execute the script after installation
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 ""
# 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
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 ""
-21
View File
@@ -1,21 +0,0 @@
# !/bin/bash
# Execute the script after uninstallation
case "$1" in
remove)
# Uninstallation operations
# Deletion of service files
systemctl daemon-reload
systemctl disable omc.service
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
;;
upgrade)
# Update Operation
;;
esac
-4
View File
@@ -1,4 +0,0 @@
# !/bin/bash
# Execute the script before installation
rm -rf /usr/local/etc/omc/default
-6
View File
@@ -1,6 +0,0 @@
# !/bin/bash
# Execute the script before uninstalling
# Stop Service
systemctl daemon-reload
systemctl stop omc.service
-79
View File
@@ -1,79 +0,0 @@
## 第一阶段 ====> Nodejs打包编译输出前端资源
FROM node:20-alpine AS build-node
# 系统文件
COPY ./linux /linux
# 后端程序
COPY ./omc_api /api
# 前端程序
COPY ./omc_web /web
RUN npm config set registry https://registry.npmmirror.com
RUN cd /web && npm install && npm run build
## 第二阶段 ====> Go打包编译输出后端程序
FROM golang:1.24-alpine AS build-golang
ARG TARGETARCH
ARG VERSION
# 从上个阶段复制文件
COPY --from=build-node /web/dist /web
COPY --from=build-node /api /api
COPY --from=build-node /linux /linux
# 设置变量
ARG VERSION
ENV CGO_ENABLED 1
ENV GOOS linux
ENV GOPROXY https://goproxy.cn,direct
# 更新apt并安装必要工具
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add gcc musl-dev libpcap-dev && rm -rf /var/cache/apk/*
RUN cd /api && go mod download
RUN cd /api && go build -o omc -v -ldflags "-s -w \
-X 'be.ems/src/framework/config.Version=$VERSION' \
-X 'be.ems/src/framework/config.BuildTime=$(date)' \
-X 'be.ems/src/framework/config.GoVer=$(go version)'"
## 第三阶段 ====> 构建前后端融合镜像
FROM alpine:3.20
# 从上个阶段复制文件
COPY --from=build-golang /linux/usr/local/etc/omc /usr/local/etc/omc
COPY --from=build-golang /linux/usr/local/omc /usr/local/omc
COPY --from=build-golang /api/omc /usr/local/bin/omc
COPY --from=build-golang /web /usr/local/etc/omc/web
# 更新apt并安装必要工具
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add musl-dev libpcap-dev bash nginx tzdata && rm -rf /var/cache/apk/*
# 设置时区和语言环境
ENV LANG="en_US.UTF-8"
ENV TZ="Asia/Shanghai"
WORKDIR /usr/local/etc/omc
RUN chmod +x /usr/local/etc/omc/script/*.sh
RUN /usr/local/etc/omc/script/postunpack.sh
EXPOSE 80 443 33030 33443 33033 33034 33060
CMD [ "/usr/local/etc/omc/script/entrypoint.sh" ]
# build 448MB
# docker docker build --platform linux/amd64 --build-arg TARGETARCH=amd64 --build-arg VERSION=2.2505.2 -t omc:2.2505.2-alpine3.20-amd64 .
# docker run --network omcnet -it omc:2.2505.2-alpine3.20-amd64 /bin/bash
# docker run --privileged=true --restart=always -m 512M \
# -e TZ=Asia/Shanghai \
# -e M_PARAM=lite \
# -p 80:80 \
# -p 443:443 \
# --network omcnet \
# --name omc \
# -d omc:2.2505.2-alpine3.20-amd64
-85
View File
@@ -1,85 +0,0 @@
## 第一阶段 ====> Nodejs打包编译输出前端资源
FROM node:20-alpine AS build-node
# 系统文件
COPY ./linux /linux
# 后端程序
COPY ./omc_api /api
# 前端程序
COPY ./omc_web /web
RUN npm config set registry https://registry.npmmirror.com
RUN cd /web && npm install && npm run build
## 第二阶段 ====> Go打包编译输出后端程序
FROM ubuntu:22.04 AS build-golang
ARG TARGETARCH
ARG VERSION
# 从上个阶段复制文件
COPY --from=build-node /web/dist /web
COPY --from=build-node /api /api
COPY --from=build-node /linux /linux
# 安装 Go 和其他依赖
RUN apt-get update && \
apt-get install -y build-essential libpcap-dev curl \
&& curl -OL https://dl.google.com/go/go1.24.2.linux-$TARGETARCH.tar.gz \
&& tar -C /usr/local -xzf go1.24.2.linux-$TARGETARCH.tar.gz \
&& rm go1.24.2.linux-$TARGETARCH.tar.gz \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 设置变量
ENV PATH="/usr/local/go/bin:${PATH}"
ENV OS_ARCH="${TARGETARCH:-amd64}"
ENV CGO_ENABLED=1
ENV GOOS=linux
ENV GOPROXY=https://goproxy.cn,direct
RUN cd /api && go mod download
RUN cd /api && go build -o omc -v -ldflags "-s -w \
-X 'be.ems/src/framework/config.Version=$VERSION' \
-X 'be.ems/src/framework/config.BuildTime=$(date)' \
-X 'be.ems/src/framework/config.GoVer=$(go version)'"
## 第三阶段 ====> 构建前后端融合镜像
FROM ubuntu:22.04
# 从上个阶段复制文件
COPY --from=build-golang /linux/usr/local/etc/omc /usr/local/etc/omc
COPY --from=build-golang /linux/usr/local/omc /usr/local/omc
COPY --from=build-golang /api/omc /usr/local/bin/omc
COPY --from=build-golang /web /usr/local/etc/omc/web
# 更新apt并安装必要工具
RUN apt-get update && apt-get install -y libpcap-dev nginx
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
RUN apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives
# 设置时区和语言环境
ENV LANG="en_US.UTF-8"
ENV TZ="Asia/Shanghai"
WORKDIR /usr/local/etc/omc
RUN chmod +x /usr/local/etc/omc/script/*.sh
RUN /usr/local/etc/omc/script/postunpack.sh
EXPOSE 80 443 33030 33443 33033 33034 33060
CMD [ "/usr/local/etc/omc/script/entrypoint.sh" ]
# build 707MB
# docker docker build --platform linux/amd64 --build-arg TARGETARCH=amd64 --build-arg VERSION=2.2505.2 -t omc:2.2505.2-ubuntu22.04-amd64 .
# docker run --network omcnet -it omc:2.2505.2-ubuntu22.04-amd64 /bin/bash
# docker run --privileged=true --restart=always -m 512M \
# -e TZ=Asia/Shanghai \
# -e M_PARAM=lite \
# -p 80:80 \
# -p 443:443 \
# --network omcnet \
# --name omc \
# -d omc:2.2505.2-ubuntu22.04-amd64
-49
View File
@@ -1,49 +0,0 @@
# Docker 编译
内部文件资源
| 路径 | 说明 |
| --------------------------- | -------------------------- |
| /usr/local/omc/static | 网管静态资源文件路径 |
| /usr/local/omc/upload | 网管上传文件资源路径 |
| /usr/local/etc/omc/omc.yaml | 网管配置文件 |
| /etc/nginx/nginx.conf | nginx 配置 |
| /etc/nginx/conf.d/omc.conf | 网管前端 nginx 代理配置 |
| /var/log | 网管相关日志输出 |
| /tmp/omc | 存放从网元拉取到本地的文件 |
端口声明
| 端口 | 说明 |
| ----- | ----------------------------- |
| 80 | 网管 Nginx HTTP 服务 |
| 443 | 网管 Nginx HTTP2 服务 |
| 33030 | 网管后台 API HTTP 服务 |
| 33443 | 网管后台 API HTTP2 服务 |
| 33033 | 网管信令跟踪 UDP 协议接收服务 |
| 33060 | 网管性能分析监控 metrics 服务 |
容器变量
| 属性 | 说明 |
| ------- | ------------------------------------------------------------------------- |
| M_PARAM | 服务模式(std、lite) std:d 标准版需外接 mariadb lite:轻量版内置 sqlite |
| C_PARAM | 相关厂商定制 |
## 镜像导出导入
```sh
docker save bitnami/keydb:6.3.4 -o keydb_6.3.4.tar
docker save mariadb:10.6.21 -o mariadb_10.6.21.tar
docker save omc:xx -o omc_xx.tar
docker load -i keydb_6.3.4.tar
docker load -i mariadb_10.6.21.tar
docker load -i omc_xx.tar
sudo bash omc-docker.sh install
tar -czvf omc-r2.2505.2-docker-alpine3.20-amd64.tar.gz omc-r2.2505.2-docker-alpine3.20-amd64/
tar -xzvf omc-r2.2505.2-docker-alpine3.20-amd64.tar.gz
```
@@ -1,34 +0,0 @@
#!/bin/bash
# shellcheck disable=SC1091
set -o errexit
set -o nounset
set -o pipefail
# set -o xtrace # Uncomment this line for debugging purposes
# Load OMC environment variables
. /usr/local/etc/omc/script/omc-env.sh
# We add the copy from default config in the entrypoint to not break users
# case someone mounts a configuration file in /usr/local/etc/omc/default)
cp -n $BASE_DIR/default/omc.conf $BASE_DIR/omc.conf
cp -n $BASE_DIR/default/omc.yaml $BASE_DIR/omc.yaml
# Initialize OMC DB
if [ ! -f /usr/local/etc/omc/machine.ini ]; then
bash /usr/local/etc/omc/script/setup.sh -i -r -m $M_PARAM -c $C_PARAM
fi
# Start Nginx server | -s stop
nginx
# Parse CLI flags to pass to the 'omc' call
args=("--config" "${BASE_DIR}/omc.yaml")
# Add flags specified via the 'CMD_EXTRA_FLAGS' environment variable
read -r -a extra_flags <<< "$CMD_EXTRA_FLAGS"
[[ "${#extra_flags[@]}" -gt 0 ]] && args+=("${extra_flags[@]}")
# Add flags passed to this script
args+=("$@")
# Run omc
omc "${args[@]}"
@@ -1,15 +0,0 @@
# Paths
export BASE_DIR="/usr/local/etc/omc"
export DATA_DIR="/usr/local/omc"
# OMC settings
export M_PARAM="${M_PARAM:-std}"
export C_PARAM="${C_PARAM:-omc}"
# OMC Config settings
export API_HTTP_PORT="${API_HTTP_PORT:-33030}"
export API_HTTPS_PORT="${API_HTTPS_PORT:-33443}"
export WEB_HTTP_PORT="${WEB_HTTP_PORT:-80}"
export WEB_HTTPS_PORT="${WEB_HTTPS_PORT:-443}"
export CMD_EXTRA_FLAGS=""
@@ -1,43 +0,0 @@
#!/bin/bash
# shellcheck disable=SC1091
set -o errexit
set -o nounset
set -o pipefail
# set -o xtrace # Uncomment this line for debugging purposes
# Load OMC environment variables
. /usr/local/etc/omc/script/omc-env.sh
chmod -R g+rwX "$BASE_DIR" "$DATA_DIR"
chmod +rx /usr/local/bin/omc
# We add the copy from default config in the entrypoint to not break users
# bypassing the setup.sh logic. If the file already exists do not overwrite (in
# case someone mounts a configuration file in /usr/local/etc/omc/default)
cp $BASE_DIR/default/omc.conf $BASE_DIR/omc.conf
cp $BASE_DIR/default/omc.yaml $BASE_DIR/omc.yaml
# OMC config
sed -i "s/addr: "0.0.0.0:33030" # route http port/addr: "0.0.0.0:$API_HTTP_PORT" # route http port/" "$BASE_DIR"/omc.yaml
sed -i "s/addr: "0.0.0.0:33443" # route https port/addr: "0.0.0.0:$API_HTTPS_PORT" # route https port/" "$BASE_DIR"/omc.yaml
sed -i 's/enabled: true # web server enabled/enabled: false # web server enabled/' "$BASE_DIR"/omc.yaml
sed -i 's/host: "127.0.0.1" # mysql host$/host: "omc_mariadb" # mysql host/' "$BASE_DIR"/omc.yaml
sed -i 's/port: 33066 # mysql port$/port: 3306 # mysql port/' "$BASE_DIR"/omc.yaml
sed -i 's/host: "127.0.0.1" # redis host$/host: "omc_keydb" # redis host/' "$BASE_DIR"/omc.yaml
# Nginx config
sed -i 's/#gzip on;/gzip on;/' /etc/nginx/nginx.conf
sed -i '/^include \/etc\/nginx\/conf.d/s/^/# /' /etc/nginx/nginx.conf
sed -i 's/include \/etc\/nginx\/http.d/include \/etc\/nginx\/conf.d/' /etc/nginx/nginx.conf
sed -i 's/# gzip_/gzip_/' /etc/nginx/nginx.conf
sed -i 's/include \/etc\/nginx\/sites-enabled/# include \/etc\/nginx\/sites-enabled/' /etc/nginx/nginx.conf
rm -rf /etc/nginx/conf.d && mkdir -p /etc/nginx/conf.d
cp -rf /usr/local/etc/omc/nginx/omc.conf /etc/nginx/conf.d
touch /usr/local/etc/omc/web/config.js && echo 'sessionStorage.clear()' | tee /usr/local/etc/omc/web/config.js
sed -i "s/33030;/$API_HTTP_PORT;/" /etc/nginx/conf.d/omc.conf
sed -i "s/33443;/$API_HTTPS_PORT;/" /etc/nginx/conf.d/omc.conf
sed -i "s/80;/$WEB_HTTP_PORT;/" /etc/nginx/conf.d/omc.conf
sed -i "s/443;/$WEB_HTTPS_PORT;/" /etc/nginx/conf.d/omc.conf
-143
View File
@@ -1,143 +0,0 @@
#!/bin/bash
OMC_CONTAINER_NAME="omc"
MYSQL_CONTAINER_NAME="omc_mariadb"
REDIS_CONTAINER_NAME="omc_keydb"
# usage
usage() {
echo "Usage: bash omc-docker.sh [install|uninstall|restart|start|stop]"
exit 1
}
# install
install(){
echo "====================== Install container omc service ====================="
echo "Install mysql and redis service program, default N (Y/N):"
read DB_SERVICE
DB_SERVICE=${DB_SERVICE:-"N"}
echo "Select the image in the tar directory (omc_{version}-{system}-{arch}.tar):"
read OMC_FILE
OMC_FILE=${OMC_FILE:-"omc_{version}-{system}-{arch}.tar"}
echo "Container time zone (Asia/Shanghai):"
read OMC_TZ
OMC_TZ=${OMC_TZ:-"Asia/Shanghai"}
echo "Container service http port (80):"
read OMC_HTTP_PORT
OMC_HTTP_PORT=${OMC_HTTP_PORT:-"80"}
echo "Container service https port (443):"
read OMC_HTTPS_PORT
OMC_HTTPS_PORT=${OMC_HTTPS_PORT:-"443"}
echo "Container name ($OMC_CONTAINER_NAME):"
read OMC_CONTAINER_NAME
OMC_CONTAINER_NAME=${OMC_CONTAINER_NAME:-"omc"}
sed -i "s/^OMC_CONTAINER_NAME=.*/OMC_CONTAINER_NAME=\"$OMC_CONTAINER_NAME\"/" ./omc-docker.sh
echo "===================== Start ====================="
echo "==> Checking Docker version"
if sudo docker -v > /dev/null 2>&1; then
sudo docker -v
else
echo "Docker is not available or sudo privileges are not granted."
exit 1
fi
echo "==> Created service network"
NETWORK="omcnet"
if ! docker network ls --filter name=$NETWORK -q | grep -q .; then
docker network create $NETWORK
echo "Network '$NETWORK' created."
else
echo "Network '$NETWORK' already exists."
fi
echo "==> Install service mysql and redis container"
if [[ "$DB_SERVICE" =~ ^[Yy]$ ]]; then
# MySQL Config
mysql_container=$(docker ps --filter "name=$MYSQL_CONTAINER_NAME" --format "{{.Names}}")
if [[ -z "$mysql_container" ]]; then
echo "MySQL container is not running. Installing MySQL container..."
docker load --input $(pwd)/tar/mariadb_10.6.21_{arch}.tar
MYSQL_IMAGE="mariadb-{arch}:10.6.21"
MYSQL_ROOT_PASSWORD="1000omc@kp!"
MYSQL_DATA=/usr/local/etc/$MYSQL_CONTAINER_NAME/data
mkdir -p $MYSQL_DATA && chmod 777 $MYSQL_DATA
docker run --privileged=true --restart=always -e TZ="$OMC_TZ" \
-e MARIADB_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD \
-e MARIADB_DATABASE=omc_db \
-v $MYSQL_DATA:/var/lib/mysql \
--network $NETWORK \
--name $MYSQL_CONTAINER_NAME \
-d $MYSQL_IMAGE
else
echo "MySQL container is already running: $mysql_container"
fi
# Redis Config
redis_container=$(docker ps --filter "name=$REDIS_CONTAINER_NAME" --format "{{.Names}}")
if [[ -z "$redis_container" ]]; then
echo "Redis container is not running. Installing Redis container..."
docker load --input $(pwd)/tar/keydb_6.3.4_{arch}.tar
REDIS_IMAGE="keydb-{arch}:6.3.4"
REDIS_PASSWORD="helloearth"
REDIS_DATA=/usr/local/etc/$REDIS_CONTAINER_NAME/data
mkdir -p $REDIS_DATA && chmod 777 $REDIS_DATA
docker run --privileged=true --restart=always -e TZ="$OMC_TZ" \
-e KEYDB_PASSWORD=$REDIS_PASSWORD \
-v $REDIS_DATA:/bitnami/keydb/data \
--network $NETWORK \
--name $REDIS_CONTAINER_NAME \
-d $REDIS_IMAGE
else
echo "Redis container is already running: $redis_container"
fi
else
echo "You chose not to install MySQL and Redis containers."
fi
echo "==> Loading service omc container"
docker load --input $(pwd)/tar/$OMC_FILE
OMC_IMAGE=$(echo "$OMC_FILE" | sed -e 's/_/:/' -e 's/\.tar$//')
docker run --privileged=true --restart=always -m 512M \
-e TZ=$OMC_TZ \
-p $OMC_HTTP_PORT:80 \
-p $OMC_HTTPS_PORT:443 \
--network $NETWORK \
--name $OMC_CONTAINER_NAME \
-d $OMC_IMAGE
echo "Running service $OMC_CONTAINER_NAME container http port $OMC_HTTP_PORT / https port $OMC_HTTPS_PORT"
}
# uninstall
uninstall(){
docker stop $OMC_CONTAINER_NAME && docker rm $OMC_CONTAINER_NAME
docker stop $REDIS_CONTAINER_NAME && docker rm $REDIS_CONTAINER_NAME
docker stop $MYSQL_CONTAINER_NAME && docker rm $MYSQL_CONTAINER_NAME
}
# According to the input parameters, the corresponding method will be selected for execution, and the instructions will be executed without input.
case "$1" in
"install")
install
;;
"uninstall")
uninstall
;;
"restart")
echo "restart container $OMC_CONTAINER_NAME"
docker restart $OMC_CONTAINER_NAME
;;
"start")
echo "start container $OMC_CONTAINER_NAME"
docker start $OMC_CONTAINER_NAME
;;
"stop")
echo "stop container $OMC_CONTAINER_NAME"
docker stop $OMC_CONTAINER_NAME
;;
*)
usage
;;
esac
View File
Whitespace-only changes.
-134
View File
@@ -1,134 +0,0 @@
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
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}.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
-1
View File
@@ -1 +0,0 @@
Building a temporary catalog for losing