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
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
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
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 "Please run: export bc_auth_users=\"${bc},$bc_auth_users\""
echo "Environment=bc_auth_users=${bc}" >> /etc/systemd/system/bridgehead@$1.service.d/override.conf
fi

View File

@ -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