Closed justme-1968 closed 2 years ago
My thoughts:
One suggestion regarding the third point:
3. **Update the script and restart it before checking Plex updates** / It seems logical. I'm not sure how to do it though.
The command you probably want to use is: exec "$0" "$@"
The exec bash builtin command replaces the current program with a new one.
$0 and $@ are bash special parameters:
($0) Expands to the name of the shell or shell script. This is set at shell initialization. If Bash is invoked with a file of commands (see Shell Scripts), $0 is set to the name of that file. If Bash is started with the -c option (see Invoking Bash), then $0 is set to the first argument after the string to be executed, if one is present. Otherwise, it is set to the filename used to invoke Bash, as given by argument zero.
($@) Expands to the positional parameters, starting from one. In contexts where word splitting is performed, this expands each positional parameter to a separate word; if not within double quotes, these words are subject to word splitting. In contexts where word splitting is not performed, this expands to a single word with each positional parameter separated by a space. When the expansion occurs within double quotes, and word splitting is performed, each parameter expands to a separate word. That is, "$@" is equivalent to "$1" "$2" …. If the double-quoted expansion occurs within a word, the expansion of the first parameter is joined with the beginning part of the original word, and the expansion of the last parameter is joined with the last part of the original word. When there are no positional parameters, "$@" and $@ expand to nothing (i.e., they are removed).
Thank you for this, it's much appreciated! My only outlying concern is how notifications will be affected by the cycled output. This will be interesting to test
For the upgrade process I would create a temporary .lock file somewhere with some variables in it:
And anything else you think is useful, e.g.:
You could even use this lock file for the Plex upgrade too. And also to test if the script and/or Plex server upgrades were successful.
The report should be issued only after the upgrade process and the aforementioned tests. And this way the report can contain the information about the success or failure of the upgrade too.
The report is simply a log of standard stream output from the task. Its not anything I can separately generate and email because of the limitations of the DSM. It's all very hackish, but there isn't a built-in alternative that I am aware of.
Thinking about this more while walking away from my keyboard, I think I can understand how what you suggest might be possible with various stream redirections to suppress/capture output until complete and ready to be displayed as a "report" when the script reaches its terminus.
Some quite extensive examples of self updating scripts, from https://glennr.nl/:
I will take a look at those for ideas, thanks!
here are some random ideas for the self update that just came to me when trying to get the 3.0.2 fix for the version umbers: