From 67402f20fa9baa1557ee1e7fa7ae106964f6d903 Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Wed, 12 Apr 2023 15:03:56 +1000 Subject: [PATCH 1/3] Update syno_raidf1_shr_switch.sh --- syno_raidf1_shr_switch.sh | 122 +++++++++++++++++++++++++------------- 1 file changed, 80 insertions(+), 42 deletions(-) diff --git a/syno_raidf1_shr_switch.sh b/syno_raidf1_shr_switch.sh index 11754ed..d4de9db 100644 --- a/syno_raidf1_shr_switch.sh +++ b/syno_raidf1_shr_switch.sh @@ -12,7 +12,7 @@ # https://kb.synology.com/en-ro/DSM/tutorial/Which_Synology_NAS_models_support_RAID_F1 #------------------------------------------------------------------------------ -scriptver="v1.0.1" +scriptver="v1.0.2" script=Synology_RAID-F1_SHR_switch repo="007revad/Synology_RAID-F1_SHR_switch" @@ -21,8 +21,8 @@ repo="007revad/Synology_RAID-F1_SHR_switch" # Shell Colors #Black='\e[0;30m' # ${Black} Red='\e[0;31m' # ${Red} -Green='\e[0;32m' # ${Green} -Yellow='\e[0;33m' # ${Yellow} +#Green='\e[0;32m' # ${Green} +#Yellow='\e[0;33m' # ${Yellow} #Blue='\e[0;34m' # ${Blue} #Purple='\e[0;35m' # ${Purple} Cyan='\e[0;36m' # ${Cyan} @@ -32,7 +32,17 @@ Off='\e[0m' # ${Off} usage(){ - scriptversion + cat <&2 + enabled="shr" + elif [[ $settingshr != "yes" ]] && [[ $settingf1 == "yes" ]]; then + echo -e "${Cyan}RAID F1${Off} ${1}enabled.\n" >&2 + enabled="raidf1" + fi +} + +#checkcurrent "is currently " +checkcurrent "is " +if [[ $check == "yes" ]]; then + exit +fi + + #-------------------------------------------------------------------- # Select RAID type PS3="Select the RAID type: " -options=("SHR" "RAID F1" "Restore" "Quit") +if [[ $enabled == "shr" ]]; then + options=("RAID F1" "Restore" "Quit") +elif [[ $enabled == "raidf1" ]]; then + options=("SHR" "Restore" "Quit") +else + options=("SHR" "RAID F1" "Restore" "Quit") +fi select raid in "${options[@]}"; do case "$raid" in SHR) shr="yes" echo -e "You selected ${Cyan}SHR${Off}" - break + if [[ $enabled == "shr" ]]; then + echo -e "${Cyan}SHR${Off} is already enabled." + else + break + fi ;; "RAID F1") raidf1="yes" echo -e "You selected ${Cyan}RAID F1${Off}" + if [[ $enabled == "raidf1" ]]; then + echo -e "${Cyan}RAID F1${Off} is already enabled." + else + break + fi break ;; Restore) @@ -273,11 +337,11 @@ if [[ $restore == "yes" ]]; then if [[ -f ${synoinfo}.bak ]]; then # Restore from backup if cp "$synoinfo".bak "$synoinfo" ; then - echo -e "\nSuccessfully restored from backup." -# rebootmsg + echo -e "\nSuccessfully restored from backup.\n" + checkcurrent "is now " exit else - echo -e "\n${Error}ERROR ${Off} Backup failed!" + echo -e "\n${Error}ERROR ${Off} Restore from backup failed!" exit 1 fi else @@ -292,9 +356,9 @@ fi if [[ ! -f ${synoinfo}.bak ]]; then if cp "$synoinfo" "$synoinfo".bak ; then - echo -e "\nBackup successful." + echo -e "\nsynoinfo.conf backed up." else - echo -e "\n${Error}ERROR ${Off} Backup failed!" + echo -e "\n${Error}ERROR ${Off} synoinfo.conf backup failed!" exit 1 fi else @@ -305,32 +369,6 @@ fi #---------------------------------------------------------- # Edit synoinfo.conf -# Enable RAID F1 -# Set the following SHR line to "no": -# support_syno_hybrid_raid="no" -# -# Then add this line to enable RAID F1: -# supportraidgroup="yes" - -# Get current settings -sshr=support_syno_hybrid_raid -settingshr="$(get_key_value $synoinfo ${sshr})" -srg=supportraidgroup -settingf1="$(get_key_value $synoinfo ${srg})" - -# Check current setting -if [[ $settingshr == "yes" ]] && [[ $settingf1 != "yes" ]]; then - echo -e "\n${Cyan}SHR${Off} is currently enabled." - if [[ $shr == "yes" ]]; then - exit - fi -elif [[ $settingshr != "yes" ]] && [[ $settingf1 == "yes" ]]; then - echo -e "\n${Cyan}RAID F1${Off} is currently enabled." - if [[ $raidf1 == "yes" ]]; then - exit - fi -fi - # Enable RAID F1 if [[ $raidf1 == "yes" ]]; then if [[ ! $settingf1 ]]; then @@ -351,7 +389,7 @@ if [[ $raidf1 == "yes" ]]; then settingshr="$(get_key_value $synoinfo ${sshr})" settingf1="$(get_key_value $synoinfo ${srg})" if [[ $settingshr != "yes" ]] && [[ $settingf1 == "yes" ]]; then - echo -e "\n${Cyan}RAID F1${Off} has been enabled." + echo -e "\n${Cyan}RAID F1${Off} has been enabled.\n" else echo -e "\n${Error}ERROR${Off} Failed to enable RAID F1!" fi @@ -378,7 +416,7 @@ if [[ $shr == "yes" ]]; then settingshr="$(get_key_value $synoinfo ${sshr})" settingf1="$(get_key_value $synoinfo ${srg})" if [[ $settingshr == "yes" ]] && [[ $settingf1 != "yes" ]]; then - echo -e "\n${Cyan}SHR${Off} has been enabled." + echo -e "\n${Cyan}SHR${Off} has been enabled.\n" else echo -e "\n${Error}ERROR${Off} Failed to enable SHR!" fi From da27934e740a68bc5ad0fbf47994d879bcc79024 Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Wed, 12 Apr 2023 15:05:08 +1000 Subject: [PATCH 2/3] Update CHANGES.txt --- CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index b8450bd..74c1525 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ -v1.0.2 +v1.0.3 - Added --check option to check and show currently selected RAID type. - Added --help option to usage options. - Changed to not show the current RAID type as a choice to change to. From f56a49a5e8c39d3143d14bcb3b9df44276645766 Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Wed, 12 Apr 2023 15:05:28 +1000 Subject: [PATCH 3/3] Update syno_raidf1_shr_switch.sh - Added --check option to check and show currently selected RAID type. - Added --help option to usage options. - Changed to not show the current RAID type as a choice to change to. --- syno_raidf1_shr_switch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syno_raidf1_shr_switch.sh b/syno_raidf1_shr_switch.sh index d4de9db..1e85207 100644 --- a/syno_raidf1_shr_switch.sh +++ b/syno_raidf1_shr_switch.sh @@ -12,7 +12,7 @@ # https://kb.synology.com/en-ro/DSM/tutorial/Which_Synology_NAS_models_support_RAID_F1 #------------------------------------------------------------------------------ -scriptver="v1.0.2" +scriptver="v1.0.3" script=Synology_RAID-F1_SHR_switch repo="007revad/Synology_RAID-F1_SHR_switch"