Skip to content

Commit

Permalink
Update syno_enable_eunit.sh
Browse files Browse the repository at this point in the history
- Now shows which expansion units are currently connected.
  • Loading branch information
007revad authored Feb 22, 2024
1 parent ed04a48 commit 5ad68c8
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions syno_enable_eunit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# sudo -i /volume1/scripts/syno_enable_eunit.sh
#-----------------------------------------------------------------------------------

scriptver="v2.0.9"
scriptver="v2.0.10"
script=Synology_enable_eunit
repo="007revad/Synology_enable_eunit"
scriptname=syno_enable_eunit
Expand Down Expand Up @@ -403,6 +403,24 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
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 ""
fi


#------------------------------------------------------------------------------
# Set file variables

Expand Down Expand Up @@ -593,9 +611,9 @@ check_section_key_value(){
if [[ -n $2 ]]; then
if [[ -n $3 ]]; then
if [[ $setting == "yes" ]]; then
echo -e "${Yellow}$4${Off} is enabled for ${Cyan}$3${Off}" >&2
echo -e "${Cyan}$4${Off} is enabled for ${Yellow}$3${Off}" >&2
else
echo -e "$4 is ${Cyan}not${Off} enabled for $3" >&2
echo -e "${Cyan}$4${Off} is ${Cyan}not${Off} enabled for ${Yellow}$3${Off}" >&2
fi
else
echo -e "Key name not specified!" >&2
Expand All @@ -612,16 +630,16 @@ check_modeldtb(){
# $1 is DX517 or RX418 etc
if [[ -f "${dtb_file}" ]]; then
if grep --text "$1" "${dtb_file}" >/dev/null; then
echo -e "${Yellow}$1${Off} is enabled in ${Cyan}${dtb_file}${Off}" >& 2
echo -e "${Cyan}$1${Off} is enabled in ${Yellow}${dtb_file}${Off}" >& 2
else
echo -e "$1 is ${Cyan}not${Off} enabled in ${Cyan}${dtb_file}${Off}" >& 2
echo -e "${Cyan}$1${Off} is ${Cyan}not${Off} enabled in ${Yellow}${dtb_file}${Off}" >& 2
fi
fi
if [[ -f "${dtb2_file}" ]]; then
if grep --text "$1" "${dtb2_file}" >/dev/null; then
echo -e "${Yellow}$1${Off} is enabled in ${Cyan}${dtb2_file}${Off}" >& 2
echo -e "${Cyan}$1${Off} is enabled in ${Yellow}${dtb2_file}${Off}" >& 2
else
echo -e "$1 is ${Cyan}not${Off} enabled in ${Cyan}${dtb2_file}${Off}" >& 2
echo -e "${Cyan}$1${Off} is ${Cyan}not${Off} enabled in ${Yellow}${dtb2_file}${Off}" >& 2
fi
fi
}
Expand All @@ -631,7 +649,7 @@ check_enabled(){
setting=$(/usr/syno/bin/synogetkeyvalue "$synoinfo" support_ew_20_eunit)
IFS=',' read -r -a eunits_array <<< "$setting"
for e in "${eunits_array[@]}"; do
echo -e "${Yellow}${e#Synology-}${Off} is enabled in ${Cyan}${synoinfo}${Off}"
echo -e "${Cyan}${e#Synology-}${Off} is enabled in ${Yellow}${synoinfo}${Off}"
done
echo ""

Expand All @@ -641,7 +659,7 @@ check_enabled(){
for e in "${eunits_array2[@]}"; do
# if [[ ${eunits_array[*]} =~ "$e" ]]; then
if [[ ${eunits_array[*]} =~ $e ]]; then
echo -e "${Yellow}${e#Synology-}${Off} is enabled in ${Cyan}${synoinfo2}${Off}"
echo -e "${Cyan}${e#Synology-}${Off} is enabled in ${Yellow}${synoinfo2}${Off}"
fi
done
echo ""
Expand Down Expand Up @@ -679,9 +697,9 @@ show_enabled(){
count=$((count +1))
fi
if [[ $count == "4" ]]; then
echo -e "${Yellow}${e#Synology-}${Off} is enabled"
echo -e "${Cyan}${e#Synology-}${Off} is enabled"
else
echo -e "${Yellow}${e#Synology-}${Off} partially enabled"
echo -e "${Cyan}${e#Synology-}${Off} ${Yellow}partially${Off} enabled"
fi
done
echo ""
Expand Down Expand Up @@ -729,16 +747,17 @@ edit_synoinfo(){
# support_ew_20_eunit="Synology-DX517,Synology-RX418"
setting=$(synogetkeyvalue "$synoinfo" support_ew_20_eunit)
if [[ $setting != *"$1"* ]]; then
#backupdb "$synoinfo" long || exit 1 # debug
backupdb "$synoinfo" || exit 1
newsetting="${setting},Synology-${1}"
if synosetkeyvalue "$synoinfo" support_ew_20_eunit "$newsetting"; then
synosetkeyvalue "$synoinfo2" support_ew_20_eunit "$newsetting"
echo -e "Enabled ${Yellow}$1${Off} in ${Cyan}synoinfo.conf${Off}" >&2
echo -e "Enabled ${Cyan}$1${Off} in ${Yellow}synoinfo.conf${Off}" >&2
else
echo -e "${Error}ERROR 9${Off} Failed to enable $1 in synoinfo.conf!" >&2
fi
else
echo -e "${Yellow}$1${Off} already enabled in ${Cyan}synoinfo.conf${Off}" >&2
echo -e "${Cyan}$1${Off} already enabled in ${Yellow}synoinfo.conf${Off}" >&2
fi
fi
}
Expand Down Expand Up @@ -951,10 +970,10 @@ edit_modeldtb(){
# Edit model.dts if needed
if ! grep "$c" "$dtb_file" >/dev/null; then
dts_ebox "$c" "$dts_file"
echo -e "Added ${Yellow}$c${Off} to ${Cyan}model${hwrev}.dtb${Off}" >&2
echo -e "Added ${Cyan}$c${Off} to ${Yellow}model${hwrev}.dtb${Off}" >&2
reboot=yes
else
echo -e "${Yellow}$c${Off} already enabled in ${Cyan}model${hwrev}.dtb${Off}" >&2
echo -e "${Cyan}$c${Off} already enabled in ${Yellow}model${hwrev}.dtb${Off}" >&2
fi
done

Expand Down

0 comments on commit 5ad68c8

Please sign in to comment.