From d9a1fd797d1d659b90c8d8d1a5b8f3c93fa2742c Mon Sep 17 00:00:00 2001 From: The StarOpenSource Project Date: Wed, 13 Sep 2023 03:17:37 +0200 Subject: [PATCH] Optimize scripts --- soscmd-cache-dotcache | 4 +--- soscmd-cleanup | 8 ++++---- soscmd-lspkg | 9 ++++++--- soscmd-prune-docker | 14 ++++---------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/soscmd-cache-dotcache b/soscmd-cache-dotcache index ccd834e..3e822a4 100755 --- a/soscmd-cache-dotcache +++ b/soscmd-cache-dotcache @@ -1,6 +1,4 @@ #!/bin/bash rm -rf /root/.cache -rm -rf /var/www/.cache -rm -rf /home/{aur,jeremystartm,mastodon}/.cache -rm -rf /opt/owncast/.cache +rm -rf /home/{aur,firefish,mastodon}/.cache echo ":: Purged all \".cache\" directories." diff --git a/soscmd-cleanup b/soscmd-cleanup index 39987b6..c242b9a 100755 --- a/soscmd-cleanup +++ b/soscmd-cleanup @@ -1,7 +1,7 @@ #!/bin/bash echo ":: Cleaning up..." -export "diskusage_precleanup=$(df -h /)" -export "diskusage_precleanup_bytes=$(df /)" +export "diskusage_precleanup=$(df -h /data)" +export "diskusage_precleanup_bytes=$(df /data)" soscmd-prune soscmd-cache soscmd-bleachbit @@ -9,8 +9,8 @@ echo ":: Cleanup successful." echo -e "\n:: Disk usage before cleanup:" echo "$diskusage_precleanup" echo ":: after cleanup:" -df -h / +df -h /data echo -e "\n:: And here in measured in bytes, before cleanup:" echo "$diskusage_precleanup_bytes" echo ":: and after:" -df / +df /data diff --git a/soscmd-lspkg b/soscmd-lspkg index 7b05f44..457dba0 100755 --- a/soscmd-lspkg +++ b/soscmd-lspkg @@ -1,6 +1,9 @@ #!/bin/bash -if [ ! -f "/bin/dpkg" ]; then - echo ":: Error: You are not running a Debian based distro." +if [ -f "/bin/dpkg" ]; then + dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n +elif [ -f "/bin/pacman" ] && [ -f "/bin/pacman-key" ]; then + LC_ALL=C pacman -Qi | awk '/^Name/{name=$3} /^Installed Size/{print $4$5, name}' | sort -h +else + echo ":: Error: You are not running a Debian or Arch Linux based distro." exit 1 fi -dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n diff --git a/soscmd-prune-docker b/soscmd-prune-docker index ca7d0e4..f5ac1c1 100755 --- a/soscmd-prune-docker +++ b/soscmd-prune-docker @@ -1,11 +1,5 @@ #!/bin/bash -echo ":: Pruning docker containers" -docker container prune --force -echo ":: Pruning docker images" -docker image prune --force -echo ":: Pruning docker volumes" -docker volume prune --force -echo ":: Pruning docker networks" -docker network prune --force -echo ":: Adding required docker networks" -docker network create runner0 +echo ":: Pruning docker system" +yes|docker system prune -a +echo ":: Recreating traccar:custom" +/opt/traccar-docker/build.sh