forked from kiss-community/kiss
kiss: Run as root where needed
This commit is contained in:
parent
7eb80497f6
commit
7ab295a76b
24
kiss
24
kiss
@ -61,10 +61,10 @@ root_cache() {
|
|||||||
|
|
||||||
# Validate the password now with a simple 'true' command
|
# Validate the password now with a simple 'true' command
|
||||||
# as we don't yet need to elevate permissions.
|
# as we don't yet need to elevate permissions.
|
||||||
root_run true
|
dosu true
|
||||||
}
|
}
|
||||||
|
|
||||||
root_run() {
|
dosu() {
|
||||||
# Run a command as root using the cached password. The 'su'
|
# Run a command as root using the cached password. The 'su'
|
||||||
# command allows you to input a password via stdin. To hide
|
# command allows you to input a password via stdin. To hide
|
||||||
# the prompt, the command's output is sent to '/dev/tty'
|
# the prompt, the command's output is sent to '/dev/tty'
|
||||||
@ -719,9 +719,9 @@ pkg_remove() {
|
|||||||
[ "${file##/etc/*}" ] || continue
|
[ "${file##/etc/*}" ] || continue
|
||||||
|
|
||||||
if [ -d "$KISS_ROOT/$file" ]; then
|
if [ -d "$KISS_ROOT/$file" ]; then
|
||||||
rmdir "$KISS_ROOT/$file" 2>/dev/null || continue
|
dosu rmdir "$KISS_ROOT/$file" 2>/dev/null || continue
|
||||||
else
|
else
|
||||||
rm -f "$KISS_ROOT/$file"
|
dosu rm -f "$KISS_ROOT/$file"
|
||||||
fi
|
fi
|
||||||
done < "$sys_db/$1/manifest"
|
done < "$sys_db/$1/manifest"
|
||||||
|
|
||||||
@ -797,7 +797,7 @@ pkg_install() {
|
|||||||
|
|
||||||
# This is repeated multiple times. Better to make it a function.
|
# This is repeated multiple times. Better to make it a function.
|
||||||
pkg_rsync() {
|
pkg_rsync() {
|
||||||
rsync --chown=root:root --chmod=Du-s,Dg-s,Do-s \
|
dosu rsync --chown=root:root --chmod=Du-s,Dg-s,Do-s \
|
||||||
-WhHKa --no-compress "$1" --exclude /etc \
|
-WhHKa --no-compress "$1" --exclude /etc \
|
||||||
"$tar_dir/$pkg_name/" "$KISS_ROOT/"
|
"$tar_dir/$pkg_name/" "$KISS_ROOT/"
|
||||||
}
|
}
|
||||||
@ -808,7 +808,7 @@ pkg_install() {
|
|||||||
|
|
||||||
# If '/etc/' exists in the package, install it but don't overwrite.
|
# If '/etc/' exists in the package, install it but don't overwrite.
|
||||||
[ -d "$tar_dir/$pkg_name/etc" ] &&
|
[ -d "$tar_dir/$pkg_name/etc" ] &&
|
||||||
rsync --chown=root:root -WhHKa --no-compress --ignore-existing \
|
dosu rsync --chown=root:root -WhHKa --no-compress --ignore-existing \
|
||||||
"$tar_dir/$pkg_name/etc" "$KISS_ROOT/"
|
"$tar_dir/$pkg_name/etc" "$KISS_ROOT/"
|
||||||
|
|
||||||
# Remove any leftover files if this is an upgrade.
|
# Remove any leftover files if this is an upgrade.
|
||||||
@ -826,18 +826,18 @@ pkg_install() {
|
|||||||
|
|
||||||
# Remove files.
|
# Remove files.
|
||||||
if [ -f "$file" ] && [ ! -L "$file" ]; then
|
if [ -f "$file" ] && [ ! -L "$file" ]; then
|
||||||
rm -f "$file"
|
dosu rm -f "$file"
|
||||||
|
|
||||||
# Remove file symlinks.
|
# Remove file symlinks.
|
||||||
elif [ -L "$file" ] && [ ! -d "$file" ]; then
|
elif [ -L "$file" ] && [ ! -d "$file" ]; then
|
||||||
unlink "$file" ||:
|
dosu unlink "$file" ||:
|
||||||
|
|
||||||
# Skip directory symlinks.
|
# Skip directory symlinks.
|
||||||
elif [ -L "$file" ] && [ -d "$file" ]; then :
|
elif [ -L "$file" ] && [ -d "$file" ]; then :
|
||||||
|
|
||||||
# Remove directories if empty.
|
# Remove directories if empty.
|
||||||
elif [ -d "$file" ]; then
|
elif [ -d "$file" ]; then
|
||||||
rmdir "$file" 2>/dev/null ||:
|
dosu rmdir "$file" 2>/dev/null ||:
|
||||||
fi
|
fi
|
||||||
done ||:
|
done ||:
|
||||||
}
|
}
|
||||||
@ -853,7 +853,7 @@ pkg_install() {
|
|||||||
|
|
||||||
if [ -x "$sys_db/$pkg_name/post-install" ]; then
|
if [ -x "$sys_db/$pkg_name/post-install" ]; then
|
||||||
log "$pkg_name" "Running post-install script"
|
log "$pkg_name" "Running post-install script"
|
||||||
"$sys_db/$pkg_name/post-install" ||:
|
dosu "$sys_db/$pkg_name/post-install" ||:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "$pkg_name" "Installed successfully"
|
log "$pkg_name" "Installed successfully"
|
||||||
@ -907,8 +907,8 @@ pkg_updates() {
|
|||||||
git fetch
|
git fetch
|
||||||
git merge
|
git merge
|
||||||
else
|
else
|
||||||
root_run git fetch
|
dosu git fetch
|
||||||
root_run git merge
|
dosu git merge
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user