Remove the pre-ansible script for service creation
This commit is contained in:
parent
3f2e60becf
commit
c1ec46aed5
2 changed files with 0 additions and 89 deletions
|
@ -1,89 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Get variables for docker-compose
|
|
||||||
read -rp "Enter the service name: " NAME
|
|
||||||
read -rp "Enter the service image: " IMAGE
|
|
||||||
read -rp "Enable watchtower? (y/N): " WATCHTOWER
|
|
||||||
|
|
||||||
# Get variables for env files
|
|
||||||
read -rp "Create .env file? (y/N): " CREATE_ENV
|
|
||||||
read -rp "Create .secret.env file? (y/N): " CREATE_SECRET_ENV
|
|
||||||
|
|
||||||
# Get variables for caddy
|
|
||||||
read -rp "Enter the service domain: " DOMAIN
|
|
||||||
read -rp "Enter the service port: " PORT
|
|
||||||
read -rp "Enter the target host: " HOST
|
|
||||||
|
|
||||||
mkdir -p "${NAME}"
|
|
||||||
|
|
||||||
|
|
||||||
parse_yn_bool() {
|
|
||||||
bool_lower=$(echo "${1}" | tr '[:upper:]' '[:lower:]')
|
|
||||||
# Map y/yes to true, otherwise false
|
|
||||||
if [ "${bool_lower}" == "y" ] || [ "${bool_lower}" == "yes" ]; then
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
parse_yn_str() {
|
|
||||||
if parse_yn_bool "${1}"; then
|
|
||||||
echo "true"
|
|
||||||
else
|
|
||||||
echo "false"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create the env files
|
|
||||||
YAML_ENV=""
|
|
||||||
if parse_yn_bool "${CREATE_ENV}" || parse_yn_bool "${CREATE_SECRET_ENV}"; then
|
|
||||||
YAML_ENV="
|
|
||||||
env_file:"
|
|
||||||
fi
|
|
||||||
if parse_yn_bool "${CREATE_ENV}"; then
|
|
||||||
YAML_ENV="${YAML_ENV}
|
|
||||||
- .env"
|
|
||||||
touch "${NAME}/.env"
|
|
||||||
fi
|
|
||||||
if parse_yn_bool "${CREATE_SECRET_ENV}"; then
|
|
||||||
YAML_ENV="${YAML_ENV}
|
|
||||||
- .secret.env"
|
|
||||||
touch "${NAME}/.secret.env"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Create the docker-compose file
|
|
||||||
cat <<EOF > "${NAME}/docker-compose.yml"
|
|
||||||
version: '3'
|
|
||||||
services:
|
|
||||||
app:
|
|
||||||
image: ${IMAGE}
|
|
||||||
restart: always${YAML_ENV}
|
|
||||||
labels:
|
|
||||||
com.centurylinklabs.watchtower.enable: $(parse_yn_str "${WATCHTOWER}")
|
|
||||||
networks:
|
|
||||||
apps:
|
|
||||||
aliases:
|
|
||||||
- ${NAME}
|
|
||||||
networks:
|
|
||||||
apps:
|
|
||||||
external: true
|
|
||||||
EOF
|
|
||||||
|
|
||||||
caddy_path="caddy/config/conf.${HOST}.d"
|
|
||||||
if [ ! -d "${caddy_path}" ]; then
|
|
||||||
echo "Caddy config directory for host '${HOST}' not found, trying default"
|
|
||||||
caddy_path="caddy/config/conf.d"
|
|
||||||
fi
|
|
||||||
if [ -d "${caddy_path}" ]; then
|
|
||||||
cat <<EOF > "$caddy_path/${DOMAIN}.conf"
|
|
||||||
${DOMAIN} {
|
|
||||||
import default
|
|
||||||
reverse_proxy ${NAME}:${PORT}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
else
|
|
||||||
echo "Caddy config directory not found, skipping caddy config"
|
|
||||||
fi
|
|
0
_utils/postgres-update.sh
Normal file → Executable file
0
_utils/postgres-update.sh
Normal file → Executable file
Reference in a new issue