From 6582eeabc18a976d1a2684f9752a017778ae0797 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Thu, 12 Jan 2017 14:56:55 -0500 Subject: [PATCH] Added update-tool --- shells/zshrc | 62 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/shells/zshrc b/shells/zshrc index 1190f3f..4b589f6 100644 --- a/shells/zshrc +++ b/shells/zshrc @@ -35,7 +35,17 @@ $ () { sv () { command="${@: -1}" while (( $# > 1 )); do - if [[ "$command" == "r" ]]; then + if [[ "$command" == "i" ]]; then + echo "Status of $1" + service "$1" status + shift + continue + fi + sudo true || return 2 + if [[ "$1" == "sshd" ]] || [[ "$1" == "ssh" ]]; then + echo "Checking sshd config..." + sudo sshd -t && echo "Config good. Continuing" || (echo "Aborting due to bad ssh config";return 1) + elif [[ "$command" == "r" ]]; then echo "Restarting $1" sudo service "$1" restart elif [[ "$command" == "s" ]]; then @@ -44,9 +54,6 @@ sv () { elif [[ "$command" == "x" ]]; then echo "Stopping $1" sudo service "$1" stop - elif [[ "$command" == "i" ]]; then - echo "Status of $1" - service "$1" status else sudo service "$1" "$command" fi @@ -111,12 +118,53 @@ download() { URL="$(printf $1 | perl -pe 's/\/paste\/view(?!\/raw)/\/paste\/view\/raw/')" curl "$URL" | base64 -d | tar -xf - } +update-tool() { + if [ "$EUID" -ne 0 ]; then + echo "This function should be run as root" + return 1 + fi + local RESP="" + while [[ "$RESP" != "q" ]]; do + CMD=${RESP:0:1} + case "$CMD" in + p) update;; + l) layman -S ;; + u) upgrade;; + e) etc-update;; + d) emerge -Ava --depclean;; + h) haskell-updater -- --usepkg=n;; + p) perl-cleaner --reallyall;; + y) python-updater;; + r) revdep-rebuild;; + q) return;; + esac + RESP=${RESP:1} + if [[ ! -z "$RESP" ]]; then + continue + fi + echo "Commands:" + echo "p: update" + echo "l: layman -S" + echo "u: upgrade" + echo "e: etc-update" + echo "d: emerge --ask --depclean" + echo "h: haskell-updater -- --usepkg=n" + echo "p: perl-cleaner --reallyall" + echo "y: python-updater" + echo "r: revdep-rebuild" + echo "q: quit" + echo -n "> " + read RESP + done +} +alias cleaner="sudo ~/run.sh 'perl-cleaner --reallyall' 'python-updater' 'haskell-updater -- --usepkg=n'" +alias jsonpretty='python -m json.tool' alias nmrestart='nmcli radio wifi off;nmcli radio wifi on' if ex mtr; then alias mtr='mtr -t' fi if ex telegram-cli; then - alias tg='telegram-cli -NWA' + alias tg='telegram-cli -NWA --disable-link-preview' fi alias perm='stat -c "%a %n"' alias afci='git x ./autoformat.sh;git commit -am "Autoformatted"' @@ -171,7 +219,7 @@ if test -f /etc/gentoo-release; then upgrade(){ # Sudo echo so we have immediate results on weather sudo worked sudo echo "Args: $*" - sudo emerge --update --newuse --deep --verbose --tree --keep-going=y --verbose-conflicts --alert --ask --binpkg-respect-use=y --binpkg-changed-deps=y $* @world + sudo emerge --update --newuse --deep --verbose --tree --keep-going=y --verbose-conflicts --alert --ask --binpkg-respect-use=y --binpkg-changed-deps=y --backtrack=30 $* @world echo "\\a" } # For emerging with absolute paths @@ -197,7 +245,7 @@ if test -f /etc/gentoo-release; then echo "You're a server. Exiting" return fi - sudo rm '/usr/portage/metadata/timestamp.chk' + sudo rm -f '/usr/portage/metadata/timestamp.chk' if ex eix-update; then sudo zsh -c "emaint sync -a&&eix-update" else