From 4c6091773d5b674789886af9cdeb298021bc45af Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:16:39 +1000 Subject: [PATCH] Update syno_enable_eunit.sh v3.0.15 - Added check that the Synology NAS has an eSATA port or Inifinband port. - Bug fix for incorrectly thinking RXnnnn was already enabled if RXnnnnRP was already enabled. --- syno_enable_eunit.sh | 47 +++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/syno_enable_eunit.sh b/syno_enable_eunit.sh index 770c1b2..5c5a869 100644 --- a/syno_enable_eunit.sh +++ b/syno_enable_eunit.sh @@ -12,7 +12,7 @@ # sudo -i /volume1/scripts/syno_enable_eunit.sh #----------------------------------------------------------------------------------- -scriptver="v3.0.14" +scriptver="v3.0.15" script=Synology_enable_eunit repo="007revad/Synology_enable_eunit" scriptname=syno_enable_eunit @@ -221,7 +221,19 @@ if [[ ${#args[@]} -gt "0" ]]; then fi # Check Synology has a expansion port -# How? +# eSATA and InfiniBand ports both appear in syno_slot_mapping as: +# Esata port count: 1 +# Eunit port 1 - RX1214 +if which syno_slot_mapping >/dev/null; then + esata_ports=$(syno_slot_mapping | grep 'Esata port count' | awk '{print $4}') + if [[ $esata_ports -lt "1" ]]; then + echo -e "${Error}ERROR${Off} Synology NAS has not expansion port(s)!" + exit 1 # No expansion port(s) + fi +else + echo -e "${Error}ERROR${Off} Unsupported Synology NAS model. No syno_slot_mapping command!" + exit 1 # No syno_slot_mapping file +fi #------------------------------------------------------------------------------ @@ -425,22 +437,17 @@ fi #------------------------------------------------------------------------------ # Show connected expansion units -if which syno_slot_mapping >/dev/null; then - #found_eunits=($(syno_slot_mapping | grep 'Eunit port' | awk '{print $NF}')) - read -r -a found_eunits <<< "$(syno_slot_mapping | grep 'Eunit port' | awk '{print $NF}')" - echo "Connected Expansion Units:" - if [[ ${#found_eunits[@]} -gt "0" ]]; then - for e in "${found_eunits[@]}"; do - echo -e "${Cyan}$e${Off}" - done - else - echo -e "${Cyan}None${Off}" - fi - #echo "" +#found_eunits=($(syno_slot_mapping | grep 'Eunit port' | awk '{print $NF}')) +read -r -a found_eunits <<< "$(syno_slot_mapping | grep 'Eunit port' | awk '{print $NF}')" +echo "Connected Expansion Units:" +if [[ ${#found_eunits[@]} -gt "0" ]]; then + for e in "${found_eunits[@]}"; do + echo -e "${Cyan}$e${Off}" + done else - echo -e "${Error}ERROR${Off} Unsupported Synology NAS model. No syno_slot_mapping command!" - exit 1 # No syno_slot_mapping file + echo -e "${Cyan}None${Off}" fi +#echo "" #------------------------------------------------------------------------------ @@ -616,14 +623,14 @@ supported_eunits=("DX517" "DX513" "DX213" "DX510" "RX418" "RX415" "RX410" \ check_modeldtb(){ # $1 is DX517 or RX418 etc if [[ -f "${dtb2_file}" ]]; then - if grep -q --text "$1" "${dtb2_file}"; then + if grep -q "$1"'\b' "${dtb2_file}"; then echo -e "${Cyan}$1${Off} is enabled in ${Yellow}${dtb2_file}${Off}" >& 2 else echo -e "${Cyan}$1${Off} is ${Cyan}not${Off} enabled in ${Yellow}${dtb2_file}${Off}" >& 2 fi fi if [[ -f "${dtb_file}" ]]; then - if grep -q --text "$1" "${dtb_file}"; then + if grep -q "$1"'\b' "${dtb_file}"; then echo -e "${Cyan}$1${Off} is enabled in ${Yellow}${dtb_file}${Off}" >& 2 else echo -e "${Cyan}$1${Off} is ${Cyan}not${Off} enabled in ${Yellow}${dtb_file}${Off}" >& 2 @@ -634,7 +641,7 @@ check_modeldtb(){ check_enabled(){ echo "" for e in "${supported_eunits[@]}"; do - if grep -q --text "$e" "${dtb_file}"; then + if grep -q "$e"'\b' "${dtb_file}"; then check_modeldtb "${e#Synology-}" fi done @@ -994,7 +1001,7 @@ edit_modeldtb(){ # Edit model.dts for c in "${eboxs[@]}"; do # Edit model.dts if needed - if ! grep -q "$c" "$dtb_file"; then + if ! grep -q "$c"'\b' "$dtb_file"; then dts_ebox "$c" "$dts_file" echo -e "Added ${Cyan}$c${Off} to ${Yellow}model${hwrev}.dtb${Off}" >&2 reboot=yes