猫盘plus 群晖 完美关机脚本(三合一修复脚本)

此前安装了群晖 DSM 6.2,按网上方法折腾了几个方案都不成功。

于是把系统升级为 DSM 7.01 , 按网上的方法成功了。

脚本内容:

bash 复制代码
#!/bin/sh

fixhosts(){
cat > /etc/hosts << \EOF
127.0.0.1	localhost
::1		localhost
127.0.0.1	DS120j
::1		DS120j

52.84.166.71 api.themoviedb.org
52.84.166.68 api.themoviedb.org
18.65.159.31 api.themoviedb.org
13.35.0.128 api.themoviedb.org
99.84.238.181 image.tmdb.org
13.226.254.58 image.tmdb.org
65.8.164.121 image.tmdb.org
54.192.73.28 image.tmdb.org
EOF
}

rc_local_func(){
if [ "$1" = "120bak" ]; then
  rm /etc/rc.local
  if [ -f /etc/rc.local.bak ]; then
    mv -f /etc/rc.local.bak /etc/rc.local
  fi
else
  if [ -f /etc/rc.local ]; then
    mv -f /etc/rc.local /etc/rc.local.bak
  fi
  cat > /etc/rc.local << \EOF
#!/bin/sh
if [ "$1" = "R" ]
then
i2cset -y -f 0 0x45 0x00 0x55
i2cset -y -f 0 0x45 0x01 0x01
i2cset -y -f 0 0x45 0x31 0x03
i2cset -y -f 0 0x45 0x32 0x03
i2cset -y -f 0 0x45 0x33 0x03
i2cset -y -f 0 0x45 0x30 0x07
i2cset -y -f 0 0x45 0x34 128
i2cset -y -f 0 0x45 0x35 0
i2cset -y -f 0 0x45 0x36 0

killall -9 synoscsitmonitor
sleep 60
/usr/sbin/ntpdate -u ntp1.aliyun.com
systemctl stop pkg-scsit-monitor.service

fi

if [ "$1" = "G" ]
then
i2cset -y -f 0 0x45 0x00 0x55
i2cset -y -f 0 0x45 0x01 0x01
i2cset -y -f 0 0x45 0x31 0x03
i2cset -y -f 0 0x45 0x32 0x03
i2cset -y -f 0 0x45 0x33 0x03
i2cset -y -f 0 0x45 0x30 0x07
i2cset -y -f 0 0x45 0x34 0
i2cset -y -f 0 0x45 0x35 128
i2cset -y -f 0 0x45 0x36 0

killall -9 synoscsitmonitor
sleep 60
/usr/sbin/ntpdate -u ntp1.aliyun.com
systemctl stop pkg-scsit-monitor.service

fi

if [ "$1" = "B" ]
then
i2cset -y -f 0 0x45 0x00 0x55
i2cset -y -f 0 0x45 0x01 0x01
i2cset -y -f 0 0x45 0x31 0x03
i2cset -y -f 0 0x45 0x32 0x03
i2cset -y -f 0 0x45 0x33 0x03
i2cset -y -f 0 0x45 0x30 0x07
i2cset -y -f 0 0x45 0x34 0
i2cset -y -f 0 0x45 0x35 0
i2cset -y -f 0 0x45 0x36 128

killall -9 synoscsitmonitor
sleep 60
/usr/sbin/ntpdate -u ntp1.aliyun.com
systemctl stop pkg-scsit-monitor.service

fi

if [ "$1" = "W" ]
then
i2cset -y -f 0 0x45 0x00 0x55
i2cset -y -f 0 0x45 0x01 0x01
i2cset -y -f 0 0x45 0x31 0x03
i2cset -y -f 0 0x45 0x32 0x03
i2cset -y -f 0 0x45 0x33 0x03
i2cset -y -f 0 0x45 0x30 0x07
i2cset -y -f 0 0x45 0x34 128
i2cset -y -f 0 0x45 0x35 128
i2cset -y -f 0 0x45 0x36 128

killall -9 synoscsitmonitor
sleep 60
/usr/sbin/ntpdate -u ntp1.aliyun.com
systemctl stop pkg-scsit-monitor.service

fi

if [ "$1" = "" ]
then
i2cset -y -f 0 0x45 0x00 0x55
i2cset -y -f 0 0x45 0x01 0x01
i2cset -y -f 0 0x45 0x30 0x07
        
i2cset -y -f 0 0x45 0x31 0x72
i2cset -y -f 0 0x45 0x32 0x72
i2cset -y -f 0 0x45 0x33 0x72
        
i2cset -y -f 0 0x45 0x37 0x44  
i2cset -y -f 0 0x45 0x3a 0x55
i2cset -y -f 0 0x45 0x3d 0x66      

i2cset -y -f 0 0x45 0x38 0x44
i2cset -y -f 0 0x45 0x3b 0x55
i2cset -y -f 0 0x45 0x3e 0x66
i2cset -y -f 0 0x45 0x39 0x40
i2cset -y -f 0 0x45 0x3c 0x40
i2cset -y -f 0 0x45 0x3f 0x40

i2cset -y -f 0 0x45 0x34 128
i2cset -y -f 0 0x45 0x35 128
i2cset -y -f 0 0x45 0x36 128

killall -9 synoscsitmonitor
sleep 60
/usr/sbin/ntpdate -u ntp1.aliyun.com
systemctl stop pkg-scsit-monitor.service

fi

if [ "$1" = "X" ]
then
i2cset -y -f 0 0x45 0x00 0x55

killall -9 synoscsitmonitor
sleep 60
/usr/sbin/ntpdate -u ntp1.aliyun.com
systemctl stop pkg-scsit-monitor.service

fi

EOF
  if [ "$1" = "120x" ]; then
    cat >> /etc/rc.local << \EOF
if [ "$1" = "K" ]
then
/usr/bin/systemctl --force poweroff
i2cset -y -f 0 0x45 0x00 0x55
i2cset -y -f 0 0x45 0x01 0x01
i2cset -y -f 0 0x45 0x31 0x33
i2cset -y -f 0 0x45 0x32 0x33
i2cset -y -f 0 0x45 0x33 0x33
i2cset -y -f 0 0x45 0x30 0x07
i2cset -y -f 0 0x45 0x34 128
i2cset -y -f 0 0x45 0x35 0
i2cset -y -f 0 0x45 0x36 0
fi
EOF
  fi
  if [ "$1" = "120d" ]; then
    cat >> /etc/rc.local << \EOF
if [ "$1" = "K" ]
then
i2cset -y -f 0 0x45 0x77 0xc6
sleep 1
reboot
fi
EOF
  fi
  chmod 755 /etc/rc.local
fi
}

if [ "$1" = "" ]
then
  echo -e "\e[1;33m 如果一直失败,可能是引导方式不同,请另寻高明。  \e[0m"
  echo -e "\e[1;31m =================== LonelyGod =================== \e[0m"
  echo -e "\e[1;31m |                                               | \e[0m"
  echo -e "\e[1;31m |          猫盘群晖DSM7.0三合一修复脚本         | \e[0m"
  echo -e "\e[1;31m |                                               | \e[0m"
  echo -e "\e[1;31m ================= https://hin.cool ================= \e[0m"
  echo -e "\e[1;33m             bash bug 120x/120d/120bak             \e[0m"
fi

if [ "$1" = "120x" -o "$1" = "120d" ]; then
  echo -e "\e[1;33m 如果一直失败,可能是引导方式不同,请另寻高明。  \e[0m"
  echo -e "\e[1;31m =================== LonelyGod =================== \e[0m"
  echo -e "\e[1;31m |                                               | \e[0m"
  echo -e "\e[1;31m |          猫盘群晖DSM7.0三合一修复脚本         | \e[0m"
  echo -e "\e[1;31m |                                               | \e[0m"
  echo -e "\e[1;31m ================= https://hin.cool ================= \e[0m"
  rc_local_func $1
  fixhosts
  rm -rf /var/log/*

  sed -i 's#/dev/null#/tmp/scemd.log#g' /etc.defaults/syslog-ng/patterndb.d/scemd.conf
  sed -i 's#/dev/null#/tmp/postgresql.log#g' /etc.defaults/syslog-ng/patterndb.d/postgresql.conf
  sed -i 's#/var/log/scemd.log#/tmp/scemd.log#g' /etc.defaults/syslog-ng/patterndb.d/scemd.conf
  sed -i 's#/var/log/postgresql.log#/tmp/postgresql.log#g' /etc.defaults/syslog-ng/patterndb.d/postgresql.conf
  sed -i 's#/usr/bin/systemctl --force poweroff#/etc/rc.local K#g' /usr/lib/systemd/system/systemd-poweroff.service

  sed -i 's/buzzeroffcfg="0x00"/buzzeroffcfg="0x1b"/g' /etc.defaults/synoinfo.conf
  sed -i 's/enable_fan_debug="0x0"/enable_fan_debug="no"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_auto_poweron="yes"/support_auto_poweron="no"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_buzzer="yes"/support_buzzer="no"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_fan="yes"/support_fan="no"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_fan_adjust_dual_mode="yes"/support_fan_adjust_dual_mode="no"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_led_behavior_v2="yes"/support_led_behavior_v2="no"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_power_recovery="yes"/support_power_recovery="no"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_wol="yes"/support_wol="no"/g' /etc.defaults/synoinfo.conf
  sed -i 's/supportrcpower="yes"/supportrcpower="no"/g' /etc.defaults/synoinfo.conf
  sed -i 's/supportsystemperature="yes"/supportsystemperature="no"/g' /etc.defaults/synoinfo.conf
  sed -i 's/supportsystempwarning="yes"/supportsystempwarning="no"/g' /etc.defaults/synoinfo.conf
  echo -e "\e[1;33m 成功啦!成功啦!成功啦!立即重启猫盘,Enjoy  it!  \e[0m"
  rm -f /root/bug
  i2cset -y -f 0 0x45 0x00 0x55
  i2cset -y -f 0 0x45 0x01 0x01
  i2cset -y -f 0 0x45 0x31 0x33
  i2cset -y -f 0 0x45 0x32 0x33
  i2cset -y -f 0 0x45 0x33 0x33
  i2cset -y -f 0 0x45 0x30 0x07
  i2cset -y -f 0 0x45 0x34 0
  i2cset -y -f 0 0x45 0x35 128
  i2cset -y -f 0 0x45 0x36 0
fi

if [ "$1" = "120bak" ]; then
  echo -e "\e[1;33m 如果一直失败,可能是引导方式不同,请另寻高明。  \e[0m"
  echo -e "\e[1;31m =================== LonelyGod =================== \e[0m"
  echo -e "\e[1;31m |                                               | \e[0m"
  echo -e "\e[1;31m |          猫盘群晖DSM7.0三合一修复脚本         | \e[0m"
  echo -e "\e[1;31m |                                               | \e[0m"
  echo -e "\e[1;31m ================= https://hin.cool ================= \e[0m"

  rc_local_func $1
  rm -rf /var/log/*

  sed -i 's#/dev/null#/var/log/scemd.log#g' /etc.defaults/syslog-ng/patterndb.d/scemd.conf
  sed -i 's#/dev/null#/var/log/postgresql.log#g' /etc.defaults/syslog-ng/patterndb.d/postgresql.conf
  sed -i 's#/tmp/scemd.log#/var/log/scemd.log#g' /etc.defaults/syslog-ng/patterndb.d/scemd.conf
  sed -i 's#/tmp/postgresql.log#/var/log/postgresql.log#g' /etc.defaults/syslog-ng/patterndb.d/postgresql.conf
  sed -i 's#/etc/rc.local K#/usr/bin/systemctl --force poweroff#g' /usr/lib/systemd/system/systemd-poweroff.service

  sed -i 's/buzzeroffcfg="0x1b"/buzzeroffcfg="0x00"/g' /etc.defaults/synoinfo.conf
  sed -i 's/enable_fan_debug="no"/enable_fan_debug="0x0"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_auto_poweron="no"/support_auto_poweron="yes"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_buzzer="no"/support_buzzer="yes"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_fan="no"/support_fan="yes"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_fan_adjust_dual_mode="no"/support_fan_adjust_dual_mode="yes"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_led_behavior_v2="no"/support_led_behavior_v2="yes"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_power_recovery="no"/support_power_recovery="yes"/g' /etc.defaults/synoinfo.conf
  sed -i 's/support_wol="no"/support_wol="yes"/g' /etc.defaults/synoinfo.conf
  sed -i 's/supportrcpower="no"/supportrcpower="yes"/g' /etc.defaults/synoinfo.conf
  sed -i 's/supportsystemperature="no"/supportsystemperature="yes"/g' /etc.defaults/synoinfo.conf
  sed -i 's/supportsystempwarning="no"/supportsystempwarning="yes"/g' /etc.defaults/synoinfo.conf
  echo -e "\e[1;33m 成功啦!成功啦!成功啦!立即重启猫盘,Enjoy  it!  \e[0m"
  rm -f /root/bug
  i2cset -y -f 0 0x45 0x00 0x55
  i2cset -y -f 0 0x45 0x01 0x01
  i2cset -y -f 0 0x45 0x31 0x33
  i2cset -y -f 0 0x45 0x32 0x33
  i2cset -y -f 0 0x45 0x33 0x33
  i2cset -y -f 0 0x45 0x30 0x07
  i2cset -y -f 0 0x45 0x34 0
  i2cset -y -f 0 0x45 0x35 128
  i2cset -y -f 0 0x45 0x36 0
fi
/usr/bin/systemctl daemon-reload

1、保存为: bug.sh

(注意,保存的时候需要把Windows 风格的换行符(\r\n),换成Unix/Linux 使用的换行符(\n),

1)、在VS Code窗口的右下角,你会看到当前文件的换行符类型,可能显示为 CRLF(Windows 风格换行符)或 LF(Unix 风格换行符)。

2)、点击 CRLF,会弹出一个菜单,选择 LF。

3)、保存文件

2、在猫盘中创建一个共享文件夹:ds120share (这个文件夹在linux中访问的路径是/volume1/ds120share/)

3、把 bug.sh 复制到猫盘的ds120share文件夹中

4、通过putty连上猫盘

5、将 /volume1/ds120share/bug.sh 复制到 /root/ 目录:

bash 复制代码
cp /volume1/ds120share/bug.sh /root/bug.sh

6、修改文件权限

bash 复制代码
chmod +x /root/bug.sh

7、运行脚本,并传递 120d 参数:

bash 复制代码
bash /root/bug.sh 120d

执行后猫盘的灯慢闪橙色。

8、在群晖界面中重启猫盘 --> 重启后在群晖界面中"关机"-->成功!

参考:猫盘群晖DSM7.0三合一修复脚本_猫盘掉ip修复脚本-CSDN博客

猫盘群晖DSM7.0三合一修复 | 瓦解的生活记事

相关推荐
A小辣椒2 天前
TShark:Wireshark CLI 功能
linux
A小辣椒2 天前
TShark:基础知识
linux
AlfredZhao2 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
AlfredZhao2 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
用户9718356334663 天前
银河麒麟 KY10 申威(SW64) 安装 nginx-1.16.1-2.p01.ky10.sw_64.rpm 详细步骤
linux
猪脚踏浪3 天前
linux 拷贝文件或目录到指定的位置
linux
大树883 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
摇滚侠3 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
bush43 天前
嵌入式linux学习记录十四、术语
linux·嵌入式
载数而行5203 天前
Linux 11 动态监控指令top
linux