编辑文件 cns.sh

This commit is contained in:
cnb.dg2025-08
2025-09-14 09:39:21 +08:00
committed by cnb
parent e80218aeb5
commit a4f90c0638
+13 -13
View File
@@ -5,7 +5,7 @@
#Stop cns & delete cns files.
Delete() {
systemctl disable cns.service
systemctl disable Acns.service
chkconfig --del cns
/etc/init.d/Acns disable
@@ -13,7 +13,7 @@ Delete() {
"$cns_install_dir"/cns.init stop
rm -rf "$cns_install_dir"
fi
rm -f /etc/init.d/Acns /lib/systemd/system/cns.service /etc/rc.d/rc5.d/S99cns /etc/rc.d/S99cns /etc/rc5.d/S99cns
rm -f /etc/init.d/Acns /lib/systemd/system/Acns.service /etc/rc.d/rc5.d/S99cns /etc/rc.d/S99cns /etc/rc5.d/S99cns
}
#Print error message and exit.
@@ -102,9 +102,9 @@ InstallFiles() {
EOF
chmod -R +rwx "$cns_install_dir" /etc/init.d/Acns
if type systemctl && [ -z "$(systemctl --failed|grep -q 'Host is down')" ]; then
$download_tool_cmd /lib/systemd/system/cns.service https://cnb.cool/dg2025-08/Cax/-/git/raw/main/cns/cns.service || Error "cns.service download failed."
chmod +rwx /lib/systemd/system/cns.service
sed -i "s~\[cns_install_dir\]~$cns_install_dir~g" /lib/systemd/system/cns.service
$download_tool_cmd /lib/systemd/system/Acns.service https://cnb.cool/dg2025-08/Cax/-/git/raw/main/cns/cns.service || Error "Acns.service download failed."
chmod +rwx /lib/systemd/system/Acns.service
sed -i "s~\[cns_install_dir\]~$cns_install_dir~g" /lib/systemd/system/Acns.service
systemctl daemon-reload
fi
}
@@ -134,26 +134,26 @@ AddAutoStart() {
fi
fi
if type chkconfig &>/dev/null; then
if chkconfig --add cns &>/dev/null && chkconfig cns on &>/dev/null; then
echo '已添加开机自启, 如需关闭请执行: chkconfig cns off'
if chkconfig --add Acns &>/dev/null && chkconfig cns on &>/dev/null; then
echo '已添加开机自启, 如需关闭请执行: chkconfig Acns off'
return
fi
fi
if [ -d '/etc/rc.d/rc5.d' -a -f '/etc/init.d/Acns' ]; then
if ln -s '/etc/init.d/Acns' '/etc/rc.d/rc5.d/S99cns'; then
echo '已添加开机自启, 如需关闭请执行: rm -f /etc/rc.d/rc5.d/S99cns'
if ln -s '/etc/init.d/Acns' '/etc/rc.d/rc5.d/S99Acns'; then
echo '已添加开机自启, 如需关闭请执行: rm -f /etc/rc.d/rc5.d/S99Acns'
return
fi
fi
if [ -d '/etc/rc5.d' -a -f '/etc/init.d/Acns' ]; then
if ln -s '/etc/init.d/Acns' '/etc/rc5.d/S99cns'; then
echo '已添加开机自启, 如需关闭请执行: rm -f /etc/rc5.d/S99cns'
if ln -s '/etc/init.d/Acns' '/etc/rc5.d/S99Acns'; then
echo '已添加开机自启, 如需关闭请执行: rm -f /etc/rc5.d/S99Acns'
return
fi
fi
if [ -d '/etc/rc.d' -a -f '/etc/init.d/Acns' ]; then
if ln -s '/etc/init.d/Acns' '/etc/rc.d/S99cns'; then
echo '已添加开机自启, 如需关闭请执行: rm -f /etc/rc.d/S99cns'
if ln -s '/etc/init.d/Acns' '/etc/rc.d/S99Acns'; then
echo '已添加开机自启, 如需关闭请执行: rm -f /etc/rc.d/S99Acns'
return
fi
fi