编辑文件 cns.sh

This commit is contained in:
cnb.dg2025-08
2025-09-14 08:18:50 +08:00
committed by cnb
parent 980316897c
commit 6a4d5c9536
+41
View File
@@ -117,6 +117,46 @@ InstallInit() {
type curl && download_tool_cmd='curl -L -ko' || download_tool_cmd='wget --no-check-certificate -O'
}
AddAutoStart() {
if [ -n "$rcCommon" ]; then
if /etc/init.d/cns enable; then
echo '已添加开机自启, 如需关闭请执行: /etc/init.d/cns disable'
return
fi
fi
if type systemctl &>/dev/null && [ -z "$(systemctl --failed|grep -q 'Host is down')" ]; then
if systemctl enable cns &>/dev/null; then
echo '已添加开机自启, 如需关闭请执行: systemctl disable cns'
return
fi
fi
if type chkconfig &>/dev/null; then
if chkconfig --add cns &>/dev/null && chkconfig cns on &>/dev/null; then
echo '已添加开机自启, 如需关闭请执行: chkconfig cns off'
return
fi
fi
if [ -d '/etc/rc.d/rc5.d' -a -f '/etc/init.d/cns' ]; then
if ln -s '/etc/init.d/cns' '/etc/rc.d/rc5.d/S99cns'; then
echo '已添加开机自启, 如需关闭请执行: rm -f /etc/rc.d/rc5.d/S99cns'
return
fi
fi
if [ -d '/etc/rc5.d' -a -f '/etc/init.d/cns' ]; then
if ln -s '/etc/init.d/cns' '/etc/rc5.d/S99cns'; then
echo '已添加开机自启, 如需关闭请执行: rm -f /etc/rc5.d/S99cns'
return
fi
fi
if [ -d '/etc/rc.d' -a -f '/etc/init.d/cns' ]; then
if ln -s '/etc/init.d/Acns' '/etc/rc.d/S99cns'; then
echo '已添加开机自启, 如需关闭请执行: rm -f /etc/rc.d/S99cns'
return
fi
fi
echo '没有添加开机自启, 如需开启请手动添加'
}
Install() {
Config
Delete >/dev/null 2>&1
@@ -132,6 +172,7 @@ Install() {
\r cns encrypt password:\033[35G${cns_encrypt_password}
\r cns tls server port:\033[35G${cns_tls_port}
\r`[ -f /etc/init.d/Acns ] && /etc/init.d/Acns usage || \"$cns_install_dir/cns.init\" usage`\033[0m"
\r`AddAutoStart`\033[0m"
}
Uninstall() {