From 98da0fa1869757734610ec34fbeb0396f26c0026 Mon Sep 17 00:00:00 2001 From: clyhtsuriva Date: Wed, 2 Nov 2022 22:21:53 +0100 Subject: Putting the first scripts in a bin/ folder --- backup_usb32.sh | 3 -- bin/backup_usb32.sh | 3 ++ bin/number-of-pr-in | 42 +++++++++++++++++++++ bin/update-everything.sh | 83 +++++++++++++++++++++++++++++++++++++++++ bin/update-script-repo.sh | 7 ++++ number-of-pr-in | 42 --------------------- update-everything.sh | 94 ----------------------------------------------- 7 files changed, 135 insertions(+), 139 deletions(-) delete mode 100755 backup_usb32.sh create mode 100755 bin/backup_usb32.sh create mode 100755 bin/number-of-pr-in create mode 100755 bin/update-everything.sh create mode 100755 bin/update-script-repo.sh delete mode 100755 number-of-pr-in delete mode 100755 update-everything.sh diff --git a/backup_usb32.sh b/backup_usb32.sh deleted file mode 100755 index 8008480..0000000 --- a/backup_usb32.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -rsync -az -u -v /mnt/32 ~/Documents/32.bak/ diff --git a/bin/backup_usb32.sh b/bin/backup_usb32.sh new file mode 100755 index 0000000..8008480 --- /dev/null +++ b/bin/backup_usb32.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +rsync -az -u -v /mnt/32 ~/Documents/32.bak/ diff --git a/bin/number-of-pr-in b/bin/number-of-pr-in new file mode 100755 index 0000000..a32e4b5 --- /dev/null +++ b/bin/number-of-pr-in @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# +# number-of-pr-in +# Author : Clyhtsuriva + +usage () { + echo "Usage: number-of-pr-in " + exit 1 +} + +number-of-pr-in () { + + [ $# -eq 1 ] || usage + + GH_REPO=void-linux/$1 + LIMIT=1000 # Search API => 1000 results max + + gh repo view "$GH_REPO" 1> /dev/null || exit 1 + + GH_PR_LIST=$(gh pr list \ + --repo "$GH_REPO" \ + --author "@me" \ + --state merged \ + --limit $LIMIT) + + PARSED=$(echo "$GH_PR_LIST" | \ + awk '{ print $2 }' | \ + sed 's/://g' | \ + sort | \ + uniq -c | \ + sort -nr | \ + sed 's/ //g') + + + COLOR_ON=$(tput setaf 3; tput bold) + COLOR_OFF=$(tput sgr0) + + # shellcheck disable=SC2001 + echo "$PARSED" | sed "s/[^[:blank:]]\{1,\}/$COLOR_ON&$COLOR_OFF/1" +} + +number-of-pr-in "$@" diff --git a/bin/update-everything.sh b/bin/update-everything.sh new file mode 100755 index 0000000..f38d4cf --- /dev/null +++ b/bin/update-everything.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# +# Author: Clyhtsuriva + + +# FUNCTIONS +# +# echo_n_notify +# local_update +# remote_update +# non_free_update +# pip_update + + +xi='sudo xbps-install' +xr='sudo xbps-remove' + +# Print to stdout +# And as a notification +echo_n_notify(){ + printf "%s\n" "[$1]" + notify-send "[$1]" +} + +echo_n_notify "Updating everything ..." + +# Update local xbps packages +# And clean the cache and remove orphans +local_update(){ + + echo_n_notify "local update" + + $xi --sync --update --verbose && \ + $xr --clean-cache --remove-orphans --verbose + +} + +# Update remote debian server using Ansible +remote_update(){ + + echo_n_notify "remote update" + + ansible-playbook --inventory-file "$HOME/workbench/ansible/hosts" \ + "$HOME/workbench/ansible/update_adjutor.yml" + +} + +# Update non-free xbps packages +non_free_update(){ + + echo_n_notify "non-free update" + + pushd ~/workbench/auto-void-packages || exit 1 + ./update-git-repo.sh + cd ../void-packages || exit 1 + ./xbps-src pkg teams-bin && \ + $xi --repository=hostdir/binpkgs/nonfree teams-bin + ./xbps-src pkg discord && \ + $xi --repository=hostdir/binpkgs/nonfree discord + ./xbps-src pkg spotify && \ + $xi --repository=hostdir/binpkgs/nonfree spotify + popd || exit 1 + +} + +# Update pip packages needing one +pip_update(){ + + echo_n_notify "pip update" + + python3 -m pip list --outdated --format=json | \ + jq -r '.[] | "\(.name)==\(.latest_version)"' | \ + xargs -n1 pip3 install -U + +} + + +# MAIN + +local_update +remote_update +non_free_update +pip_update diff --git a/bin/update-script-repo.sh b/bin/update-script-repo.sh new file mode 100755 index 0000000..2edf308 --- /dev/null +++ b/bin/update-script-repo.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# Author : Clyhtsuriva + +SCRIPTS_REPO_PATH="$HOME/workbench/scripts/" + +cp -rv "$HOME/.local/usr/local/bin" "$SCRIPTS_REPO_PATH" +cp -rv "$HOME/workbench/auto-void-packages" "$SCRIPTS_REPO_PATH" diff --git a/number-of-pr-in b/number-of-pr-in deleted file mode 100755 index a32e4b5..0000000 --- a/number-of-pr-in +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -# -# number-of-pr-in -# Author : Clyhtsuriva - -usage () { - echo "Usage: number-of-pr-in " - exit 1 -} - -number-of-pr-in () { - - [ $# -eq 1 ] || usage - - GH_REPO=void-linux/$1 - LIMIT=1000 # Search API => 1000 results max - - gh repo view "$GH_REPO" 1> /dev/null || exit 1 - - GH_PR_LIST=$(gh pr list \ - --repo "$GH_REPO" \ - --author "@me" \ - --state merged \ - --limit $LIMIT) - - PARSED=$(echo "$GH_PR_LIST" | \ - awk '{ print $2 }' | \ - sed 's/://g' | \ - sort | \ - uniq -c | \ - sort -nr | \ - sed 's/ //g') - - - COLOR_ON=$(tput setaf 3; tput bold) - COLOR_OFF=$(tput sgr0) - - # shellcheck disable=SC2001 - echo "$PARSED" | sed "s/[^[:blank:]]\{1,\}/$COLOR_ON&$COLOR_OFF/1" -} - -number-of-pr-in "$@" diff --git a/update-everything.sh b/update-everything.sh deleted file mode 100755 index 6f2109e..0000000 --- a/update-everything.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env bash -# -# Author: Clyhtsuriva - - -# FUNCTIONS -# -# echo_n_notify -# local_update -# remote_update -# non_free_update -# pip_update - - -xi='sudo xbps-install' -xr='sudo xbps-remove' - -# Print to stdout -# And as a notification -echo_n_notify(){ - printf "%s\n" "[$1]" - notify-send "[$1]" -} - -echo_n_notify "Updating everything ..." - -# Update local xbps packages -# And clean the cache and remove orphans -local_update(){ - - echo_n_notify "local update" - - $xi --sync --update --verbose && \ - $xr --clean-cache --remove-orphans --verbose - -} - -# Update remote debian server using Ansible -remote_update(){ - - echo_n_notify "remote update" - -# ssh -p8022 debian@adjutor.xyz '\ -# sudo apt-fast update && \ -# sudo apt-fast upgrade && \ -# sudo apt-fast autoremove' - - ansible-playbook --inventory-file "$HOME/workbench/ansible/hosts" \ - "$HOME/workbench/ansible/update_adjutor.yml" - -} - -# Update non-free xbps packages -non_free_update(){ - - echo_n_notify "non-free update" - - pushd ~/workbench/auto-void-packages || exit 1 - ./update-git-repo.sh - cd ../void-packages || exit 1 - ./xbps-src pkg teams-bin && \ - $xi --repository=hostdir/binpkgs/nonfree teams-bin - ./xbps-src pkg discord && \ - $xi --repository=hostdir/binpkgs/nonfree discord - ./xbps-src pkg spotify && \ - $xi --repository=hostdir/binpkgs/nonfree spotify - popd || exit 1 - -} - -# Update pip packages needing one -pip_update(){ - - echo_n_notify "pip update" - - python3 -m pip list --outdated --format=json | \ - jq -r '.[] | "\(.name)==\(.latest_version)"' | \ - xargs -n1 pip3 install -U - -} - - -# ___ ___ ___ _____ _ _ -# | \/ | / _ \|_ _|| \ | | -# | . . |/ /_\ \ | | | \| | -# | |\/| || _ | | | | . ` | -# | | | || | | |_| |_ | |\ | -# \_| |_/\_| |_/\___/ \_| \_/ -# - -local_update -remote_update -non_free_update -pip_update -- cgit v1.2.3