diff --git a/syno_seq_io.sh b/syno_seq_io.sh index 08d940a..ba783cd 100644 --- a/syno_seq_io.sh +++ b/syno_seq_io.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# shellcheck disable=SC2076,SC2207 #------------------------------------------------------------------------------ # Github: https://github.com/007revad/Synology_enable_sequential_IO # Script verified at https://www.shellcheck.net/ @@ -16,103 +17,248 @@ # If no parameter the script defaults to 0 #------------------------------------------------------------------------------ -scriptver="v1.0.1" +# v2.0.3 +# Added --volumes option to make it possible to schedule script to run at boot-up. +# - You can specify multiple comma separated volumes. +# Added --kb option to replace setting kb via first parameter. +# Bug fix for "Not persistent across reboots" issue #2 +# Bug fix for when no caches are found. +# Bug fix for when multiple caches are found. + + +scriptver="v2.0.3" script=Synology_enable_sequential_IO repo="007revad/Synology_enable_sequential_IO" #scriptname=syno_seq_io -if [[ $1 =~ ^[0-9]+$ ]]; then - kb="$1" +# Check script is running as root +if [[ $( whoami ) != "root" ]]; then + echo -e "$script $scriptver - by 007revad" + echo -e "ERROR This script must be run as sudo or root!" + exit 1 +fi + +version(){ + echo -e "$script $scriptver - by 007revad" + echo -e "See https://github.com/$repo \n" +} + +# Save options used +args=("$@") + +usage(){ + cat </dev/null; then + echo "$kb" > "/proc/sys/dev/${v}/skip_seq_thresh_kb" + fi + + # Check we set key value + check="$(synogetkeyvalue /etc/sysctl.conf "$key")" + if [[ "$check" == "0" ]]; then + echo -e "Sequential I/O for $cachevol cache is ${Green}Enabled${Off} in /etc/sysctl.conf" + elif [[ "$check" == "1024" ]]; then + echo -e "Sequential I/O for $cachevol cache is ${Red}Disabled${Off} in /etc/sysctl.conf" + elif [[ -z "$check" ]]; then + echo -e "Sequential I/O for $cachevol cache is ${Red}not set${Off} in /etc/sysctl.conf" + else + echo -e "Sequential I/O for $cachevol cache is set to ${Cyan}$check${Off} in /etc/sysctl.conf" + fi + + # Check we set proc/sys/dev + val="$(cat /proc/sys/dev/"${v}"/skip_seq_thresh_kb)" + if [[ "$val" == "0" ]]; then + echo -e "Sequential I/O for $cachevol cache is ${Green}Enabled${Off} in /proc/sys/dev\n" + elif [[ "$val" == "1024" ]]; then + echo -e "Sequential I/O for $cachevol cache is ${Red}Disabled${Off} in /proc/sys/dev\n" + elif [[ -z "$val" ]]; then + echo -e "Sequential I/O for $cachevol cache is ${Red}not set${Off} in /proc/sys/dev\n" + else + echo -e "Sequential I/O for $cachevol cache is set to ${Cyan}$val${Off} in /proc/sys/dev\n" + fi + fi + done +done + + +if [[ $scheduled != "yes" ]]; then + echo "You need to run this script after each reboot," + echo -e "or schedule a triggered task to run it as root at boot.\n" fi + exit