#!/bin/bash # front-end Catalog WebDir=/root/omc.git/fe.ems.vue3 WebBranch=multi-tenant BuildWeb="" # back-end Catalog ApiDir=/root/omc.git/be.ems ApiBranch=multi-tenant BuildApi="" # Package Catalog BuildDir=/root/omc.git/build.ems BuildBranch=multi-tenant # 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 rm -rf debbuild/* 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 sed -i "s/VITE_APP_VERSION = .*/VITE_APP_VERSION = \"${VERSION}\"/g" $WebDir/.env.development sed -i "s/VITE_APP_VERSION = .*/VITE_APP_VERSION = \"${VERSION}\"/g" $WebDir/.env.production cp -rf $BuildDir/customized/ba.d/images/background_light.jpg $WebDir/public/background/light.jpg cp -rf $BuildDir/customized/ba.d/images/background_dark.jpg $WebDir/public/background/dark.jpg cp -rf $BuildDir/customized/ba.d/locales/zh-CN.ts $WebDir/src/i18n/locales/zh-CN.ts npm install --registry https://registry.npmmirror.com npm run build echo "===> build web directory: $WebDir" fi # =================== Api echo # Determine if --api is passed in if [ -n "$BuildApi" ]; then cd $ApiDir git checkout . git pull git checkout $ApiBranch git pull ProcList="restagent sshsvc" for procName in $ProcList;do cd $ApiDir/$procName sed -i "s/VERSION = .*/VERSION = ${VERSION}/g" $ApiDir/$procName/makefile echo "Make $procName ..." make done echo "===> build api directory: $ApiDir" fi # =================== ba deb echo cd $BuildDir sed -i "s/VERSION=.*/VERSION=${VERSION}/g" $BuildDir/bin/build.sh sed -i "s/Version: .*/Version: ${VERSION}-YYYYMMDD-mt/g" $BuildDir/debbuild/DEBIAN/control sed -i "s/Version: .*/Version: ${VERSION}-YYYYMMDD-mt/g" $BuildDir/debbuild/22.04/DEBIAN/control sed -i "s/Version: .*/Version: ${VERSION}/g" $BuildDir/rpmbuild/SPECS/omc.spec bash bin/build.sh badeb # bash pkg.sh --web --api -v 2.2508.1 # bash pkg.sh --web --api