Standardize function import
This commit is contained in:
@@ -7,25 +7,27 @@ unset user password
|
||||
parent="${BASH_SOURCE[0]}"
|
||||
parent=${parent%/*}
|
||||
|
||||
[[ -f "$parent"/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||
[[ -f $parent/script-functions ]] && . "$parent"/script-functions || exit 1
|
||||
|
||||
is_root
|
||||
|
||||
echo "This script supports two optional arguments, a username and password"
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
prompt username
|
||||
prompt user
|
||||
prompt password
|
||||
elif [[ $# -eq 1 ]]; then
|
||||
username="$1"
|
||||
user="$1"
|
||||
prompt password
|
||||
elif [[ $# -eq 2 ]]; then
|
||||
username="$1"
|
||||
user="$1"
|
||||
password="$2"
|
||||
elif [[ $# -gt 2 ]]; then
|
||||
echo "Too many arguments provided"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! id -u "$username" &>/dev/null; then
|
||||
if ! id -u "$user" &>/dev/null; then
|
||||
echo "User $user does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user