diff --git a/utils_wp.sh b/utils_wp.sh index 97c9d12..430c063 100644 --- a/utils_wp.sh +++ b/utils_wp.sh @@ -1,11 +1,17 @@ #!/bin/bash -x +set -e + usage() { - echo "Usage: $0 [-h ] [ -s website ] [ -l | -v | -u userid ]" >&2 - exit 1 + echo "Usage: $0 [-h ] [ -s domain ] [ -l | -v | -u userid ]" >&2 + exit 0 } +if [ $# -lt 3 ]; then + echo "not enough arguments" + usage +fi while getopts ":hs:lu:v" opt; do @@ -13,10 +19,10 @@ do h) echo "Usage:" echo " $0 -h Display this help message." - echo " $0 -s The website is a mandatory argument." - echo " $0 -s -l List WordPress users." - echo " $0 -s -v Display the WordPress version" - echo " $0 -s -u Generate and set a random password for this WordPress userid." + echo " $0 -s The website is a mandatory argument." + echo " $0 -s -l List WordPress users." + echo " $0 -s -v Display the WordPress version" + echo " $0 -s -u Generate and set a random password for this WordPress userid." exit 0 ;; s) @@ -51,7 +57,6 @@ fi # declaration section - # functions section check_err() @@ -65,6 +70,10 @@ check_err() function get_sysuser() { SYSUSER=`ls -l /var/www/ | awk '$9 ~ /^'${WEB}'$/ { print $11 }' | awk -F'/' '{ print $6 }'` + if [ -z ${SYSUSER} ]; then + echo "SYSUSER contains nothing!" + exit 1 + fi echo ${SYSUSER} }