iankelling.org
/
git
/
distro-setup
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
various fixes
[distro-setup]
/
filesystem
/
usr
/
local
/
bin
/
myupgrade
diff --git
a/filesystem/usr/local/bin/myupgrade
b/filesystem/usr/local/bin/myupgrade
index 1b39e7ff1c881f5b63432319b4a59aa13fa108de..e762246d09756f9c12c9d3042e0d433c7a69c304 100755
(executable)
--- a/
filesystem/usr/local/bin/myupgrade
+++ b/
filesystem/usr/local/bin/myupgrade
@@
-4,8
+4,16
@@
if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+source /usr/local/lib/err
+pre="${0##*/}:"
+m() { printf "$pre %s\n" "$*"; "$@"; }
+e() { printf "$pre %s\n" "$*"; }
+err() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $pre: $*" >&2; }
+
+if [[ $EUID == 0 ]]; then
+ err "run as nonroot"
+ exit 1
+fi
hn=$(hostname -f)
source /a/bin/bash_unpublished/source-state
hn=$(hostname -f)
source /a/bin/bash_unpublished/source-state
@@
-22,7
+30,7
@@
l /a/bin/buildscripts/rust
l /a/bin/buildscripts/misc
l go get -u mvdan.cc/fdroidcl
l /a/bin/buildscripts/misc
l go get -u mvdan.cc/fdroidcl
-cmd="
$s
/usr/sbin/checkrestart -p"
+cmd="
sudo
/usr/sbin/checkrestart -p"
if [[ $($cmd | sed '/^Found 0 processes using old versions of upgraded files$/d' | wc -l) != 0 ]]; then
$cmd -v | pee cat "wall -n"
fi
if [[ $($cmd | sed '/^Found 0 processes using old versions of upgraded files$/d' | wc -l) != 0 ]]; then
$cmd -v | pee cat "wall -n"
fi
@@
-35,7
+43,7
@@
if [[ -s /var/log/checkrestart.log ]]; then
for x in {30..1}; do
if ! fuser /var/lib/dpkg/lock &> /dev/null; then
echo "pid $PID. unattended upgrade, rebooting now" | pee cat "wall -n"
for x in {30..1}; do
if ! fuser /var/lib/dpkg/lock &> /dev/null; then
echo "pid $PID. unattended upgrade, rebooting now" | pee cat "wall -n"
- /sbin/reboot
+
sudo
/sbin/reboot
exit 0
fi
echo "pid $PID. unattended upgrade reboot waiting 10 seconds for dpkg lock" | wall -n
exit 0
fi
echo "pid $PID. unattended upgrade reboot waiting 10 seconds for dpkg lock" | wall -n