From 6cd053caa52c7e65940a52fb66bf82d340faf1a7 Mon Sep 17 00:00:00 2001 From: Andre Ramnitz Date: Thu, 4 Jul 2024 21:12:19 +0200 Subject: [PATCH] upgrayyedd: increase compatibility --- local/bin/upgrayyedd | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) 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 -- 2.51.2