cns9.0.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/bash
  2. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
  3. export PATH
  4. clear
  5. printf "\033c"
  6. echo
  7. read -p "请设置cns端口(默认:33445): " cnspost
  8. if [ -z "$cnspost" ];then
  9. cnspost=33445
  10. fi
  11. echo -e "已设置cns端口为:\033[32m "$cnspost"\033[0m"
  12. echo
  13. read -p "请设置cns密码(默认:cns): " cnsmz
  14. if [ -z "$cnsmz" ];then
  15. cnsmz=cns
  16. fi
  17. echo -e "已设置cns密码为:\033[32m "$cnsmz"\033[0m"
  18. echo
  19. read -p "请设置cns路径(默认:/usr/local/cns): " cnswp
  20. if [ -z "$cnswp" ];then
  21. cnswp="/usr/local/cns"
  22. fi
  23. echo -e "已设置cns路径为:\033[32m "$cnswp"\033[0m"
  24. cd /root/
  25. key="cns"
  26. zip="$key.zip"
  27. host="https://jihulab.com/hepingcaizi/sao/-/raw/main/cns9.0.zip"
  28. #卸载
  29. ###############
  30. $cnswp/cns.init stop #停止
  31. systemctl disable cns.service
  32. #完全删除amy进城-这个最好使
  33. kill -s 15 `pgrep cns`
  34. rm -rf /root/CNS /usr/local/cns
  35. rm -rf $cnswp /etc/init.d/cns /usr/lib/systemd/system/cns.service /etc/systemd/system/cns.service /lib/systemd/system/cns.service
  36. ###############
  37. clear
  38. printf "\033c"
  39. sleep 1
  40. wget $host -O $zip
  41. mkdir -p $cnswp
  42. unzip -q -o $zip -d $cnswp
  43. rm -rf $zip
  44. chmod -R 777 $cnswp
  45. ###############
  46. sed -i "s|cnswp|$cnswp|g" $cnswp/cns.init
  47. sed -i "s|cnswp|$cnswp|g" $cnswp/cns.service
  48. echo -e "正在设置cns端口..."
  49. sed -i "s|33445|$cnspost|g" $cnswp/config.cfg
  50. sed -i "s|in 33445|in $cnspost|g" $cnswp/cns.init
  51. echo -e "正在设置cns密码..."
  52. sed -i "s|cns|$cnsmz|g" $cnswp/config.cfg
  53. ##核心下载#############
  54. latestVersion="v0.4.2"
  55. if [ ! -z "$(uname -m | grep -E 'amd64|x86_64')" ]; then
  56. ARCH="amd64"
  57. elif [ ! -z "$(uname -m | grep -E '86')" ]; then
  58. ARCH="i386"
  59. elif [ ! -z "$(uname -m | grep -E 'armv8|aarch64')" ]; then
  60. ARCH="aarch64"
  61. elif [ ! -z "$(uname -m | grep -Eq 'armv7|armv6')" ]; then
  62. ARCH="arm"
  63. else
  64. echo -e "不支持的系统架构!"
  65. exit 1
  66. fi
  67. echo -e "正在下载最新核心 linux_$ARCH-cns-$latestVersion ..."
  68. curl -L -o $cnswp/cns "https://jihulab.com/hepingcaizi/sao/-/raw/main/core/CNS_Anzichen/cns-linux-${ARCH}.bin"
  69. chmod -R 777 $cnswp
  70. ###############
  71. clear
  72. printf "\033c"
  73. #设置开机自启:
  74. ln -s $cnswp/cns.init /etc/init.d/cns #不需要权限
  75. if command -v systemctl >/dev/null 2>&1; then
  76. mv $cnswp/cns.service /lib/systemd/system/cns.service #不需要权限
  77. systemctl daemon-reload && systemctl enable cns.service
  78. systemctl restart cns.service && systemctl status cns.service
  79. else
  80. rm -rf $cnswp/cns.service
  81. /etc/init.d/cns restart
  82. fi
  83. #查看是否开机启动
  84. sleep 1
  85. ##显示
  86. echo "-------------------------------------------
  87. #启动代码:
  88. systemctl start cns.service #启动
  89. systemctl stopt cns.service #停止
  90. systemctl restart cns.service #重启
  91. /etc/init.d/cns status #检测
  92. /etc/init.d/cns stop #停止
  93. /etc/init.d/cns restart #重启
  94. -------------------------------------------
  95. 服务器端口:$cnspost密码:$cnsmz"
  96. echo "------------------------------------------"