You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
scriptform/examples/simple/job_add_user.sh

29 lines
452 B

#!/bin/sh
HTPASSWD=htpasswd
err() {
echo $* >&2
exit 1
}
if [ -z "$password1" ]; then
err "Empty password specified"
fi
if [ "$password1" != "$password2" ]; then
err "Passwords do not match."
fi
if [ $(egrep "^$username:" $HTPASSWD) ]; then
UPDATE=1
else
UPDATE=0
fi
htpasswd -s -b $HTPASSWD "$username" "$password1" || exit $?
if [ "$UPDATE" -eq 1 ]; then
echo "User password updated"
else
echo "User created"
fi