Added panel fix for usernames and fixed docker-compose for services

This commit is contained in:
root 2023-06-28 15:43:33 +00:00
parent 5f987d4652
commit 4972e74f7c
22 changed files with 99 additions and 78 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
bin/.adminpass
bin/.b2init
bin/.gpg.backblaze
bin/.env
logs/
certs/
apps/

View File

@ -1,23 +1,20 @@
# Domain name
DOMAIN="customer1.federatedcomputer.cloud"
DOMAIN="crudgingtons.net"
# Company name
COMPANY="Customer1 Federated Install"
COMPANY="The Crudgingtons"
# Country Code (US, HK, GB, JP, etc)
COUNTRY="US"
# Where to send welcome e-mail
EMAIL="test@test.org"
# Admin password
ADMINPASS="password123"
# Listmonk password
LISTMONKPASS="password123"
EMAIL="derek@federated.computer"
# Backblaze KeyID (Master Key) for backups
B2_APPLICATION_KEY_ID="3239c6765fdc"
# Backblaze Application Key for backups
B2_APPLICATION_KEY="0050ac8837466cbca0e0aa574b5f8332f706a5e26c"
# Email address for alerts on services that fail to start
ALERTS_EMAIL="derek@federated.computer"

View File

@ -9,8 +9,26 @@ usage() {
exit 2
}
startservice() {
echo "* Starting $SERVICE.."
cd /federated/apps/$SERVICE && docker-compose -f docker-compose.yml -p $SERVICE up -d
. /federated/bin/.env
echo -ne "* Starting $SERVICE.."
if [ "$(docker container inspect -f '{{.State.Status}}' $SERVICE 2>/dev/null)" = "running" ]; then
echo -ne "is already running.\n"
else
if [ -z "$ALERTS_EMAIL" ]; then
cd /federated/apps/$SERVICE && docker-compose -f docker-compose.yml -p $SERVICE up -d &> /dev/null
echo -ne "done.\n"
else
spin &
SPINPID=$!
NC_COMMAND=`grep start_service /federated/lib/$SERVICE.sh | awk -F\" '{ print $4 }'`
start_service_withalert "$SERVICE" "$NC_COMMAND"
kill -9 $SPINPID &> /dev/null
echo -ne "done.\n"
fi
fi
}
startservice_all() {
for i in "${SERVICES[@]}"; do

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -x
. /federated/lib/functions.sh

View File

@ -108,11 +108,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_caddy() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/caddy/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "caddy" "nc -z $SERVICE_IP 80 &> /dev/null"
start_service "caddy" "nc -z 172.99.0.31 80 &> /dev/null"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -64,11 +64,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_collabora() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/collabora/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "collabora" "nc -z $SERVICE_IP 9980 &> /dev/null"
start_service "collabora" "nc -z 172.99.0.17 9980 &> /dev/null"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -129,11 +129,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_element() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/element/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "element" "nc -z $SERVICE_IP 80 &> /dev/null"
start_service "element" "nc -z 172.99.0.20 80 &> /dev/null"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -16,7 +16,7 @@ failcheck() {
}
cleanup() {
kill -9 $SPINPID &> /dev/null
exit 2
exit 2;
}
spin() {
spinner="/|\\-/|\\-"
@ -157,6 +157,58 @@ start_service_upgrade() {
done
fi
}
start_service_withalert() {
SERVICE="$1"
COMMAND="$2"
# Start /federated/apps/SERVICE with output to /dev/null
# echo -ne "\n* Starting /federated/apps/$SERVICE service.."
# spin &
# SPINPID=$!
docker-compose -f /federated/apps/$SERVICE/docker-compose.yml -p $SERVICE up -d &> /dev/null
# Keep trying service port to make sure it's up before
# we proceed
RETRY="4"
while [ $RETRY -gt 0 ]; do
bash -c "eval $COMMAND" &> /dev/null
if [ $? -eq 0 ]; then
break
else
if [ "$RETRY" == 1 ]; then
EXTERNALIP=`dig @resolver4.opendns.com myip.opendns.com +short 2> /dev/null`
docker-compose -f /federated/apps/$SERVICE/docker-compose.yml -p $SERVICE down &> /dev/null
echo "Generated by /federated/bin/start" > /federated/apps/mail/data/root/certs/mailfile
docker exec mail bash -c "mail -r admin@$DOMAIN -a \"Content-type: text/html\" -s \"$SERVICE failed to start on $EXTERNALIP\" $ALERTS_EMAIL < /root/certs/mailfile"
fail "There was a problem starting service /federated/apps/$SERVICE\nCheck the output of 'docker logs $SERVICE' or turn on\ndebug with -d"
fi
((RETRY--))
sleep 7
fi
done
}
start_service_upgrade() {
SERVICE="$1"
# Keep trying service port to make sure it's up before
# we proceed
RETRY="30"
while [ $RETRY -gt 0 ]; do
bash -c "$COMMAND" &> /dev/null
if [ $? -eq 0 ]; then
break
else
if [ "$RETRY" == 1 ]; then
docker-compose -f /federated/apps/$SERVICE/docker-compose.yml -p $SERVICE down &> /dev/null
kill -9 $SPINPID &> /dev/null
fail "There was a problem starting service /federated/apps/$SERVICE\nCheck the output of 'docker logs $SERVICE' or turn on\ndebug with -d"
fi
((RETRY--))
sleep 7
fi
done
}
start_service() {
SERVICE="$1"
COMMAND="$2"

View File

@ -158,11 +158,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_gitea() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/gitea/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "gitea" "nc -z $SERVICE_IP 3000 &> /dev/null"
start_service "gitea" "nc -z 172.99.0.30 3000 &> /dev/null"
# Copy creategitea.sh inside gitea container
mv /federated/apps/gitea/data/creategitea.sh /federated/apps/gitea/data/data/creategitea.sh

View File

@ -16,4 +16,4 @@ matrix=v1.85.2
mail=12.1
ldap=1.5.0
wireguard=1.0.20210914
gitea=1.19.0
gitea=1.20.0-rc1

View File

@ -158,11 +158,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_ldap() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/ldap/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "ldap" "nc -z $SERVICE_IP 636 &> /dev/null"
start_service "ldap" "nc -z 172.99.0.15 636 &> /dev/null"
# Run our ldap.sh script inside the ldap container
# This imports the inital LDAP configuration

View File

@ -80,11 +80,8 @@ start_listmonk() {
docker exec postgresql psql -U listmonk -c "update settings set value='\"listmonk <listmonk@listmonk.$DOMAIN>\"' where key='app.from_email'" &> /dev/null
docker exec postgresql psql -U listmonk -c "update settings set value='[{\"host\": \"mail.$DOMAIN\", \"port\": 587, \"enabled\": true, \"password\": \"$ADMINPASS\", \"tls_type\": \"STARTTLS\", \"username\": \"admin\", \"max_conns\": 10, \"idle_timeout\": \"15s\", \"wait_timeout\": \"5s\", \"auth_protocol\": \"login\", \"email_headers\": [], \"hello_hostname\": \"\", \"max_msg_retries\": 2, \"tls_skip_verify\": false}, {\"host\": \"smtp.gmail.com\", \"port\": 465, \"enabled\": false, \"password\": \"password\", \"tls_type\": \"TLS\", \"username\": \"username@gmail.com\", \"max_conns\": 10, \"idle_timeout\": \"15s\", \"wait_timeout\": \"5s\", \"auth_protocol\": \"login\", \"email_headers\": [], \"hello_hostname\": \"\", \"max_msg_retries\": 2, \"tls_skip_verify\": false}]' where key='smtp';" &> /dev/null
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/listmonk/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "listmonk" "nc -z $SERVICE_IP 9000 &> /dev/null"
start_service "listmonk" "nc -z 172.99.0.21 9000 &> /dev/null"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -153,11 +153,8 @@ EOF
echo -ne "done."
}
start_mail() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/mail/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "mail" "nc -z $SERVICE_IP 25 &> /dev/null"
start_service "mail" "nc -z 172.99.0.16 25 &> /dev/null"
# Generate the DKIM DNS key and setup
docker exec mail setup config dkim

View File

@ -107,11 +107,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_matrix() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/matrix/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "matrix" "nc -z $SERVICE_IP 8008 &> /dev/null"
start_service "matrix" "nc -z 172.99.0.19 8008 &> /dev/null"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -249,11 +249,8 @@ chmod +x /federated/apps/nextcloud/data/config.sh
}
start_nextcloud() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/nextcloud/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "nextcloud" "nc -z $SERVICE_IP 80 &> /dev/null"
start_service "nextcloud" "nc -z 172.99.0.18 80 &> /dev/null"
# Move config.sh and sidemenu config, set config.sh executable
mv /federated/apps/nextcloud/data/config.sh /federated/apps/nextcloud/data/configs.json /federated/apps/nextcloud/data/var/www/html/

View File

@ -53,6 +53,7 @@ LDAP_ADMIN_BIND_PWD=$LDAP_SECRET
LDAP_ACCOUNT_ADDITIONAL_OBJECTCLASSES=PostfixBookMailAccount
LDAP_ACCOUNT_ADDITIONAL_ATTRIBUTES=mailEnabled:Mail Enabled:TRUE,mailAlias+:Email aliases
EMAIL_DOMAIN=$DOMAIN
ENFORCE_SAFE_SYSTEM_NAMES=false
USERNAME_FORMAT={first_name}.{last_name}
SITE_NAME=$COMPANY User Manager
SMTP_HOSTNAME=mail.$DOMAIN
@ -68,11 +69,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_panel() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/panel/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "panel" "nc -z $SERVICE_IP 80 &> /dev/null"
start_service "panel" "nc -z 172.99.0.23 80 &> /dev/null"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -99,11 +99,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_pdns() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/pdns/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "pdns" "nc -z ${SERVICE_IP} 8081 &> /dev/null"
start_service "pdns" "nc -z 172.99.0.11 8081 &> /dev/null"
# Create DNS records for newdomain
# docker exec pdns pdnsutil create-zone $DOMAIN

View File

@ -93,11 +93,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_pdnsadmin() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/pdnsadmin/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "pdnsadmin" "nc -z ${SERVICE_IP} 9494 &> /dev/null"
start_service "pdnsadmin" "nc -z 172.99.0.12 9494 &> /dev/null"
# Run MySQL command to create admin user for pdns admin interface
docker exec pdnsmysql bash -c "mysql -updns -p$MYSQL_PASSWORD pdns -e '$PDNS_MYSQL_COMMAND;'"

View File

@ -52,11 +52,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_pdnsmysql() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/pdnsmysql/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "pdnsmysql" "nc -z ${SERVICE_IP} 3306 &> /dev/null"
start_service "pdnsmysql" "nc -z 172.99.0.10 3306 &> /dev/null"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -102,11 +102,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_postgresql() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/postgresql/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "postgresql" "nc -z ${SERVICE_IP} 5432 &> /dev/null"
start_service "postgresql" "nc -z 172.99.0.14 5432 &> /dev/null"
# Tune PostgreSQL
sed -i "s#shared_buffers =.*#shared_buffers = 800MB#g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf

View File

@ -61,11 +61,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_vaultwarden() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/vaultwarden/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "vaultwarden" "nc -z $SERVICE_IP 80 &> /dev/null"
start_service "vaultwarden" "nc -z 172.99.0.22 80 &> /dev/null"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -83,11 +83,8 @@ echo -ne "done."
}
start_wireguard() {
# Grab the container IP from docker-compose above
SERVICE_IP=`grep ipv4_address /federated/apps/wireguard/docker-compose.yml | awk '{ print $2 }'`
# Start service with command to make sure it's up before proceeding
start_service "wireguard" "nc -uvz $SERVICE_IP 51820 &> /dev/null"
start_service "wireguard" "nc -uvz 172.99.0.24 51820 &> /dev/null"
kill -9 $SPINPID &> /dev/null
echo -ne "done."