Compare commits

..

2 Commits

Author SHA1 Message Date
fd9dba9f12 Merge remote-tracking branch 'origin/master' into debian 2023-07-06 13:00:17 +02:00
ba623040b9 - minor semantic changes (semicolons at the end of the line)
- added convenient updateSystem command
2023-07-06 12:51:55 +02:00
2 changed files with 26 additions and 14 deletions

View File

@ -31,6 +31,17 @@ alias fssizes='df -kh --output=size,used,avail,pcent,target | sort -hr'
alias dirsizes='du -kh --apparent-size --max-depth=1 | sort -hr' alias dirsizes='du -kh --apparent-size --max-depth=1 | sort -hr'
updateSystem() {
executeAndNotify "doUpdateSystem $1" "system updated" "system update failed"
}
doUpdateSystem() {
updatePackages $1;
updateFlatpak $1;
}
updateFlatpak() { updateFlatpak() {
noconfirm= noconfirm=
if [[ $1 == "-y" ]]; then if [[ $1 == "-y" ]]; then
@ -42,7 +53,7 @@ updateFlatpak() {
doUpdateFlatpak() { doUpdateFlatpak() {
flatpak update $1; flatpak update $1;
flatpak remove --unused $1 flatpak remove --unused $1;
} }
@ -50,10 +61,10 @@ doUpdateFlatpak() {
execute() { execute() {
dir="$(pwd)"; dir="$(pwd)";
dir=${dir##*/}; dir=${dir##*/};
if [ -n "$2" ]; then if [[ -n "$2" ]]; then
errLog=$2 errLog=$2;
else else
errLog="execution of \"$1\" failed" errLog="execution of \"$1\" failed";
fi fi
if ! $1; then if ! $1; then
@ -67,32 +78,32 @@ execute() {
executeAndNotify () { executeAndNotify () {
dir="$(pwd)"; dir="$(pwd)";
dir=${dir##*/}; dir=${dir##*/};
if [ -n "$2" ]; then if [[ -n "$2" ]]; then
winLog=$2 winLog=$2;
else else
winLog="execution of \"$1\" succeeded" winLog="execution of \"$1\" succeeded";
fi fi
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()
return 1; return 1;
fi fi
notifyInfo "$dir: $winLog" notifyInfo "$dir: $winLog";
} }
# find file but don't print errors (e.g. can't access directory etc.) # find file but don't print errors (e.g. can't access directory etc.)
finds () { finds () {
find $* 2>/dev/null find $* 2>/dev/null;
} }
# sends a desktop-notification with an icon signalling an error # sends a desktop-notification with an icon signalling an error
notifyError () { notifyError () {
notify-send "$1" --icon=data-warning notify-send "$1" --icon=data-warning;
} }
# sends a desktop-notification with an icon signalling a simple information # sends a desktop-notification with an icon signalling a simple information
notifyInfo () { notifyInfo () {
notify-send "$1" --icon=preferences-desktop-notification notify-send "$1" --icon=preferences-desktop-notification;
} }

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
updateSystem() {
updatePackages() {
noconfirm= noconfirm=
if [[ $1 == "-y" ]]; then if [[ $1 == "-y" ]]; then
noconfirm="--assume-yes" noconfirm="--assume-yes"
@ -9,11 +10,11 @@ updateSystem() {
if [[ $2 == "--full" ]]; then if [[ $2 == "--full" ]]; then
full="full-" full="full-"
fi fi
executeAndNotify "doUpdateSystem $noconfirm $full" "system updated" "system update failed"; executeAndNotify "doUpdatePackages $noconfirm $full" "system updated" "system update failed";
} }
doUpdateSystem() { doUpdatePackages() {
sudo apt update; sudo apt update;
sudo apt ${2}upgrade $1; sudo apt ${2}upgrade $1;
sudo apt autoremove $1; sudo apt autoremove $1;