1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-12-25 16:40:07 -07:00

kiss: Allow usage of 'su' instead of 'sudo'

This commit is contained in:
Dylan Araps 2019-10-10 15:19:01 +03:00
parent ac1f0852dc
commit 885cad9774
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

24
kiss
View File

@ -419,7 +419,7 @@ pkg_build() {
# Install any pre-built binaries if they exist. # Install any pre-built binaries if they exist.
# This calls 'args' to inherit a root check and call # 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" ] && { [ -f "$bin_dir/$pkg#$version-$release.tar.gz" ] && {
log "$pkg" "Found pre-built binary, installing" log "$pkg" "Found pre-built binary, installing"
(KISS_FORCE=1 args i "$bin_dir/$pkg#$version-$release.tar.gz") (KISS_FORCE=1 args i "$bin_dir/$pkg#$version-$release.tar.gz")
@ -811,8 +811,13 @@ pkg_updates() {
git merge git merge
else else
log "$PWD" "Need root to update" 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 fi
} }
done done
@ -920,10 +925,15 @@ args() {
i|install|r|remove) i|install|r|remove)
[ "$1" ] || die "'kiss $action' requires an argument" [ "$1" ] || die "'kiss $action' requires an argument"
# Rerun the script with 'sudo' if the user isn't root. # Rerun the script with 'su' if the user isn't root.
# Cheeky but 'sudo' can't be used on shell functions themselves. # Cheeky but 'su' can't be used on shell functions themselves.
[ "$(id -u)" = 0 ] || { [ "$(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 return
} }
;; ;;
@ -1008,7 +1018,7 @@ args() {
;; ;;
v|version|-v|--version) v|version|-v|--version)
log kiss 0.50.0 log kiss 0.51.0
;; ;;
h|help|-h|--help|'') h|help|-h|--help|'')