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
448 B

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