1
0

update package build shell script for adb rename to kvdb

This commit is contained in:
2024-07-09 15:08:29 +08:00
parent 9c95b66d2a
commit 3ed69ebd5f
4 changed files with 93 additions and 65 deletions

View File

@@ -1,15 +1,16 @@
# !/bin/bash # !/bin/bash
RedisRootDir=/usr/local RedisRootDir=/usr/local
OMCRootDir=/usr/local/omc
RedisOldRootDir=/usr/local/db RedisOldRootDir=/usr/local/db
RedisConfDir=${RedisRootDir}/etc/adb RedisConfDir=${RedisRootDir}/etc/kvdb
DependsRootDir=/usr/local/omc/depends DependsRootDir=${OMCRootDir}/depends
SystemdRootDir=/lib/systemd/system SystemdRootDir=/lib/systemd/system
OMCEtcDir=/usr/local/omc/etc OMCEtcDir=${OMCRootDir}/etc
FERootDir=/usr/local/omc/htdocs/front FERootDir=${OMCRootDir}/htdocs/front
X86Lib64Dir=/lib/x86_64-linux-gnu X86Lib64Dir=/lib/x86_64-linux-gnu
OmcBinDir=/usr/local/omc/bin OmcBinDir=${OMCRootDir}/bin
OMCStaticDir=/usr/local/omc/static OMCStaticDir=${OMCRootDir}/static
UsrLocalBinDir=/usr/local/bin UsrLocalBinDir=/usr/local/bin
OmcDaemon=omcd OmcDaemon=omcd
NginxEtcDir=/etc/nginx NginxEtcDir=/etc/nginx
@@ -24,7 +25,7 @@ echo " sudo systemctl start/stop/restart/status restagent.service"
echo " sudo systemctl start/stop/restart/status crontask.service" echo " sudo systemctl start/stop/restart/status crontask.service"
echo " sudo systemctl start/stop/restart/status sshsvc.service" echo " sudo systemctl start/stop/restart/status sshsvc.service"
echo " sudo systemctl start/stop/restart/status captrace.service" echo " sudo systemctl start/stop/restart/status captrace.service"
echo " sudo systemctl start/stop/restart/status adb.service" echo " sudo systemctl start/stop/restart/status kvdb.service"
echo " or run: " echo " or run: "
echo " sudo /usr/local/omc/bin/omcsvc.sh start/stop/restart/status" echo " sudo /usr/local/omc/bin/omcsvc.sh start/stop/restart/status"
echo "" echo ""
@@ -42,10 +43,10 @@ if [ ! -e libwsutil.so ]; then ln -s libwsutil.so.13.1.0 libwsutil.so; fi
cd ${UsrLocalBinDir} cd ${UsrLocalBinDir}
if [ ! -e ${OmcDaemon} ]; then ln -s ${OmcBinDir}/omcsvc.sh ${OmcDaemon}; fi if [ ! -e ${OmcDaemon} ]; then ln -s ${OmcBinDir}/omcsvc.sh ${OmcDaemon}; fi
chmod +rx /usr/local/omc/bin/* chmod +rx ${OMCRootDir}/bin/*
chmod +rx /usr/local/omc/* chmod +rx ${OMCRootDir}/*
chmod +rx /usr/local/bin/* chmod +rx ${UsrLocalBinDir}/*
chmod -R 755 /usr/local/omc/htdocs/front chmod -R 755 ${OMCRootDir}/htdocs/front
for CFile in ${CFileList}; do for CFile in ${CFileList}; do
if [ ! -e "${OMCEtcDir}/${CFile}" ]; then if [ ! -e "${OMCEtcDir}/${CFile}" ]; then
@@ -57,42 +58,54 @@ for CFile in ${CFileList}; do
done done
# Install redis db if not exist /usr/local/db # Install redis db if not exist /usr/local/db
if [ ! -e "${RedisRootDir}/bin/adb-server" ]; then if [ ! -e "${RedisRootDir}/bin/kvdb-server" ]; then
# if [ ! -e "${RedisRootDir}" ]; then # if [ ! -e "${RedisRootDir}" ]; then
# mkdir -p ${RedisRootDir} # mkdir -p ${RedisRootDir}
# fi # fi
# stop old adb service
if [ -e "${RedisOldRootDir}/bin/redis-server" ] && [ -e "${SystemdRootDir}/adb.service" ]; then if [ -e "${RedisOldRootDir}/bin/redis-server" ] && [ -e "${SystemdRootDir}/adb.service" ]; then
systemctl stop adb.service systemctl stop adb.service
systemctl disable adb.service
fi fi
cp -rf ${DependsRootDir}/adb/* / # stop adb service
chmod +rx ${RedisRootDir}/bin/* if [ -e "${UsrLocalBinDir}/adb-server" ] && [ -e "${SystemdRootDir}/adb.service" ]; then
if [ ! -e "${RedisConfDir}/adb.conf" ]; then systemctl stop adb.service
cp ${RedisConfDir}/default/adb.conf ${RedisConfDir} systemctl disable adb.service
fi
cp -rf ${DependsRootDir}/kvdb/* /
chmod +rx ${RedisRootDir}/bin/kvdb*
if [ ! -e "${RedisConfDir}/kvdb.conf" ]; then
cp ${RedisConfDir}/default/kvdb.conf ${RedisConfDir}
fi fi
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/adb.conf sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/kvdb.conf
LINE="masterauth helloearth" LINE="masterauth helloearth"
FILE="${RedisConfDir}/adb.conf" FILE="${RedisConfDir}/kvdb.conf"
# 检查文件中是否存在该行 # 检查文件中是否存在该行
if ! grep -qxF "$LINE" "$FILE"; then if ! grep -qxF "$LINE" "$FILE"; then
# 如果不存在,将其添加到文件末尾 # 如果不存在,将其添加到文件末尾
echo "$LINE" >> "$FILE" echo "$LINE" >> "$FILE"
fi fi
# copy the orangin dump.rdb # copy the old adb dump.rdb
if [ -e "${RedisOldRootDir}/bin/conf/dump.rdb" ]; then if [ -e "${RedisOldRootDir}/bin/conf/dump.rdb" ] && [ ! -e "${RedisRootDir}/etc/kvdb/dump.rdb" ]; then
cp -f ${RedisOldRootDir}/bin/conf/dump.rdb ${RedisConfDir} cp -f ${RedisOldRootDir}/bin/conf/dump.rdb ${RedisRootDir}/etc/kvdb/;
mv -f ${RedisRootDir}/db ${RedisRootDir}/adb.old mv -f ${RedisRootDir}/db ${RedisRootDir}/adb.old
fi
# cp -f ${DependsRootDir}/systemd/adb.service ${SystemdRootDir}
else
if [ ! -e "${RedisConfDir}/adb.conf" ]; then
cp ${RedisConfDir}/default/adb.conf ${RedisConfDir}
fi fi
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/adb.conf # copy the adb dump.rdb
if [ -e "${RedisRootDir}/etc/adb/dump.rdb" ] && [ ! -e "${RedisRootDir}/etc/kvdb/dump.rdb" ]; then
cp -f ${RedisRootDir}/etc/adb/dump.rdb ${RedisRootDir}/etc/kvdb/;
mv -f ${RedisRootDir}/etc/adb ${RedisRootDir}/etc/adb.old
fi
# cp -f ${DependsRootDir}/systemd/kvdb.service ${SystemdRootDir}
else
if [ ! -e "${RedisConfDir}/kvdb.conf" ]; then
cp ${RedisConfDir}/default/kvdb.conf ${RedisConfDir}
fi
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/kvdb.conf
LINE="masterauth helloearth" LINE="masterauth helloearth"
FILE="${RedisConfDir}/adb.conf" FILE="${RedisConfDir}/kvdb.conf"
# 检查文件中是否存在该行 # 检查文件中是否存在该行
if ! grep -qxF "$LINE" "$FILE"; then if ! grep -qxF "$LINE" "$FILE"; then
# 如果不存在,将其添加到文件末尾 # 如果不存在,将其添加到文件末尾
@@ -131,16 +144,16 @@ systemctl enable restagent.service
systemctl enable crontask.service systemctl enable crontask.service
systemctl enable sshsvc.service systemctl enable sshsvc.service
systemctl enable captrace.service systemctl enable captrace.service
systemctl enable adb.service systemctl enable kvdb.service
systemctl daemon-reload systemctl daemon-reload
systemctl stop nginx.service systemctl stop nginx.service
systemctl stop restagent.service systemctl stop restagent.service
systemctl stop crontask.service systemctl stop crontask.service
systemctl stop sshsvc.service systemctl stop sshsvc.service
systemctl stop captrace.service systemctl stop captrace.service
systemctl stop adb.service systemctl stop kvdb.service
systemctl start nginx.service systemctl start nginx.service
systemctl start adb.service systemctl start kvdb.service
systemctl start crontask.service systemctl start crontask.service
systemctl start sshsvc.service systemctl start sshsvc.service
systemctl start captrace.service systemctl start captrace.service

View File

@@ -13,14 +13,15 @@ systemctl stop restagent.service
systemctl stop crontask.service systemctl stop crontask.service
systemctl stop sshsvc.service systemctl stop sshsvc.service
systemctl stop captrace.service systemctl stop captrace.service
systemctl stop adb.service #systemctl stop kvdb.service
#rm -rf /usr/local/omc #rm -rf /usr/local/omc
rm -rf /etc/nginx/conf.d/omc.conf rm -rf /etc/nginx/conf.d/omc.conf
rm -f /usr/local/bin/omcd
systemctl disable restagent.service systemctl disable restagent.service
systemctl disable crontask.service systemctl disable crontask.service
systemctl disable sshsvc.service systemctl disable sshsvc.service
systemctl disable captrace.service systemctl disable captrace.service
systemctl disable adb.service #systemctl disable kvdb.service
systemctl daemon-reload systemctl daemon-reload

View File

@@ -1,15 +1,16 @@
# !/bin/bash # !/bin/bash
RedisRootDir=/usr/local RedisRootDir=/usr/local
OMCRootDir=/usr/local/omc
RedisOldRootDir=/usr/local/db RedisOldRootDir=/usr/local/db
RedisConfDir=${RedisRootDir}/etc/adb RedisConfDir=${RedisRootDir}/etc/kvdb
DependsRootDir=/usr/local/omc/depends DependsRootDir=${OMCRootDir}/depends
SystemdRootDir=/lib/systemd/system SystemdRootDir=/lib/systemd/system
OMCEtcDir=/usr/local/omc/etc OMCEtcDir=${OMCRootDir}/etc
FERootDir=/usr/local/omc/htdocs/front FERootDir=${OMCRootDir}/htdocs/front
X86Lib64Dir=/lib/x86_64-linux-gnu X86Lib64Dir=/lib/x86_64-linux-gnu
OmcBinDir=/usr/local/omc/bin OmcBinDir=${OMCRootDir}/bin
OMCStaticDir=/usr/local/omc/static OMCStaticDir=${OMCRootDir}/static
UsrLocalBinDir=/usr/local/bin UsrLocalBinDir=/usr/local/bin
OmcDaemon=omcd OmcDaemon=omcd
NginxEtcDir=/etc/nginx NginxEtcDir=/etc/nginx
@@ -24,7 +25,7 @@ echo " sudo systemctl start/stop/restart/status restagent.service"
echo " sudo systemctl start/stop/restart/status crontask.service" echo " sudo systemctl start/stop/restart/status crontask.service"
echo " sudo systemctl start/stop/restart/status sshsvc.service" echo " sudo systemctl start/stop/restart/status sshsvc.service"
echo " sudo systemctl start/stop/restart/status captrace.service" echo " sudo systemctl start/stop/restart/status captrace.service"
echo " sudo systemctl start/stop/restart/status adb.service" echo " sudo systemctl start/stop/restart/status kvdb.service"
echo " or run: " echo " or run: "
echo " sudo /usr/local/omc/bin/omcsvc.sh start/stop/restart/status" echo " sudo /usr/local/omc/bin/omcsvc.sh start/stop/restart/status"
echo "" echo ""
@@ -42,10 +43,10 @@ if [ ! -e libwsutil.so ]; then ln -s libwsutil.so.13.1.0 libwsutil.so; fi
cd ${UsrLocalBinDir} cd ${UsrLocalBinDir}
if [ ! -e ${OmcDaemon} ]; then ln -s ${OmcBinDir}/omcsvc.sh ${OmcDaemon}; fi if [ ! -e ${OmcDaemon} ]; then ln -s ${OmcBinDir}/omcsvc.sh ${OmcDaemon}; fi
chmod +rx /usr/local/omc/bin/* chmod +rx ${OMCRootDir}/bin/*
chmod +rx /usr/local/omc/* chmod +rx ${OMCRootDir}/*
chmod +rx /usr/local/bin/* chmod +rx ${UsrLocalBinDir}/*
chmod -R 755 /usr/local/omc/htdocs/front chmod -R 755 ${OMCRootDir}/htdocs/front
for CFile in ${CFileList}; do for CFile in ${CFileList}; do
if [ ! -e "${OMCEtcDir}/${CFile}" ]; then if [ ! -e "${OMCEtcDir}/${CFile}" ]; then
@@ -57,42 +58,54 @@ for CFile in ${CFileList}; do
done done
# Install redis db if not exist /usr/local/db # Install redis db if not exist /usr/local/db
if [ ! -e "${RedisRootDir}/bin/adb-server" ]; then if [ ! -e "${RedisRootDir}/bin/kvdb-server" ]; then
# if [ ! -e "${RedisRootDir}" ]; then # if [ ! -e "${RedisRootDir}" ]; then
# mkdir -p ${RedisRootDir} # mkdir -p ${RedisRootDir}
# fi # fi
# stop old adb service
if [ -e "${RedisOldRootDir}/bin/redis-server" ] && [ -e "${SystemdRootDir}/adb.service" ]; then if [ -e "${RedisOldRootDir}/bin/redis-server" ] && [ -e "${SystemdRootDir}/adb.service" ]; then
systemctl stop adb.service systemctl stop adb.service
systemctl disable adb.service
fi fi
cp -rf ${DependsRootDir}/adb/* / # stop adb service
chmod +rx ${RedisRootDir}/bin/* if [ -e "${UsrLocalBinDir}/adb-server" ] && [ -e "${SystemdRootDir}/adb.service" ]; then
if [ ! -e "${RedisConfDir}/adb.conf" ]; then systemctl stop adb.service
cp ${RedisConfDir}/default/adb.conf ${RedisConfDir}; systemctl disable adb.service
fi
cp -rf ${DependsRootDir}/kvdb/* /
chmod +rx ${RedisRootDir}/bin/kvdb*
if [ ! -e "${RedisConfDir}/kvdb.conf" ]; then
cp ${RedisConfDir}/default/kvdb.conf ${RedisConfDir};
fi fi
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/adb.conf sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/kvdb.conf
LINE="masterauth helloearth" LINE="masterauth helloearth"
FILE="${RedisConfDir}/adb.conf" FILE="${RedisConfDir}/kvdb.conf"
# 检查文件中是否存在该行 # 检查文件中是否存在该行
if ! grep -qxF "$LINE" "$FILE"; then if ! grep -qxF "$LINE" "$FILE"; then
# 如果不存在,将其添加到文件末尾 # 如果不存在,将其添加到文件末尾
echo "$LINE" >> "$FILE" echo "$LINE" >> "$FILE"
fi fi
# copy the orangin dump.rdb # copy the old adb dump.rdb
if [ -e "${RedisOldRootDir}/bin/conf/dump.rdb" ]; then if [ -e "${RedisOldRootDir}/bin/conf/dump.rdb" ] && [ ! -e "${RedisConfDir}/dump.rdb" ]; then
cp -f ${RedisOldRootDir}/bin/conf/dump.rdb ${RedisConfDir}; cp -f ${RedisOldRootDir}/bin/conf/dump.rdb ${RedisConfDir};
mv -f ${RedisRootDir}/db ${RedisRootDir}/adb.old mv -f ${RedisRootDir}/db ${RedisRootDir}/adb.old
fi
# cp -f ${DependsRootDir}/systemd/adb.service ${SystemdRootDir}
else
if [ ! -e "${RedisConfDir}/adb.conf" ]; then
cp ${RedisConfDir}/default/adb.conf ${RedisConfDir}
fi fi
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/adb.conf # copy the adb dump.rdb
if [ -e "${RedisRootDir}/etc/adb/dump.rdb" ] && [ ! -e "${RedisRootDir}/etc/kvdb/dump.rdb" ]; then
cp -f ${RedisRootDir}/etc/adb/dump.rdb ${RedisRootDir}/etc/kvdb/;
mv -f ${RedisRootDir}/etc/adb ${RedisRootDir}/etc/adb.old
fi
# cp -f ${DependsRootDir}/systemd/kvdb.service ${SystemdRootDir}
else
if [ ! -e "${RedisConfDir}/kvdb.conf" ]; then
cp ${RedisConfDir}/default/kvdb.conf ${RedisConfDir}
fi
sed -i 's/replica-read-only yes/replica-read-only no/g' ${RedisConfDir}/kvdb.conf
LINE="masterauth helloearth" LINE="masterauth helloearth"
FILE="${RedisConfDir}/adb.conf" FILE="${RedisConfDir}/kvdb.conf"
# 检查文件中是否存在该行 # 检查文件中是否存在该行
if ! grep -qxF "$LINE" "$FILE"; then if ! grep -qxF "$LINE" "$FILE"; then
# 如果不存在,将其添加到文件末尾 # 如果不存在,将其添加到文件末尾
@@ -131,16 +144,16 @@ systemctl enable restagent.service
systemctl enable crontask.service systemctl enable crontask.service
systemctl enable sshsvc.service systemctl enable sshsvc.service
systemctl enable captrace.service systemctl enable captrace.service
systemctl enable adb.service systemctl enable kvdb.service
systemctl daemon-reload systemctl daemon-reload
systemctl stop nginx.service systemctl stop nginx.service
systemctl stop restagent.service systemctl stop restagent.service
systemctl stop crontask.service systemctl stop crontask.service
systemctl stop sshsvc.service systemctl stop sshsvc.service
systemctl stop captrace.service systemctl stop captrace.service
systemctl stop adb.service systemctl stop kvdb.service
systemctl start nginx.service systemctl start nginx.service
systemctl start adb.service systemctl start kvdb.service
systemctl start crontask.service systemctl start crontask.service
systemctl start sshsvc.service systemctl start sshsvc.service
systemctl start captrace.service systemctl start captrace.service

View File

@@ -13,14 +13,15 @@ systemctl stop restagent.service
systemctl stop crontask.service systemctl stop crontask.service
systemctl stop sshsvc.service systemctl stop sshsvc.service
systemctl stop captrace.service systemctl stop captrace.service
systemctl stop adb.service #systemctl stop kvdb.service
#rm -rf /usr/local/omc #rm -rf /usr/local/omc
rm -rf /etc/nginx/conf.d/omc.conf rm -rf /etc/nginx/conf.d/omc.conf
rm -f /usr/local/bin/omcd
systemctl disable restagent.service systemctl disable restagent.service
systemctl disable crontask.service systemctl disable crontask.service
systemctl disable sshsvc.service systemctl disable sshsvc.service
systemctl disable captrace.service systemctl disable captrace.service
systemctl disable adb.service #systemctl disable kvdb.service
systemctl daemon-reload systemctl daemon-reload