Standardize function import

This commit is contained in:
2024-06-30 15:30:50 -04:00
parent ccf91fe0f5
commit a5cde22362
16 changed files with 49 additions and 105 deletions

View File

@@ -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