- removed debug ouptut
- only execute certain code when the accompanying command exists
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
commandExists() {
|
||||
type $1 2 >& 1 > /dev/null
|
||||
}
|
||||
|
||||
|
||||
rsyncLink() {
|
||||
source=$1;
|
||||
linkSource="$(realpath $source)";
|
||||
@@ -52,25 +47,18 @@ rsyncLink() {
|
||||
shift;
|
||||
dest=$1;
|
||||
shift;
|
||||
echo "rsync $DEFAULT_RSYNC --one-file-system --link-dest=$linkSource $source $dest $*;"
|
||||
rsync $DEFAULT_RSYNC --one-file-system --link-dest=$linkSource $source $dest $*;
|
||||
}
|
||||
|
||||
|
||||
updateSystem() {
|
||||
executeAndNotify "doUpdateSystem $1" "system updated" "system update failed"
|
||||
}
|
||||
|
||||
|
||||
doUpdateSystem() {
|
||||
updatePackages $1;
|
||||
updateFlatpak $1;
|
||||
}
|
||||
|
||||
|
||||
updateFlatpak() {
|
||||
if [[ ! $(commandExists flatpak) ]]; then
|
||||
return 1;
|
||||
fi
|
||||
noconfirm=
|
||||
if [[ $1 == "-y" ]]; then
|
||||
noconfirm="--assumeyes";
|
||||
@@ -88,7 +76,7 @@ doUpdateFlatpak() {
|
||||
# executes command and notifies upon failure
|
||||
execute() {
|
||||
dir="$(pwd)";
|
||||
dir=${dir##*/}; # cut off previous path (/path/to/foo.txt -> foo.txt)
|
||||
dir=${dir##*/};
|
||||
if [[ -n "$2" ]]; then
|
||||
errLog=$2;
|
||||
else
|
||||
@@ -112,9 +100,17 @@ executeAndNotify () {
|
||||
winLog="execution of \"$1\" succeeded";
|
||||
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()
|
||||
echo "failed \"$1\" -> \"$3\""
|
||||
return 1;
|
||||
fi
|
||||
echo "succeeded \"$1\" -> \"$winLog\""
|
||||
notifyInfo "$dir: $winLog";
|
||||
}
|
||||
|
||||
@@ -127,19 +123,11 @@ finds () {
|
||||
|
||||
# sends a desktop-notification with an icon signalling an error
|
||||
notifyError () {
|
||||
if [[ ! $(commandExists notify-send) ]]; then
|
||||
echo "ERROR: $1";
|
||||
else
|
||||
notify-send "$1" --icon=data-warning;
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# sends a desktop-notification with an icon signalling a simple information
|
||||
notifyInfo () {
|
||||
if [[ ! $(commandExists notify-send) ]]; then
|
||||
echo "INFO: $1";
|
||||
else
|
||||
notify-send "$1" --icon=preferences-desktop-notification;
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user