Made requested changes by TB

This commit is contained in:
root 2022-04-11 15:28:11 +02:00
parent a3f9dc64b7
commit fe0e1ce5d2
2 changed files with 25 additions and 6 deletions

View File

@ -1,15 +1,29 @@
#!/bin/bash -e #!/bin/bash -e
echo "This script add's a user with password to the bridghead" 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 -p 'Username: ' bc_user
read -sp 'Password: ' bc_password read -sp 'Password: ' bc_password
echo echo
bc=$(docker run --rm -ti xmartlabs/htpasswd $bc_user $bc_password)
if [ -z $bc_auth_users ]; then bc=`docker run --rm -it httpd:latest htpasswd -nb $bc_user $bc_password`
printf "Please run: export bc_auth_users=\"%q\"" $bc
else if grep -q -E "Environment=bc_auth_users=" /etc/systemd/system/bridgehead@$1.service.d/override.conf ; then
echo "Please run: export bc_auth_users=\"${bc},$bc_auth_users\"" 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 fi

View File

@ -1,6 +1,11 @@
#!/bin/bash #!/bin/bash
### Note: Currently not complete, needs some features before useable for production ### 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 source lib/functions.sh
if ! lib/prerequisites.sh; then if ! lib/prerequisites.sh; then