]> ##&name; ###&version; - Fix for unRaid 6.10 ###26.01.21 - Fixed empty included Drives list ###23.12.20 - CAUTION BETA Version install only if you know ho to revert back manually - Integrating lastest fixes for unRaid 6.9 ###2020.04.18 - Fix Sleep.php error - Fix Settings page ###2020.04.01 - Unraid 6.9 compability - Ported support for multi cache pool and correction for Cache pool - Multilanguage support ###2020.02.23 - Upgraded Script to 3.0.7 - Changed timer behavior - Change order of network activity check and ping check - THX to AcidRain@kodinerds.de ###2020.01.01a - codecleanup - new icon ###2020.01.01 - reverted back to version similiar 3.0.4 of the script ###2018.04.23 - made S3_sleep script compatible with unRAID 6.4 - fixed cache pool list ###2017.05.12 - revert to previous version, until proper solution is implemented. ###2017.04.28 - updated s3_sleep script to version 3.0.5 (added hdd activity check on both disk state and disk I/O) ###2017.03.07 - revert to previous version ###2017.03.06 - added auto detection of available sleep mode ###2016.10.23 - changed confirmation checkbox to confirmation window ###2016.09.24 - updated s3_sleep script to version 3.0.4 (fixed calling of powerdown script) ###2016.08.26 - fixed folders and files permissions - added minimum unRAID version 6.1.9 ###2016.8.19 - updated s3_sleep script to version 3.0.3 (changed HDD activity check to allow RAID controllers, courtesy Michael A.) - changed sleep icon ###2016.06.22 - updated s3_sleep script to version 3.0.2 (include SCSI attached disks in array list) ###2016.06.20 - fixed regression error when running unRAID v6.1.9 ###2016.06.19 - changed "System in Sleep mode" message to middle of footer (showNotice) ###2015.12.14 - added unRAID version check. Only version 6.1 or higher is allowed - updated consistency of PLG file ###2015.12.13 - changed .txz file naming to support consistent package upgrading - updated rc.s3_sleep script (start | stop | restart) ###2015.09.23 - correction in PLG file ###2015.09.16 - corrected preRun and postRun scripts calling with immediate sleep - added debug information with immediate sleep - updated s3_sleep script to version 3.0.1 ###2015.08.18b - corrected script location installation in PLG file ###2015.08.18a - moved location of pre-sleep and post-sleep commands to scripts folder (please re-apply settings) ###2015.08.18 - corrected regression error is sleep button ###2015.08.13 - adhere new security policy in unRAID v6.1 (please reboot after upgrade) ###2015.08.08 - make plugin compatible with unRAID version 6.0 and 6.1 ###2015.06.27 - introduced new logo (thanks Zonediver) - removed utilities page (now standard included with Dynamix webGui) - removed Reset button (now controlled by Dynamix webGui) - changed behavior of Default button (immediate reset) - changed behavior of enable/disable fields - allowed pre- and post- commands when Sleep button is pressed ###2015.04.28 - added Reset button on settings page - fixed enabling/disabling of buttons ###2015.04.11 - included online help information ###2015.02.14 - fixed s3_sleep startup after system reboot ###2015.01.22 - version update for webGui 2015.01.21 ###2014.12.07 - new s3_sleep version 3.0.0 - fixed addition of sleep settings - fixed unassigned devices ###2014.12.03 - fixed sleep button not added to Array Operation page ###2014.11.28 - initial release for unRAID v6 cfg="/boot/config/plugins/dynamix/dynamix.cfg" add_key(){ key=$(echo $2|cut -d'=' -f1) section=$(sed -n "/^\[$1\]/,/^\[/p" $cfg) if [[ -z $section ]]; then echo -e "[$1]\n$2" >>$cfg else if [[ $(echo $section|grep "$key="|wc -l) -eq 0 ]]; then sed -i "$(sed -n "/^\[$1\]/,/^\[/=" $cfg|tail -1) i $2" $cfg fi fi } # Add sleep settings if [[ -e $cfg ]]; then add_key 'confirm' 'sleep="1"' add_key 'display' 'sleep="plugins/&name;/Sleep.php"' else echo -e "[confirm]\nsleep=\"1\"" >$cfg echo -e "[display]\nsleep=\"plugins/&name;/Sleep.php\"" >>$cfg fi # Stop service /usr/local/emhttp/plugins/&name;/scripts/rc.s3sleep stop 2>/dev/null # Remove old 'source' packages MD5=$(md5sum &source;.txz 2>/dev/null|grep -Po '^\S+') if [[ $MD5 != &MD5; ]]; then rm -f &source;*.txz fi https://raw.githubusercontent.com/bjoerns1983/S3Sleep/master/archive/&name;.txz &MD5; #!/bin/bash /usr/local/emhttp/plugins/&name;/scripts/rc.s3sleep start cfg=&source;.cfg if [[ ! -e $cfg ]]; then cfg=/usr/local/emhttp/plugins/&name;/default.cfg fi # string decoder urldecode(){ echo -e "$(sed 's/+/ /g;s/%0D//g;s/%/\\x/g')" } # get unRAID key getkey(){ local mdcmd=/proc/mdstat if [[ -e $mdcmd ]]; then local key=$1 grep -Po "^$key=\K.*" $mdcmd fi } # Create preRun and postRun files (if existing) bash="#!/bin/bash\n" bin=/usr/local/emhttp/plugins/&name;/scripts preRun=$(grep -Po '^preRun="\K[^"]+' $cfg) if [[ -n $preRun ]]; then echo "${bash}${preRun}"|urldecode >$bin/preRun chmod u+x $bin/preRun fi postRun=$(grep -Po '^postRun="\K[^"]+' $cfg) if [[ -n $postRun ]]; then echo "${bash}${postRun}"|urldecode >$bin/postRun chmod u+x $bin/postRun fi # Start service enable=$(grep -Po '^service="\K[^"]+' $cfg) conf=/etc/s3_sleep.conf if [[ $enable -eq 1 ]]; then if [[ ! -e $conf ]]; then grep -Po '^options="\K.*' $cfg|sed -n 'G;s:"\n$::;p' >$conf fi if [[ $(getkey mdState) == STARTED ]]; then at -M -f /tmp/start_service now 2>/dev/null fi fi rm -f /tmp/start_service # Update file access mode chmod 644 $(awk '/\.(htm|php|js|page|css|png|plg|gif|cfg|md)$/ {print "/"$0}' /var/log/packages/&name;) echo "" echo "-----------------------------------------------------------" echo " Plugin &name; is installed." echo " This plugin requires Dynamix webGui to operate" echo " Copyright 2020, Bergware International" echo " Version: &version;" echo "-----------------------------------------------------------" echo "" # Delete sleep settings sed -i '/^sleep=/d' /boot/config/plugins/dynamix/dynamix.cfg # Stop service /usr/local/emhttp/plugins/&name;/scripts/rc.s3sleep stop # Remove plugin related files rm -rf /boot/config/plugins/&name; # Uninstall the 'source' package removepkg &name;