bridgehead/lib/prerequisites.sh

70 lines
1.6 KiB
Bash
Raw Normal View History

2021-12-21 13:48:28 +01:00
#!/bin/bash
2022-05-09 13:44:36 +02:00
source lib/functions.sh
2021-12-21 13:48:28 +01:00
## Check if user is a su
2022-05-09 12:57:24 +02:00
log "Welcome to the starting a bridgehead. We will get your instance up and running in no time"
log "First we will check if all prerequisites are met ..."
2022-04-08 08:43:42 +02:00
prerequisites="git docker docker-compose"
2021-12-21 13:48:28 +01:00
for prerequisite in $prerequisites; do
$prerequisite --version 2>&1
is_available=$?
if [ $is_available -gt 0 ]; then
log "ERROR" "Prerequisite not fulfilled - $prerequisite is not available!"
exit 79
fi
# TODO: Check for specific version
done
2022-05-09 12:57:24 +02:00
log "Checking /etc/bridgehead/"
2022-05-03 09:16:19 +02:00
## Download submodule
2022-05-04 13:50:33 +02:00
if [ ! -d "/etc/bridgehead/" ]; then
2022-05-09 12:57:24 +02:00
log "Please set up the config folder. Instruction are in the readme."
2022-05-03 09:16:19 +02:00
exit 1
else
2022-05-09 12:57:24 +02:00
log "Done"
2022-05-03 09:16:19 +02:00
fi
2022-05-09 12:57:24 +02:00
log "Checking /etc/bridgehead/site.conf"
2021-12-21 13:48:28 +01:00
#check if site.conf is created
2022-05-04 13:50:33 +02:00
if [ ! -f /etc/bridgehead/site.conf ]; then
2022-05-09 12:57:24 +02:00
log "Please create your specific site.conf file from the site.dev.conf"
2022-05-03 09:16:19 +02:00
exit 1
else
2022-05-09 12:57:24 +02:00
log "Done"
2021-12-21 13:48:28 +01:00
fi
#Load site specific variables
2022-05-04 13:50:33 +02:00
source /etc/bridgehead/site.conf
2021-12-21 13:48:28 +01:00
if [ -z "$site_name" ]; then
2022-05-09 12:57:24 +02:00
log "Please set site_name"
2022-05-03 09:16:19 +02:00
exit 1
2021-12-21 13:48:28 +01:00
fi
2022-05-09 12:57:24 +02:00
log "Checking project config"
2021-12-21 13:48:28 +01:00
#check if project env is present
2022-05-04 13:50:33 +02:00
if [ -d "/etc/bridgehead/${project}.env" ]; then
2022-05-09 12:57:24 +02:00
log "Please copy the tempalte from ${project} and put it in the /etc/bridgehead-config/ folder"
2022-05-03 09:16:19 +02:00
exit 1
else
2022-05-09 12:57:24 +02:00
log "Done"
2021-12-21 13:48:28 +01:00
fi
2022-05-09 12:57:24 +02:00
log "Checking ssl cert"
## Create SSL Cert
if [ ! -d "/certs" ]; then
2022-05-09 12:57:24 +02:00
log "SSL cert missing, now we create one. Please consider getting a signed one"
mkdir certs
fi
2022-05-09 12:57:24 +02:00
if [ -d "certs/traefik.crt" ]; then
openssl req -x509 -newkey rsa:4096 -nodes -keyout certs/traefik.key -out certs/traefik.crt -days 365
fi
2022-05-09 12:57:24 +02:00
log "All prerequisites are met!"