diff options
author | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2019-10-10 12:19:01 +0000 |
---|---|---|
committer | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2019-10-10 12:19:01 +0000 |
commit | 324b2859cf1e710d89e1d38672b2600993b82eb6 (patch) | |
tree | 3eca33f7510a613fe0d9c0f0688d6ec8a361b90d /kiss | |
parent | 7bcf0769c0e2ec09336fba83e1fa69a188b2162b (diff) | |
download | cpt-324b2859cf1e710d89e1d38672b2600993b82eb6.tar.gz |
kiss: Allow usage of 'su' instead of 'sudo'
FossilOrigin-Name: 06cd176678969dee0cdf2a8b368a02562264b1464668e1c8a38b08135b81c4cc
Diffstat (limited to 'kiss')
-rwxr-xr-x | kiss | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -419,7 +419,7 @@ pkg_build() { # Install any pre-built binaries if they exist. # This calls 'args' to inherit a root check and call - # to 'sudo' to elevate permissions. + # to 'su' to elevate permissions. [ -f "$bin_dir/$pkg#$version-$release.tar.gz" ] && { log "$pkg" "Found pre-built binary, installing" (KISS_FORCE=1 args i "$bin_dir/$pkg#$version-$release.tar.gz") @@ -811,8 +811,13 @@ pkg_updates() { git merge else log "$PWD" "Need root to update" - sudo git fetch - sudo git merge + + if command -v sudo >/dev/null; then + sudo git fetch + sudo git merge + else + su -c 'git fetch && git merge' + fi fi } done @@ -920,10 +925,15 @@ args() { i|install|r|remove) [ "$1" ] || die "'kiss $action' requires an argument" - # Rerun the script with 'sudo' if the user isn't root. - # Cheeky but 'sudo' can't be used on shell functions themselves. + # 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 ] || { - sudo -E KISS_FORCE="$KISS_FORCE" kiss "$action" "$@" + if command -v sudo >/dev/null; then + sudo -E KISS_FORCE="$KISS_FORCE" kiss "$action" "$@" + else + su -pc "KISS_FORCE=$KISS_FORCE kiss $action $*" + fi + return } ;; @@ -1008,7 +1018,7 @@ args() { ;; v|version|-v|--version) - log kiss 0.50.0 + log kiss 0.51.0 ;; h|help|-h|--help|'') |