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

30 lines
452 B

10 years ago
#!/bin/sh
HTPASSWD=htpasswd
10 years ago
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
10 years ago
UPDATE=1
else
UPDATE=0
fi
htpasswd -s -b $HTPASSWD "$username" "$password1" || exit $?
10 years ago
if [ "$UPDATE" -eq 1 ]; then
echo "User password updated"
else
echo "User created"
fi