Changed add_authelia_config_to_dockercompose able to pass in second variable as ip

This commit is contained in:
root 2025-01-22 16:29:39 +00:00
parent fde50bcee7
commit d1797b8242
10 changed files with 11 additions and 19 deletions

View File

@ -208,8 +208,7 @@ start_authelia() {
[ $? -ne 0 ] && fail "Couldn't add dns record for authelia" [ $? -ne 0 ] && fail "Couldn't add dns record for authelia"
# If extra_hosts doesn't exist then insert extra_host configuration in pdnsadmin docker compose # If extra_hosts doesn't exist then insert extra_host configuration in pdnsadmin docker compose
add_authelia_config_to_dockercompose "pdnsadmin" add_authelia_config_to_dockercompose "pdnsadmin" "$EXTERNALIP"
# [[ ! $(grep extra_hosts /federated/apps/pdnsadmin/docker-compose.yml 2>/dev/null) ]] && sed -i "/192.168.0.12/a \ extra_hosts:\n\ - \"authelia.$DOMAIN:$EXTERNALIP\"" /federated/apps/pdnsadmin/docker-compose.yml
# Stop and start pdnsadmin for internal dns externalhosts to work # Stop and start pdnsadmin for internal dns externalhosts to work
/federated/bin/stop pdnsadmin &> /dev/null /federated/bin/stop pdnsadmin &> /dev/null

View File

@ -13,7 +13,6 @@ config_bookstack() {
fi fi
cat > /federated/apps/bookstack/docker-compose.yml <<EOF cat > /federated/apps/bookstack/docker-compose.yml <<EOF
version: "3.7"
services: services:
bookstack: bookstack:
image: lscr.io/linuxserver/bookstack:\${IMAGE_VERSION} image: lscr.io/linuxserver/bookstack:\${IMAGE_VERSION}
@ -246,7 +245,7 @@ OIDC_END_SESSION_ENDPOINT=https://authelia.$DOMAIN/logout?rd=https://dashboard.$
EOF EOF
# Add in extra hosts config # Add in extra hosts config
add_authelia_config_to_dockercompose "bookstack" add_authelia_config_to_dockercompose "bookstack" "$EXTERNALIP"
# Setup external_auth_id for each user in bookstack users table # Setup external_auth_id for each user in bookstack users table
BOOKSTACK_SECRET=$(cat /federated/apps/bookstack/.env | grep "DB_PASS" | awk -F= '{ print $2 }') BOOKSTACK_SECRET=$(cat /federated/apps/bookstack/.env | grep "DB_PASS" | awk -F= '{ print $2 }')

View File

@ -13,8 +13,6 @@ config_espocrm() {
fi fi
cat > /federated/apps/espocrm/docker-compose.yml <<EOF cat > /federated/apps/espocrm/docker-compose.yml <<EOF
version: '3.7'
services: services:
espocrm: espocrm:
image: espocrm/espocrm:\${IMAGE_VERSION} image: espocrm/espocrm:\${IMAGE_VERSION}
@ -263,7 +261,7 @@ EOF
sed -i "/authenticationMethod/a \ 'oidcScopes' => [\n\ 0 => 'profile',\n\ 1 => 'email',\n\ 2 => 'groups',\n\ 3 => 'openid'\n\ ]," /federated/apps/espocrm/data/var/www/html/data/config.php sed -i "/authenticationMethod/a \ 'oidcScopes' => [\n\ 0 => 'profile',\n\ 1 => 'email',\n\ 2 => 'groups',\n\ 3 => 'openid'\n\ ]," /federated/apps/espocrm/data/var/www/html/data/config.php
# Add in extra_hosts to docker-compose # Add in extra_hosts to docker-compose
add_authelia_config_to_dockercompose "espocrm" add_authelia_config_to_dockercompose "espocrm" "$EXTERNALIP"
# Set auth method to Oidc only # Set auth method to Oidc only
sed -i "s/ESPOCRM_CONFIG_AUTHENTICATION_METHOD=LDAP/#ESPOCRM_CONFIG_AUTHENTICATION_METHOD=LDAP/g" /federated/apps/espocrm/.env sed -i "s/ESPOCRM_CONFIG_AUTHENTICATION_METHOD=LDAP/#ESPOCRM_CONFIG_AUTHENTICATION_METHOD=LDAP/g" /federated/apps/espocrm/.env

View File

@ -1803,9 +1803,9 @@ run_finishtasks() {
add_authelia_config_to_dockercompose() { add_authelia_config_to_dockercompose() {
if [[ ! $(grep authelia /federated/apps/$1/docker-compose.yml) ]]; then if [[ ! $(grep authelia /federated/apps/$1/docker-compose.yml) ]]; then
if [[ $(grep extra_hosts /federated/apps/$1/docker-compose.yml) ]]; then if [[ $(grep extra_hosts /federated/apps/$1/docker-compose.yml) ]]; then
sed -i "/extra_hosts/a \ - \"authelia.$DOMAIN:$EXTERNALIP\"" /federated/apps/$1/docker-compose.yml sed -i "/extra_hosts/a \ - \"authelia.$DOMAIN:$2\"" /federated/apps/$1/docker-compose.yml
else else
sed -i "/restart: always/a \ extra_hosts:\n\ - \"authelia.$DOMAIN:$EXTERNALIP\"" /federated/apps/$1/docker-compose.yml sed -i "/restart: always/a \ extra_hosts:\n\ - \"authelia.$DOMAIN:$2\"" /federated/apps/$1/docker-compose.yml
fi fi
fi fi
} }

View File

@ -361,7 +361,7 @@ EOF
run_command "/federated/bin/start authelia" run_command "/federated/bin/start authelia"
# Add in extra hosts config # Add in extra hosts config
add_authelia_config_to_dockercompose "gitea" add_authelia_config_to_dockercompose "gitea" "$EXTERNALIP"
run_command "/federated/bin/stop gitea" run_command "/federated/bin/stop gitea"
run_command "/federated/bin/start gitea" run_command "/federated/bin/start gitea"

View File

@ -21,8 +21,6 @@ config_mail() {
fi fi
cat > /federated/apps/mail/docker-compose.yml <<EOF cat > /federated/apps/mail/docker-compose.yml <<EOF
version: '3.7'
services: services:
mail: mail:
image: docker.io/mailserver/docker-mailserver:\${IMAGE_VERSION} image: docker.io/mailserver/docker-mailserver:\${IMAGE_VERSION}

View File

@ -277,7 +277,7 @@ EOF
run_command "/federated/bin/stop authelia" run_command "/federated/bin/stop authelia"
run_command "/federated/bin/start authelia" run_command "/federated/bin/start authelia"
add_authelia_config_to_dockercompose "matrix" add_authelia_config_to_dockercompose "matrix" "$EXTERNALIP"
cat >> /federated/apps/matrix/data/matrix/homeserver.yaml <<EOF cat >> /federated/apps/matrix/data/matrix/homeserver.yaml <<EOF
oidc_providers: oidc_providers:

View File

@ -321,7 +321,7 @@ cat >> /federated/apps/authelia/data/config/idproviders.yml <<EOF
token_endpoint_auth_method: 'client_secret_post' token_endpoint_auth_method: 'client_secret_post'
EOF EOF
add_authelia_config_to_dockercompose "nextcloud" add_authelia_config_to_dockercompose "nextcloud" "$EXTERNALIP"
# Restart Authelia for changes to take the above configuration # Restart Authelia for changes to take the above configuration
run_command "/federated/bin/stop authelia" run_command "/federated/bin/stop authelia"

View File

@ -170,8 +170,8 @@ EOF
run_command "/federated/bin/start authelia" run_command "/federated/bin/start authelia"
# Add in extra hosts config # Add in extra hosts config
add_authelia_config_to_dockercompose "roundcube" add_authelia_config_to_dockercompose "roundcube" "$EXTERNALIP"
add_authelia_config_to_dockercompose "mail" add_authelia_config_to_dockercompose "mail" "$EXTERNALIP"
sed -i "/?php/a \ \$config['oauth_provider'] = 'generic'; \n\ sed -i "/?php/a \ \$config['oauth_provider'] = 'generic'; \n\
\$config['oauth_provider_name'] = 'Authelia'; \n\ \$config['oauth_provider_name'] = 'Authelia'; \n\

View File

@ -16,8 +16,6 @@ config_wordpress() {
WORDPRESS_SECRET=$(create_password); WORDPRESS_SECRET=$(create_password);
cat > /federated/apps/wordpress/docker-compose.yml <<EOF cat > /federated/apps/wordpress/docker-compose.yml <<EOF
version: "3.7"
services: services:
wordpress: wordpress:
image: bitnami/wordpress:\${IMAGE_VERSION} image: bitnami/wordpress:\${IMAGE_VERSION}
@ -238,7 +236,7 @@ EOF
run_command "/federated/bin/stop authelia" run_command "/federated/bin/stop authelia"
run_command "/federated/bin/start authelia" run_command "/federated/bin/start authelia"
add_authelia_config_to_dockercompose "wordpress" add_authelia_config_to_dockercompose "wordpress" "$EXTERNALIP"
sed -i "/Add any custom values/a \ sed -i "/Add any custom values/a \
define( 'OIDC_CLIENT_ID', 'wordpress' );\n\ define( 'OIDC_CLIENT_ID', 'wordpress' );\n\