From 9a690532548aee8e4ebac54d01d5a32ab48271ec Mon Sep 17 00:00:00 2001 From: Pablo Sarria Date: Tue, 10 May 2022 11:22:49 +0200 Subject: [PATCH] =?UTF-8?q?a=C3=B1ado=20set=20-e=20para=20salir=20cuando?= =?UTF-8?q?=20invoco=20exit=201=20y=20controlamos=20que=20el=20chsh=20no?= =?UTF-8?q?=20se=20realice=20sobre=20root?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils_wp.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) 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} }