- removed debug ouptut

- only execute certain code when the accompanying command exists
This commit is contained in:
2025-11-19 20:54:18 +01:00
parent d5ff6f3332
commit 4c09537776

View File

@@ -40,11 +40,6 @@ alias dirsizes='du -kh --apparent-size --max-depth=1 | sort -hr'
alias start_x11_vnc="x11vnc -many -display :0 -no6 -rfbport 5900 -auth /var/run/lightdm/root/:0 -rfbauth $HOME/.vnc/passwd" alias start_x11_vnc="x11vnc -many -display :0 -no6 -rfbport 5900 -auth /var/run/lightdm/root/:0 -rfbauth $HOME/.vnc/passwd"
commandExists() {
type $1 2 >& 1 > /dev/null
}
rsyncLink() { rsyncLink() {
source=$1; source=$1;
linkSource="$(realpath $source)"; linkSource="$(realpath $source)";
@@ -52,25 +47,18 @@ rsyncLink() {
shift; shift;
dest=$1; dest=$1;
shift; shift;
echo "rsync $DEFAULT_RSYNC --one-file-system --link-dest=$linkSource $source $dest $*;"
rsync $DEFAULT_RSYNC --one-file-system --link-dest=$linkSource $source $dest $*; rsync $DEFAULT_RSYNC --one-file-system --link-dest=$linkSource $source $dest $*;
} }
updateSystem() { updateSystem() {
executeAndNotify "doUpdateSystem $1" "system updated" "system update failed"
}
doUpdateSystem() {
updatePackages $1; updatePackages $1;
updateFlatpak $1; updateFlatpak $1;
} }
updateFlatpak() { updateFlatpak() {
if [[ ! $(commandExists flatpak) ]]; then
return 1;
fi
noconfirm= noconfirm=
if [[ $1 == "-y" ]]; then if [[ $1 == "-y" ]]; then
noconfirm="--assumeyes"; noconfirm="--assumeyes";
@@ -88,7 +76,7 @@ doUpdateFlatpak() {
# executes command and notifies upon failure # executes command and notifies upon failure
execute() { execute() {
dir="$(pwd)"; dir="$(pwd)";
dir=${dir##*/}; # cut off previous path (/path/to/foo.txt -> foo.txt) dir=${dir##*/};
if [[ -n "$2" ]]; then if [[ -n "$2" ]]; then
errLog=$2; errLog=$2;
else else
@@ -112,9 +100,17 @@ executeAndNotify () {
winLog="execution of \"$1\" succeeded"; winLog="execution of \"$1\" succeeded";
fi fi
echo ""
echo "******************************************"
echo "executeAndNotify \"$1\" \"$winLog\" \"$3\""
echo "******************************************"
echo ""
if ! execute "$1" "$3"; then # arguments in quotes so they are interpreted as ONE argument each by execute() if ! execute "$1" "$3"; then # arguments in quotes so they are interpreted as ONE argument each by execute()
echo "failed \"$1\" -> \"$3\""
return 1; return 1;
fi fi
echo "succeeded \"$1\" -> \"$winLog\""
notifyInfo "$dir: $winLog"; notifyInfo "$dir: $winLog";
} }
@@ -127,19 +123,11 @@ finds () {
# sends a desktop-notification with an icon signalling an error # sends a desktop-notification with an icon signalling an error
notifyError () { notifyError () {
if [[ ! $(commandExists notify-send) ]]; then
echo "ERROR: $1";
else
notify-send "$1" --icon=data-warning; notify-send "$1" --icon=data-warning;
fi
} }
# sends a desktop-notification with an icon signalling a simple information # sends a desktop-notification with an icon signalling a simple information
notifyInfo () { notifyInfo () {
if [[ ! $(commandExists notify-send) ]]; then
echo "INFO: $1";
else
notify-send "$1" --icon=preferences-desktop-notification; notify-send "$1" --icon=preferences-desktop-notification;
fi
} }