rfuehrer / syno_autoshutdown Goto Github PK
View Code? Open in Web Editor NEWAutoshutdown Shell Script for Synology (or other NAS)
License: Apache License 2.0
Autoshutdown Shell Script for Synology (or other NAS)
License: Apache License 2.0
Add additional placeholder which replace #RUNLOOP_TIME# in human readable format. The placeholder #RUNLOOP_TIME# is in minutes.
have a look at the time values (6:50->7:43->40mins?). config is set to NOTIFY_ON_LONGRUN_EVERY=120, so the warning should be written after 2h and not after 40mins...
12.11.2019 07:43:43 [18739] [I] - Sending notification (MESSAGE_LONGRUN)
12.11.2019 07:43:43 [18739] [D] - DS2413
12.11.2019 07:43:43 [18739] [D] - Das System ist bereits seit 12.11.2019 06:50:24 für 0d:0h:40m:0s online. Weiterhin erforderlich?
Although it is perfectly fine to use parameters as $1
and $2
in the code like here...
syno_autoshutdown/autoshutdown.sh
Lines 309 to 319 in 66d9a30
Example
notification()
{
local system=$1 # myname
local message=$2
if [ "x$IFTTT_KEY" != "x" ]; then
if [ "x$IFTTT_EVENT" != "x" ]; then
if [ "x$system" != "x" ]; then
MY_NAME=$system
MY_STATUS=$message
writelog "D" "$MY_NAME"
writelog "D" "$MY_STATUS"
If no system is names (or variable CHECKHOSTS is commented), the check found "0 systems" and the loop is resetted. The loop should say "No valid systems fund"
The brackets around the shell commands like in the example below serve no purpose and should be removed.
syno_autoshutdown/autoshutdown.sh
Line 93 in 66d9a30
Every necessary variable should have a default value which is set if no config definition is set.
The code must be documented as comprehensively and meaningful as possible. Important lines/blocks in the code should be sufficiently commented and all functions should be provided with an appropriate header which describes the function, the input variables as well as the output variables.
Several instances of the script must be checked and handled correctly depending on the future scope of functions.
Starting the script from within itself requires at least several instances for a short time (2). Also, later parameterized calls to terminate all instances or other functions implemented in a single script could lead to several instances being (temporarily) executed at the same time.
Nevertheless, it should be considered whether the permanent execution of multiple instances makes sense. In particular, logging in different logs under different PIDs is not useful.
Wrong image embedded showing wrong command to start autoshutdown script.
The code is not consistent in how it invokes commands. Usage of backticks like in this example...
syno_autoshutdown/autoshutdown.sh
Line 24 in 66d9a30
$(foo ...)
Notification messages should be enhanced with placeholders for dynamic content (list of found systems, elapsed time with no valid system etc.)
User data must be secured in such a way that the variables do not represent an entry gate for attackers but are also converted in such a way that the service can still be used.
Systems in standby or sleep state (e.g. Macbook) are detected as valid marker system and the system won't shutdown. Implement a fix to detect systems in standby and shutdown the NAS.
The shebang
syno_autoshutdown/autoshutdown.sh
Line 1 in 66d9a30
syno_autoshutdown/autoshutdown.sh
Line 442 in 66d9a30
This does not produce an error since on most Linux systems, sh
is usually a symlink to bash
or dash
or some other "way more advanced then pure POSIX sh
"-shell, but it's still wrong.
Fixing is easy: use #!/usr/bin/env bash
as shebang.
(This also uses environment lookup).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.