Made requested changes by TB
This commit is contained in:
		@@ -1,15 +1,29 @@
 | 
			
		||||
#!/bin/bash -e
 | 
			
		||||
 | 
			
		||||
echo "This script add's a user with password to the bridghead"
 | 
			
		||||
 | 
			
		||||
if [ $# -eq 0 ]; then
 | 
			
		||||
    echo "No arguments provided, please provide the prject name"
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ ! -f /etc/systemd/system/bridgehead@$1.service.d/override.conf ]; then
 | 
			
		||||
    echo "Please create a Service first, with setup-bridgehead-units.sh"
 | 
			
		||||
    exit
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
read -p 'Username: ' bc_user
 | 
			
		||||
read -sp 'Password: ' bc_password
 | 
			
		||||
 | 
			
		||||
echo 
 | 
			
		||||
echo
 | 
			
		||||
 | 
			
		||||
bc=$(docker run --rm -ti xmartlabs/htpasswd $bc_user $bc_password)
 | 
			
		||||
 | 
			
		||||
if [ -z $bc_auth_users ]; then
 | 
			
		||||
    printf "Please run: export bc_auth_users=\"%q\"" $bc
 | 
			
		||||
else
 | 
			
		||||
    echo "Please run: export bc_auth_users=\"${bc},$bc_auth_users\""
 | 
			
		||||
bc=`docker run --rm -it httpd:latest htpasswd -nb $bc_user $bc_password`
 | 
			
		||||
 | 
			
		||||
if grep -q -E "Environment=bc_auth_users=" /etc/systemd/system/bridgehead@$1.service.d/override.conf ; then
 | 
			
		||||
    x=`grep -E "Environment=bc_auth_users=" /etc/systemd/system/bridgehead@$1.service.d/override.conf`
 | 
			
		||||
    sed -i "/Environment=bc_auth_users=/c\\$x,$bc" /etc/systemd/system/bridgehead@$1.service.d/override.conf       
 | 
			
		||||
 | 
			
		||||
else 
 | 
			
		||||
    echo "Environment=bc_auth_users=${bc}" >> /etc/systemd/system/bridgehead@$1.service.d/override.conf
 | 
			
		||||
fi
 | 
			
		||||
@@ -1,6 +1,11 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
### Note: Currently not complete, needs some features before useable for production
 | 
			
		||||
 | 
			
		||||
if [ $# -eq 0 ]; then
 | 
			
		||||
    echo "No arguments provided"
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
source lib/functions.sh
 | 
			
		||||
 | 
			
		||||
if ! lib/prerequisites.sh; then
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user