diff options
author | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2020-02-10 18:02:44 +0000 |
---|---|---|
committer | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2020-02-10 18:02:44 +0000 |
commit | 293f957ce374d6cb2c8f548b3a278cde36bf8c0f (patch) | |
tree | fbbfee06e90813fcb9de4753722b9ce6d6bd36b6 /kiss | |
parent | 6c9c7883ad146ddecfac669a0b897cfb18e32c07 (diff) | |
download | cpt-293f957ce374d6cb2c8f548b3a278cde36bf8c0f.tar.gz |
kiss: Don't show messages if root
FossilOrigin-Name: 9f6d1d33b1dd7f9e140c3c516ecd11c90cef66dde434bf4a5335027960f4ef77
Diffstat (limited to 'kiss')
-rwxr-xr-x | kiss | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -52,7 +52,7 @@ prompt() { as_root() { # Simple function to run a command as root using either 'sudo', # 'doas' or 'su'. Hurrah for choice. - log "Using '${su:-su}'" + [ "$uid" = 0 ] || log "Using '${su:-su}'" case $su in *sudo) sudo -Eu "${user:-root}" -- "$@" ;; @@ -1070,13 +1070,13 @@ pkg_updates() { *) log "$PWD" " " ;; esac - if [ -w "$PWD" ] && [ "$(id -u)" != 0 ]; then + if [ -w "$PWD" ] && [ "$uid" != 0 ]; then git fetch git diff >> "$mak_dir/log" git merge else - log "$PWD" "Need root to update" + [ "$uid" = 0 ] || log "$PWD" "Need root to update" # Find out the owner of the repository and spawn # git as this user below. @@ -1212,7 +1212,7 @@ args() { a|alternatives) # Rerun the script with 'su' if the user isn't root. # Cheeky but 'su' can't be used on shell functions themselves. - [ -z "$1" ] || [ "$(id -u)" = 0 ] || { + [ -z "$1" ] || [ "$uid" = 0 ] || { as_root kiss "$action" "$@" return } @@ -1223,7 +1223,7 @@ args() { # Rerun the script with 'su' if the user isn't root. # Cheeky but 'su' can't be used on shell functions themselves. - [ "$(id -u)" = 0 ] || { + [ "$uid" = 0 ] || { KISS_FORCE="$KISS_FORCE" as_root kiss "$action" "$@" return } @@ -1289,7 +1289,7 @@ args() { l|list) pkg_list "$@" ;; u|update) pkg_updates ;; s|search) for pkg; do pkg_find "$pkg" all; done ;; - v|version) log kiss 1.4.3 ;; + v|version) log kiss 1.4.4 ;; h|help|-h|--help|'') log 'kiss [a|b|c|i|l|r|s|u|v] [pkg] [pkg] [pkg]' @@ -1344,6 +1344,10 @@ main() { # of the log files the package manager creates uring builds. time=$(date '+%Y-%m-%d-%H:%M') + # Make note of the user's current ID to do root checks later on. + # This is used enough to warrant a place here. + uid=$(id -u) + # This allows for automatic setup of a KISS chroot and will # do nothing on a normal system. mkdir -p "${sys_db:=$KISS_ROOT/$pkg_db}" 2>/dev/null ||: |