Modified start_service to use timeouts and start script with alert

This commit is contained in:
root 2023-06-28 15:52:19 +00:00
parent 4972e74f7c
commit 4953c508a4
21 changed files with 24 additions and 28 deletions

View File

@ -23,7 +23,8 @@ startservice() {
SPINPID=$!
NC_COMMAND=`grep start_service /federated/lib/$SERVICE.sh | awk -F\" '{ print $4 }'`
start_service_withalert "$SERVICE" "$NC_COMMAND"
RETRY=`grep start_service /federated/lib/caddy.sh | awk -F\" '{ print $6 }'`
start_service_withalert "$SERVICE" "$NC_COMMAND" "$RETRY"
kill -9 $SPINPID &> /dev/null
echo -ne "done.\n"

View File

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

View File

@ -82,7 +82,7 @@ echo -ne "done."
start_baserow() {
# Start service with command to make sure it's up before proceeding
start_service "baserow" "docker exec baserow curl http://localhost:8000 &> /dev/null"
start_service "baserow" "docker exec baserow curl http://localhost:8000 &> /dev/null" "7"
# Move createuser.sh and set it executable
mv /federated/apps/baserow/data/createuser.sh /federated/apps/baserow/data/baserow/data/

View File

@ -108,8 +108,8 @@ kill -9 $SPINPID &> /dev/null
echo -ne "done."
}
start_caddy() {
# Start service with command to make sure it's up before proceeding
start_service "caddy" "nc -z 172.99.0.31 80 &> /dev/null"
# Start service with command and retry amount to make sure it's up before proceeding
start_service "caddy" "nc -z 172.99.0.31 80 &> /dev/null" "7"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -65,7 +65,7 @@ echo -ne "done."
}
start_collabora() {
# Start service with command to make sure it's up before proceeding
start_service "collabora" "nc -z 172.99.0.17 9980 &> /dev/null"
start_service "collabora" "nc -z 172.99.0.17 9980 &> /dev/null" "7"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -130,7 +130,7 @@ echo -ne "done."
}
start_element() {
# Start service with command to make sure it's up before proceeding
start_service "element" "nc -z 172.99.0.20 80 &> /dev/null"
start_service "element" "nc -z 172.99.0.20 80 &> /dev/null" "7"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -160,17 +160,12 @@ start_service_upgrade() {
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=$!
RETRY="$3"
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
@ -212,6 +207,7 @@ start_service_upgrade() {
start_service() {
SERVICE="$1"
COMMAND="$2"
RETRY="$3"
# Start /federated/apps/SERVICE with output to /dev/null
echo -ne "\n* Starting /federated/apps/$SERVICE service.."
@ -227,7 +223,6 @@ start_service() {
# 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

View File

@ -159,7 +159,7 @@ echo -ne "done."
}
start_gitea() {
# Start service with command to make sure it's up before proceeding
start_service "gitea" "nc -z 172.99.0.30 3000 &> /dev/null"
start_service "gitea" "nc -z 172.99.0.30 3000 &> /dev/null" "7"
# Copy creategitea.sh inside gitea container
mv /federated/apps/gitea/data/creategitea.sh /federated/apps/gitea/data/data/creategitea.sh

View File

@ -614,7 +614,7 @@ echo -ne "done."
start_jitsi() {
# Start service with command to make sure it's up before proceeding
start_service "jitsi" "nc -z 172.99.0.25 443 &> /dev/null"
start_service "jitsi" "nc -z 172.99.0.25 443 &> /dev/null" "8"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -159,7 +159,7 @@ echo -ne "done."
}
start_ldap() {
# Start service with command to make sure it's up before proceeding
start_service "ldap" "nc -z 172.99.0.15 636 &> /dev/null"
start_service "ldap" "nc -z 172.99.0.15 636 &> /dev/null" "40"
# Run our ldap.sh script inside the ldap container
# This imports the inital LDAP configuration

View File

@ -81,7 +81,7 @@ start_listmonk() {
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
# Start service with command to make sure it's up before proceeding
start_service "listmonk" "nc -z 172.99.0.21 9000 &> /dev/null"
start_service "listmonk" "nc -z 172.99.0.21 9000 &> /dev/null" "8"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -154,7 +154,7 @@ EOF
}
start_mail() {
# Start service with command to make sure it's up before proceeding
start_service "mail" "nc -z 172.99.0.16 25 &> /dev/null"
start_service "mail" "nc -z 172.99.0.16 25 &> /dev/null" "9"
# Generate the DKIM DNS key and setup
docker exec mail setup config dkim

View File

@ -108,7 +108,7 @@ echo -ne "done."
}
start_matrix() {
# Start service with command to make sure it's up before proceeding
start_service "matrix" "nc -z 172.99.0.19 8008 &> /dev/null"
start_service "matrix" "nc -z 172.99.0.19 8008 &> /dev/null" "8"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -250,7 +250,7 @@ chmod +x /federated/apps/nextcloud/data/config.sh
start_nextcloud() {
# Start service with command to make sure it's up before proceeding
start_service "nextcloud" "nc -z 172.99.0.18 80 &> /dev/null"
start_service "nextcloud" "nc -z 172.99.0.18 80 &> /dev/null" "35"
# 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

@ -70,7 +70,7 @@ echo -ne "done."
}
start_panel() {
# Start service with command to make sure it's up before proceeding
start_service "panel" "nc -z 172.99.0.23 80 &> /dev/null"
start_service "panel" "nc -z 172.99.0.23 80 &> /dev/null" "7"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -100,7 +100,7 @@ echo -ne "done."
}
start_pdns() {
# Start service with command to make sure it's up before proceeding
start_service "pdns" "nc -z 172.99.0.11 8081 &> /dev/null"
start_service "pdns" "nc -z 172.99.0.11 8081 &> /dev/null" "7"
# Create DNS records for newdomain
# docker exec pdns pdnsutil create-zone $DOMAIN

View File

@ -94,7 +94,7 @@ echo -ne "done."
}
start_pdnsadmin() {
# Start service with command to make sure it's up before proceeding
start_service "pdnsadmin" "nc -z 172.99.0.12 9494 &> /dev/null"
start_service "pdnsadmin" "nc -z 172.99.0.12 9494 &> /dev/null" "8"
# 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

@ -53,7 +53,7 @@ echo -ne "done."
}
start_pdnsmysql() {
# Start service with command to make sure it's up before proceeding
start_service "pdnsmysql" "nc -z 172.99.0.10 3306 &> /dev/null"
start_service "pdnsmysql" "nc -z 172.99.0.10 3306 &> /dev/null" "8"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -103,7 +103,7 @@ echo -ne "done."
}
start_postgresql() {
# Start service with command to make sure it's up before proceeding
start_service "postgresql" "nc -z 172.99.0.14 5432 &> /dev/null"
start_service "postgresql" "nc -z 172.99.0.14 5432 &> /dev/null" "8"
# Tune PostgreSQL
sed -i "s#shared_buffers =.*#shared_buffers = 800MB#g" /federated/apps/postgresql/data/var/lib/postgresql/data/postgresql.conf

View File

@ -62,7 +62,7 @@ echo -ne "done."
}
start_vaultwarden() {
# Start service with command to make sure it's up before proceeding
start_service "vaultwarden" "nc -z 172.99.0.22 80 &> /dev/null"
start_service "vaultwarden" "nc -z 172.99.0.22 80 &> /dev/null" "8"
kill -9 $SPINPID &> /dev/null
echo -ne "done."

View File

@ -84,7 +84,7 @@ echo -ne "done."
start_wireguard() {
# Start service with command to make sure it's up before proceeding
start_service "wireguard" "nc -uvz 172.99.0.24 51820 &> /dev/null"
start_service "wireguard" "nc -uvz 172.99.0.24 51820 &> /dev/null" "8"
kill -9 $SPINPID &> /dev/null
echo -ne "done."