Administrator
Administrator
发布于 2024-12-27 / 4 阅读
0

群晖自动修改硬盘兼容性脚本

将此脚本部署在群晖设备中并添加自定义定时任务,每次群晖重启后检查配置文件中的硬盘兼容性参数,如果群晖自动升级了,脚本会修改参数,只需要再次重启群晖设备,硬盘兼容性就生效了,非常方便。希望能帮助到有需要的人。

#!/bin/bash

# Configuration file path (modify the path according to your system)
CONFIG_FILE="/etc.defaults/synoinfo.conf"  # Or adjust the path as necessary
BACKUP_CONFIG_FILE="/etc.defaults/synoinfo.conf.bak"  # Backup configuration file path

# Check if the configuration file exists
if [ ! -f "$CONFIG_FILE" ]; then
  echo "Configuration file $CONFIG_FILE does not exist!"
  exit 1
fi

# Check if the parameter is set to "yes"
grep "support_disk_compatibility=\"yes\"" $CONFIG_FILE

# If the parameter is "yes", modify it to "no"
if [ $? -eq 0 ]; then
  echo "Detected disk compatibility setting as 'yes', modifying it to 'no'..."

  # Create a backup of the configuration file before making any changes
  cp $CONFIG_FILE $BACKUP_CONFIG_FILE

  # Use sed to modify the configuration file
  sed -i 's/support_disk_compatibility=\"yes\"/support_disk_compatibility=\"no\"/' $CONFIG_FILE

  # Save the modification
  echo "Disk compatibility setting has been changed to 'no'"
  
  # Restart the system or relevant services (adjust as needed)
  # /sbin/reboot  # Uncomment if you need to reboot the system
else
  echo "Disk compatibility setting is already 'no', no modification needed"
fi

exit 0