From: Andre Ramnitz Date: Thu, 4 Jul 2024 19:12:19 +0000 (+0200) Subject: upgrayyedd: increase compatibility X-Git-Tag: v0.2~164 X-Git-Url: https://git.ramnitz.eu/?a=commitdiff_plain;h=6cd053caa52c7e65940a52fb66bf82d340faf1a7;p=dotfiles.git upgrayyedd: increase compatibility --- diff --git a/local/bin/upgrayyedd b/local/bin/upgrayyedd index 151c7202..13ae02b9 100755 --- a/local/bin/upgrayyedd +++ b/local/bin/upgrayyedd @@ -1,23 +1,40 @@ -#!/bin/sh +#!/bin/bash + +if command -v doas > /dev/null 2>&1; then + PRIV_CMD="doas" +elif command -v sudo > /dev/null 2>&1; then + PRIV_CMD="sudo" +elif [ "$(id -u)" -eq 0 ]; then + PRIV_CMD="" +else + echo "Error: No possibility to get administrative prileges." +fi case "$1" in refresh) - doas emaint sync -A - doas emerge -avuDN @world "${@:2}" + "$PRIV_CMD" emaint sync -A + "$PRIV_CMD" emerge -avuDN @world "${@:2}" ;; - log) - grep -i --color=auto -i "completed" /var/log/emerge.log - echo "note: use 'date -d @[unixtime]' to convert the timestamp" + again) + "$PRIV_CMD" emerge -avuDN @world "${@:2}" + exit 0 ;; clean) - doas emerge -a --depclean "${@:2}" + "$PRIV_CMD" emerge -a --depclean "${@:2}" ;; - now) - doas emerge -avuDN @world "${@:2}" + log) + grep -i --color=auto -i "completed" /var/log/emerge.log + echo "note: use 'date -d @[unixtime]' to convert the timestamp" ;; test) echo "${@:2}" ;; + "1") + "$PRIV_CMD" emerge -1av "${@:2}" + ;; + "av") + "$PRIV_CMD" emerge -av "${@:2}" + ;; *) - echo "Currently available commands: 'clean', 'refresh', 'log', 'now'" + echo "Currently available commands: 'refresh', 'again', 'clean', 'log', 'av', '1'" esac