Parcourir la source

Fix sed escape slashes

Nicolas Meienberger il y a 3 ans
Parent
commit
237fd56c02

+ 0 - 1
ansible/host_vars/tipi.yml

@@ -11,7 +11,6 @@ packages:
   - npm
 
 username: nicolas
-jwt_secret: test
 
 ### ZSH Settings
 zsh_theme: "powerlevel10k/powerlevel10k"

+ 0 - 7
ansible/tasks/common/system-api.yml

@@ -9,13 +9,6 @@
 - name: Enable pm2 as a service
   shell: sudo env PATH=$PATH:/usr/local/bin pm2 startup -u {{ username }}
 
-- name: Create .env file in /system-api "{{ playbook_dir }}/../system-api/.env"
-  copy:
-    dest: "{{ playbook_dir }}/../system-api/.env"
-    content: |
-      ROOT_FOLDER={{ playbook_dir }}/../
-      JWT_SECRET={{ jwt_secret }}
-
 - name: Install packages based on package.json.
   community.general.npm:
     path: "{{ playbook_dir }}/../system-api"

+ 1 - 5
scripts/configure.sh

@@ -22,11 +22,7 @@ if ! command -v ansible-playbook > /dev/null; then
   sudo pip3 install ansible
 fi
 
-# Create seed file with cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
-if [[ ! -f "${ROOT_FOLDER}/state/seed" ]]; then
-  echo "Generating seed..."
-  cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 > "${ROOT_FOLDER}/state/seed"
-fi
+
 
 ansible-playbook ansible/setup.yml -i ansible/hosts -K
 

+ 8 - 1
scripts/start.sh

@@ -10,6 +10,7 @@ fi
 
 ROOT_FOLDER="$($readlink -f $(dirname "${BASH_SOURCE[0]}")/..)"
 STATE_FOLDER="${ROOT_FOLDER}/state"
+SED_ROOT_FOLDER="$(echo $ROOT_FOLDER | sed 's/\//\\\//g')"
 INTERNAL_IP="$(hostname -I | awk '{print $1}')"
 DNS_IP=9.9.9.9
 
@@ -72,6 +73,12 @@ if [[ ! -f "${STATE_FOLDER}/users.json" ]]; then
   cp "${ROOT_FOLDER}/templates/users-sample.json" "${STATE_FOLDER}/users.json" && chown -R "1000:1000" "${STATE_FOLDER}/users.json"
 fi
 
+# Create seed file with cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
+if [[ ! -f "${STATE_FOLDER}/seed" ]]; then
+  echo "Generating seed..."
+  cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 > "${STATE_FOLDER}/seed"
+fi
+
 export DOCKER_CLIENT_TIMEOUT=240
 export COMPOSE_HTTP_TIMEOUT=240
 
@@ -102,8 +109,8 @@ for template in "${ENV_FILE}" "${ENV_FILE_SYSTEM_API}"; do
   sed -i "s/<puid>/${PUID}/g" "${template}"
   sed -i "s/<pgid>/${PGID}/g" "${template}"
   sed -i "s/<tz>/${TZ}/g" "${template}"
-  sed -i "s/<root_folder>/${ROOT_FOLDER}/g" "${template}"
   sed -i "s/<jwt_secret>/${JWT_SECRET}/g" "${template}"
+  sed -i "s/<root_folder>/${SED_ROOT_FOLDER}/g" "${template}"
 done
 
 mv -f "$ENV_FILE" "$ROOT_FOLDER/.env"

+ 1 - 1
system-api/src/config/config.ts

@@ -23,7 +23,7 @@ const config: IConfig = {
   NODE_ENV,
   ROOT_FOLDER,
   JWT_SECRET,
-  CLIENT_URLS: ['locahost:3000', `${INTERNAL_IP}`, `${INTERNAL_IP}:3000`],
+  CLIENT_URLS: ['http://locahost:3000', `http://${INTERNAL_IP}`, `http://${INTERNAL_IP}:3000`],
 };
 
 export default config;