From b8004870dcb9b8dccf9c4cbd723ea9c9a71613f4 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Tue, 29 Mar 2022 21:26:52 +0200 Subject: [PATCH] Apps config --- apps/wg-easy/docker-compose.yml | 2 +- scripts/configure.sh | 7 +++++++ scripts/start.sh | 26 +++++++++++++++++++++++++- state/apps.json | 3 +++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 state/apps.json diff --git a/apps/wg-easy/docker-compose.yml b/apps/wg-easy/docker-compose.yml index 029cbd8b..ec79150f 100644 --- a/apps/wg-easy/docker-compose.yml +++ b/apps/wg-easy/docker-compose.yml @@ -5,7 +5,7 @@ services: image: 'weejewel/wg-easy' restart: unless-stopped volumes: - - ${PWD}/wg-easy:/etc/wireguard + - ${DATA_FOLDER}/wg-easy:/etc/wireguard environment: WG_HOST: 'wireguard.meienberger.dev' PASSWORD: 'moneyprintergobrrr' diff --git a/scripts/configure.sh b/scripts/configure.sh index 3d0747ad..5343057e 100755 --- a/scripts/configure.sh +++ b/scripts/configure.sh @@ -22,6 +22,13 @@ ENV_FILE="./templates/.env" [[ -f "./templates/.env-sample" ]] && cp "./templates/.env-sample" "$ENV_FILE" [[ -f "./templates/ansible-hosts-sample.cfg" ]] && cp "./templates/ansible-hosts-sample.cfg" "$ANSIBLE_HOSTS_FILE" +# Install jq if not installed +if ! command -v jq > /dev/null; then + echo "Installing jq..." + apt-get update + apt-get install -y jq +fi + # Install ansible if not installed if ! command -v ansible > /dev/null; then echo "Installing Ansible..." diff --git a/scripts/start.sh b/scripts/start.sh index 1fea30df..ce74c301 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -1,3 +1,6 @@ +ROOT_FOLDER="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)" +STATE_FOLDER="${ROOT_FOLDER}/state" + if [[ $UID != 0 ]]; then echo "Tipi must be started as root" echo "Please re-run this script as" @@ -5,4 +8,25 @@ if [[ $UID != 0 ]]; then exit 1 fi -# run docker-compose \ No newline at end of file +# Run docker-compose +# docker-compose up -d + +# Get field from json file +function get_json_field() { + local json_file="$1" + local field="$2" + + echo $(jq -r ".${field}" "${json_file}") +} + +str=$(get_json_field ${STATE_FOLDER}/apps.json installed) +apps_to_start=($str) + +for app in "${apps_to_start[@]}"; do + echo "Starting app: $app" + + # App data folder + app_data_folder="${UMBREL_ROOT}/app-data/${app}" + + docker-compose -f ${ROOT_FOLDER}/apps/${app}/docker-compose.yml --env-file ${ROOT_FOLDER}/.env -e DATA_FOLDER=${app_data_folder} up -d +done \ No newline at end of file diff --git a/state/apps.json b/state/apps.json new file mode 100644 index 00000000..b69f0115 --- /dev/null +++ b/state/apps.json @@ -0,0 +1,3 @@ +{ + "installed": "wg-easy" +}