feat: support build deb
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -87,3 +87,9 @@ yarn.lock
|
||||
release/debs/*.deb
|
||||
release/tars/*.tar.gz
|
||||
release/src-tars/*.tar.gz
|
||||
debbuild
|
||||
!debbuild/DEBIAN/control
|
||||
!debbuild/DEBIAN/postinst
|
||||
!debbuild/DEBIAN/preinst
|
||||
!debbuild/DEBIAN/postrm
|
||||
!debbuild/DEBIAN/prerm
|
||||
32
bin/build.sh
32
bin/build.sh
@@ -12,6 +12,12 @@ BuildRootDir=${GitRootDir}/build.wfc
|
||||
WFCWorkDir=/opt/wfc
|
||||
BuildDockerDir=${BuildRootDir}/build/docker
|
||||
ReleseDir=${BuildRootDir}/release
|
||||
SystemdDir=${BuildRootDir}/build/systemd/system
|
||||
|
||||
DebBuildDir=${BuildRootDir}/debbuild
|
||||
DebReleseDir=${ReleseDir}/debs
|
||||
DebSystemdDir=${DebBuildDir}/etc/systemd/system
|
||||
|
||||
TmpDir=${BuildRootDir}/tmp
|
||||
TmpEnvFile=${TmpDir}/.env.tmp
|
||||
|
||||
@@ -58,9 +64,7 @@ pre-build-deb(){
|
||||
if [ ! -d ${ReleseDir}/debs ]; then
|
||||
mkdir -p ${ReleseDir}/debs
|
||||
fi
|
||||
if [ -f ${BuildDockerDir}/.env ]; then
|
||||
mv -f ${BuildDockerDir}/.env ${TmpEnvFile}
|
||||
fi
|
||||
# source ${BuildRootDir}/bin/control.sh
|
||||
}
|
||||
|
||||
build-extras(){
|
||||
@@ -111,6 +115,20 @@ copy-file(){
|
||||
cp -f ${BuildRootDir}/bin/printJarVer.class ${BuildRootDir}/build/bin/
|
||||
}
|
||||
|
||||
copy-file-debbuild(){
|
||||
rm -rf ${DebBuildDir}/opt/wfc/*
|
||||
cp -rf ${BuildRootDir}/build/bin/ ${DebBuildDir}/opt/wfc
|
||||
cp -rf ${BuildRootDir}/build/docker/ ${DebBuildDir}/opt/wfc
|
||||
cp -rf ${BuildRootDir}/build/systemd/ ${DebBuildDir}/opt/wfc
|
||||
if [ -f ${DebBuildDir}/opt/wfc/docker/.env ]; then
|
||||
rm ${DebBuildDir}/opt/wfc/docker/.env
|
||||
fi
|
||||
cp -rf ${SystemdDir}/* ${DebSystemdDir}/
|
||||
chmod 755 ${DebBuildDir}/DEBIAN/preinst
|
||||
chmod 755 ${DebBuildDir}/DEBIAN/postinst
|
||||
chmod 755 ${DebBuildDir}/DEBIAN/postrm
|
||||
}
|
||||
|
||||
# create tar package
|
||||
create-tar(){
|
||||
TarFileName=${ProjectL}-${RelVersion}-${RelDate}.tar.gz
|
||||
@@ -162,7 +180,10 @@ create-src-tar(){
|
||||
|
||||
# create deb package
|
||||
create-deb(){
|
||||
echo -n "Begin build deb package ... "
|
||||
Version=$(grep '^Version:' ${DebBuildDir}/DEBIAN/control | awk '{print $2}')
|
||||
DebPkgFile=${ProjectL}-${Version}-${RelDate}-ub22.deb
|
||||
echo -n "Begin build deb package(${DebPkgFile}) ... "
|
||||
dpkg -b ${DebBuildDir} ${DebReleseDir}/${DebPkgFile} 1>/dev/null
|
||||
echo "done"
|
||||
}
|
||||
|
||||
@@ -201,11 +222,12 @@ case "$1" in
|
||||
if [ "$SKIP_PRE_GIT_PULL" = false ]; then
|
||||
pre-git-pull
|
||||
fi
|
||||
# pre-build-deb
|
||||
pre-build-deb
|
||||
build-extras
|
||||
build-jar
|
||||
build-dist
|
||||
copy-file
|
||||
copy-file-debbuild
|
||||
create-deb
|
||||
# post-build
|
||||
;;
|
||||
|
||||
@@ -31,7 +31,6 @@ conf_dirs=" ${docker_work_dir}/conf
|
||||
${docker_work_dir}/wfc/modules/file/conf
|
||||
${docker_work_dir}/wfc/modules/payment/conf
|
||||
"
|
||||
|
||||
case "$1" in
|
||||
env)
|
||||
# prepare directory
|
||||
@@ -42,9 +41,11 @@ case "$1" in
|
||||
fi
|
||||
|
||||
# setup system serivce
|
||||
cp -rf ${src_service_dir}/wfccontrol.service ${dst_service_dir}/
|
||||
systemctl daemon-reload
|
||||
systemctl enable wfccontrol.service
|
||||
if [ -f ${src_service_dir}/wfccontrol.service ]; then
|
||||
cp -rf ${src_service_dir}/wfccontrol.service ${dst_service_dir}/
|
||||
systemctl daemon-reload
|
||||
systemctl enable wfccontrol.service
|
||||
fi
|
||||
|
||||
if [ ! -f ${docker_work_dir}/docker-compose.yml ]; then
|
||||
cp ${docker_work_dir}/compose/docker-compose.yml ${docker_work_dir}/docker-compose.yml
|
||||
|
||||
@@ -151,7 +151,7 @@ services:
|
||||
- SPRING_CONFIG_ADDITIONAL_LOCATION=optional:classpath:/,optional:file:/opt/wfc/conf/
|
||||
- TZ=${TZ}
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "curl -f http://localhost:${AUTH_SERVER_PORT}/actuator/health || exit 1"]
|
||||
test: ["CMD-SHELL", "curl -f http://localhost:${AUTH_SERVER_PORT}/actuator/health || exit 1"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
Package: WFC
|
||||
Version: 1.0.7-YYYYMMDD
|
||||
Version: 1.0.7
|
||||
Section: WFC
|
||||
Prioritt: optional
|
||||
Architecture: amd64
|
||||
Maintainer: wfc
|
||||
Depends:
|
||||
Description: WANFi Controller
|
||||
Description: WANFi Control and Billing System
|
||||
|
||||
|
||||
92
debbuild/DEBIAN/postinst
Normal file → Executable file
92
debbuild/DEBIAN/postinst
Normal file → Executable file
@@ -1,94 +1,14 @@
|
||||
# !/bin/bash
|
||||
|
||||
WFCRootDir=/opt/wfc
|
||||
SystemdRootDir=/usr/lib/systemd/system
|
||||
WFCEtcDir=${WFCRootDir}/etc
|
||||
FERootDir=${WFCRootDir}/nginx/html/dist
|
||||
wfcBinDir=${WFCRootDir}/bin
|
||||
UsrLocalBinDir=/usr/local/bin
|
||||
wfcDaemon=wfcd
|
||||
NginxEtcDir=/etc/nginx
|
||||
NginxConfDir=${NginxEtcDir}/conf.d
|
||||
CFileList="restconf.yaml crontask.yaml tasks.yaml sshsvc.yaml capconf.yaml wfc.conf"
|
||||
LogoFileList="zh_brand.png zh_icon.png en_brand.png en_icon.png"
|
||||
wfc_root_dir=/opt/wfc
|
||||
systemd_dir=/etc/systemd/system
|
||||
fe_dist_dir=${wfc_root_dir}/opt/wfc/docker/nginx/html/dist
|
||||
wfc_bin_dir=${wfc_root_dir}/bin
|
||||
|
||||
echo ""
|
||||
echo "* To start/stop/restart/status wfc service, please run:"
|
||||
echo " sudo systemctl start/stop/restart/status restagent.service"
|
||||
echo " or run: "
|
||||
echo " sudo /usr/local/wfc/bin/wfcsvc.sh start/stop/restart/status"
|
||||
echo ""
|
||||
|
||||
chmod +rx ${WFCRootDir}/bin/*
|
||||
chmod +rx ${WFCRootDir}/*
|
||||
chmod +rx ${UsrLocalBinDir}/*
|
||||
chmod -R 755 ${WFCRootDir}/htdocs/front
|
||||
|
||||
for CFile in ${CFileList}; do
|
||||
if [ ! -e "${WFCEtcDir}/${CFile}" ]; then
|
||||
cp -f ${WFCEtcDir}/default/${CFile} ${WFCEtcDir}
|
||||
else
|
||||
# mv -f ${WFCEtcDir}/${CFile} ${WFCEtcDir}/${CFile}.bak
|
||||
# cp -f ${WFCEtcDir}/default/${CFile} ${WFCEtcDir}
|
||||
if [ -e "${WFCBinDir}/upgconf.sh" ]; then
|
||||
${WFCBinDir}/upgconf.sh
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -e "${FERootDir}/config.js" ]; then
|
||||
cp ${FERootDir}/default/config.js ${FERootDir};
|
||||
fi
|
||||
|
||||
for LogoFile in ${LogoFileList}; do
|
||||
if [ ! -e "${WFCStaticDir}/logo/${LogoFile}" ]; then
|
||||
cp ${WFCStaticDir}/wfc.d/logo/${LogoFile} ${WFCStaticDir}/logo;
|
||||
fi
|
||||
done
|
||||
|
||||
if ! id -u wfc >/dev/null 2>&1 ; then
|
||||
useradd -d /opt/wfc -m -s /bin/bash -pwfc123 wfc;
|
||||
mkdir -p /opt/wfc/ftp
|
||||
else
|
||||
echo "user wfc exist";
|
||||
fi
|
||||
|
||||
if [ ! -e "${NginxConfDir}/wfc.conf" ]; then
|
||||
mkdir -p ${NginxConfDir}
|
||||
cp -f ${WFCEtcDir}/nginx/wfc.conf ${NginxConfDir};
|
||||
fi
|
||||
chmod +rx ${wfc_root_dir}/bin/*
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable wfccontrol.service
|
||||
|
||||
# disable auto upgrade
|
||||
systemctl disable --now unattended-upgrades
|
||||
|
||||
systemctl enable restagent.service
|
||||
systemctl enable crontask.service
|
||||
systemctl enable sshsvc.service
|
||||
systemctl enable captrace.service
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
# read environment parameter and to do
|
||||
if [ "$M_PARAM" = "install" -o "$M_PARAM" = "upgrade" ]; then
|
||||
echo "M parameter: $M_PARAM"
|
||||
if [ -n "$C_PARAM" ]; then
|
||||
echo "C parameter: $C_PARAM"
|
||||
${WFCRootDir}/bin/setwfc.sh -m $M_PARAM -c $C_PARAM
|
||||
else
|
||||
${WFCRootDir}/bin/setwfc.sh -m $M_PARAM
|
||||
fi
|
||||
# exit while failed to run setwfc.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "setwfc.sh execution failed. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -n "Starting WFC service ... "
|
||||
systemctl start crontask.service
|
||||
systemctl start sshsvc.service
|
||||
systemctl start captrace.service
|
||||
systemctl start restagent.service
|
||||
echo "done"
|
||||
|
||||
21
debbuild/DEBIAN/postrm
Normal file → Executable file
21
debbuild/DEBIAN/postrm
Normal file → Executable file
@@ -1,23 +1,6 @@
|
||||
# !/bin/bash
|
||||
|
||||
#rm -rf /usr/local/omc
|
||||
rm -rf /etc/nginx/conf.d/omc.conf
|
||||
rm -f /usr/local/bin/omcd
|
||||
|
||||
systemctl daemon-reload
|
||||
# systemctl stop wfccontrol.service
|
||||
systemctl disable wfccontrol.service
|
||||
|
||||
if systemctl list-units --type=service --all | grep -q 'restagent.service'; then
|
||||
echo -n "Stopping OMC service ... "
|
||||
systemctl stop restagent.service
|
||||
systemctl stop crontask.service
|
||||
systemctl stop sshsvc.service
|
||||
systemctl stop captrace.service
|
||||
echo "done"
|
||||
fi
|
||||
|
||||
systemctl disable restagent.service
|
||||
systemctl disable crontask.service
|
||||
systemctl disable sshsvc.service
|
||||
systemctl disable captrace.service
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
16
debbuild/DEBIAN/preinst
Normal file → Executable file
16
debbuild/DEBIAN/preinst
Normal file → Executable file
@@ -1,16 +1,8 @@
|
||||
# !/bin/bash
|
||||
|
||||
systemctl daemon-reload
|
||||
if systemctl list-units --type=service --all | grep -q 'restagent.service'; then
|
||||
echo -n "Stopping WFC service ... "
|
||||
systemctl stop restagent.service
|
||||
echo "done"
|
||||
fi
|
||||
fe_dist_dir=/opt/wfc/docker/nginx/html/dist
|
||||
|
||||
FERootDir=/usr/local/omc/htdocs/front
|
||||
|
||||
# apt-get install zip
|
||||
# clear front-end old hash js files
|
||||
rm -rf ${FERootDir}/assets
|
||||
rm -rf ${FERootDir}/js
|
||||
rm -rf ${FERootDir}/index.*.js
|
||||
rm -rf ${fe_dist_dir}/sys
|
||||
rm -rf ${fe_dist_dir}/u
|
||||
|
||||
|
||||
7
debbuild/DEBIAN/prerm
Executable file
7
debbuild/DEBIAN/prerm
Executable file
@@ -0,0 +1,7 @@
|
||||
# !/bin/bash
|
||||
|
||||
wfc_bin_dir=/opt/wfc/bin
|
||||
|
||||
${wfc_bin_dir}/wfccontrol.sh stop
|
||||
${wfc_bin_dir}/wfcsetup.sh rm all
|
||||
|
||||
Reference in New Issue
Block a user