Updated ncRoot checks

This commit is contained in:
Asif Bacchus 2018-10-03 14:04:18 -06:00
parent c1c02132af
commit 85b5c15672

View File

@ -189,7 +189,7 @@ while getopts ':l:n:u:v5:w:' PARAMS; do
;; ;;
n) n)
# NextCloud webroot # NextCloud webroot
ncRoot="${OPTARG}" ncRoot="${OPTARG%/}"
;; ;;
u) u)
# webuser # webuser
@ -222,10 +222,21 @@ done
if [ $(id -u) -ne 0 ]; then if [ $(id -u) -ne 0 ]; then
echo -e "\n${err}This script MUST be run as ROOT. Exiting.${normal}" echo -e "\n${err}This script MUST be run as ROOT. Exiting.${normal}"
exit 2 exit 2
# Ensure NextCloud webroot is provided
elif [ -z "$ncRoot" ]; then elif [ -z "$ncRoot" ]; then
echo -e "\n${err}The NextCloud webroot must be specified (-n parameter)" \ echo -e "\n${err}The NextCloud webroot must be specified (-n parameter)" \
"${normal}\n" "${normal}\n"
exit 1 exit 1
# Ensure NextCloud webroot directory exists
elif [ -n "$ncRoot" ]; then
checkExist fd "$ncRoot"
checkResult="$?"
if [ "$checkResult" = "1" ]; then
# Specified NextCloud webroot directory could not be found
echo -e "\n${err}The provided NextCloud webroot directory" \
"(-n parameter) does not exist.${normal}\n"
exit 1
fi
# Ensure NextCloud webuser account is provided # Ensure NextCloud webuser account is provided
elif [ -z "$webUser" ]; then elif [ -z "$webUser" ]; then
echo -e "\n${err}The webuser account running NextCloud must be provided" \ echo -e "\n${err}The webuser account running NextCloud must be provided" \