Nicolas Meienberger il y a 3 ans
Parent
commit
b8004870dc
4 fichiers modifiés avec 36 ajouts et 2 suppressions
  1. 1 1
      apps/wg-easy/docker-compose.yml
  2. 7 0
      scripts/configure.sh
  3. 25 1
      scripts/start.sh
  4. 3 0
      state/apps.json

+ 1 - 1
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'

+ 7 - 0
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..."

+ 25 - 1
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
+# 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

+ 3 - 0
state/apps.json

@@ -0,0 +1,3 @@
+{
+  "installed": "wg-easy"
+}