not running the letsencrypt-auto script as root, but use su if sudo not found

This commit is contained in:
Dev & Sec 2015-11-02 21:49:22 +00:00
parent 275f083a33
commit 8bad8de1c6

View file

@ -14,15 +14,16 @@ VENV_PATH=${VENV_PATH:-"$XDG_DATA_HOME/$VENV_NAME"}
VENV_BIN=${VENV_PATH}/bin
if test "`id -u`" -ne "0" ; then
if type sudo &>/dev/null; then
SUDO=sudo
else
args=("$@")
for i in "${!args[@]}"; do
args[$i]="'$(printf "%s" "${args[$i]}" | sed -e "s/'/'\"'\"'/g")' "
done
exec su root -c "$0 ${args[*]}"
if ! type sudo &>/dev/null; then
function sudo (){
args=("$@")
for i in "${!args[@]}"; do
args[$i]="'$(printf "%s" "${args[$i]}" | sed -e "s/'/'\"'\"'/g")' "
done
su root -c "${args[*]}"
}
fi
SUDO=sudo
else
SUDO=
fi