bootstrap: Do not require sudo when running as root

This commit is contained in:
2020-12-08 23:09:09 +01:00
parent 1f0ea0e7be
commit 1a6239e928
2 changed files with 16 additions and 4 deletions

View File

@@ -16,7 +16,11 @@ if [[ "$(readlink "${_SCRIPT_DIR}")" != "${DOTDIR}" ]] ; then
exit 1
fi
printf "Moving directory to $DOTDIR ...\n"
sudo mv --no-target-directory "${_SCRIPT_DIR}" "${DOTDIR}"
sudo=""
if (( $(id -u ) != 0 )) ; then
sudo=sudo
fi
$sudo mv --no-target-directory "${_SCRIPT_DIR}" "${DOTDIR}"
printf "Done\n"
else
printf "Already working in ${DOTDIR}, nothing to do\n"