#! /bin/bash USERNAME=$1 SCRIPT_USER=$USER USER_HOME=$HOME # Make sure a user is supplied if [[ -z "$USER" ]]; then echo "Username is required" echo "./add_user.sh " exit fi # Get password inputs read -sp "Enter the account password: " PASS echo "" read -sp "Enter the password again: " PASS2 echo "" # Make sure passwords match if [ "$PASS" != "$PASS2" ]; then echo "Passwords do not match" exit fi # Make sure the auth folder exists mkdir -p ~/deployment/data/reg_auth # Add the new user and password to the registry (using docker to avoid dependencies) # Then if docker doesn't crash, print a msg to stdout for the end user sudo docker run --rm \ --entrypoint htpasswd \ httpd:2 -Bbn $USERNAME $PASS >> $USER_HOME/deployment/data/reg_auth/htpassword && \ echo "Made user $USERNAME"