Browse Source

init script

merge-requests/68/head
Steven Foerster 5 years ago
parent
commit
bb70b94357
  1. 9
      scripts/env/check_env_file.sh
  2. 5
      scripts/services/guacamole/init.sh
  3. 11
      scripts/wrappers/mistborn_docker.sh

9
scripts/env/check_env_file.sh vendored

@ -5,6 +5,8 @@ set -e @@ -5,6 +5,8 @@ set -e
SERVICE="$1"
export MISTBORN_HOME=/opt/mistborn
export SERVICE_ENV_INSTALLER="${MISTBORN_HOME}/scripts/subinstallers/extra/${SERVICE}.sh"
export SERVICE_ENV_FILE="${MISTBORN_HOME}/.envs/.production/.${SERVICE}"
# read in global variables
set -a
@ -14,17 +16,16 @@ source ${MISTBORN_HOME}/.envs/.production/.postgres @@ -14,17 +16,16 @@ source ${MISTBORN_HOME}/.envs/.production/.postgres
source ${MISTBORN_HOME}/.envs/.production/.pihole
set +a
export SERVICE_ENV_INSTALLER="${MISTBORN_HOME}/scripts/subinstallers/extra/${SERVICE}.sh"
export SERVICE_ENV_FILE="${MISTBORN_HOME}/.envs/.production/.${SERVICE}"
if [[ -f "${SERVICE_ENV_INSTALLER}" ]]; then
if [[ -f "${SERVICE_ENV_FILE}" ]]; then
echo "Environment file already exists."
else
echo "Creating environment file"
# create env file for service
echo "Creating environment file"
source $SERVICE_ENV_INSTALLER $SERVICE_ENV_FILE
chmod 600 $SERVICE_ENV_FILE
fi

5
scripts/env/guacamole_init.sh → scripts/services/guacamole/init.sh

@ -1,5 +1,10 @@ @@ -1,5 +1,10 @@
#!/bin/bash
if [[ -f "/opt/mistborn_volumes/extra/guacamole/init/initdb.sql" ]]; then
echo "initdb.sql exists. Proceeding."
exit 0
fi
mkdir -p /opt/mistborn_volumes/extra/guacamole/init/ >/dev/null 2>&1
chmod -R +x /opt/mistborn_volumes/extra/guacamole/init/
docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --postgres > /opt/mistborn_volumes/extra/guacamole/init/initdb.sql

11
scripts/wrappers/mistborn_docker.sh

@ -7,6 +7,7 @@ shift @@ -7,6 +7,7 @@ shift
export MISTBORN_HOME="/opt/mistborn"
export MISTBORN_SERVICE_FILE=${MISTBORN_HOME}/.envs/.production/.${SERVICE}
export MISTBORN_SERVICE_INIT=${MISTBORN_HOME}/scripts/services/${SERVICE}/init.sh
# check and create file if needed
${MISTBORN_HOME}/scripts/env/check_env_file.sh ${SERVICE}
@ -19,8 +20,16 @@ if [[ -f "${MISTBORN_SERVICE_FILE}" ]]; then @@ -19,8 +20,16 @@ if [[ -f "${MISTBORN_SERVICE_FILE}" ]]; then
echo "Loading service variables"
source ${MISTBORN_SERVICE_FILE}
else
echo "No service variables to load"
echo "No service variables to load. Proceeding."
fi
set +a
# init script
if [[ -f "${MISTBORN_SERVICE_INIT}" ]]; then
echo "Running init script"
${MISTBORN_SERVICE_INIT}
else
echo "No init script. Proceeding."
fi
exec "$@"
Loading…
Cancel
Save