From 237fd56c027ac75c54fdc38d16bdcc4ff1bb5541 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Sat, 7 May 2022 07:09:11 +0000 Subject: [PATCH] Fix sed escape slashes --- ansible/host_vars/tipi.yml | 1 - ansible/tasks/common/system-api.yml | 7 ------- scripts/configure.sh | 6 +----- scripts/start.sh | 9 ++++++++- system-api/src/config/config.ts | 2 +- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/ansible/host_vars/tipi.yml b/ansible/host_vars/tipi.yml index 98398f7f..6b29967d 100644 --- a/ansible/host_vars/tipi.yml +++ b/ansible/host_vars/tipi.yml @@ -11,7 +11,6 @@ packages: - npm username: nicolas -jwt_secret: test ### ZSH Settings zsh_theme: "powerlevel10k/powerlevel10k" diff --git a/ansible/tasks/common/system-api.yml b/ansible/tasks/common/system-api.yml index 36835795..9f1f6284 100644 --- a/ansible/tasks/common/system-api.yml +++ b/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" diff --git a/scripts/configure.sh b/scripts/configure.sh index 2711be76..11ef67a4 100755 --- a/scripts/configure.sh +++ b/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 diff --git a/scripts/start.sh b/scripts/start.sh index 6c0437a1..c531d8c8 100755 --- a/scripts/start.sh +++ b/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}/g" "${template}" sed -i "s//${PGID}/g" "${template}" sed -i "s//${TZ}/g" "${template}" - sed -i "s//${ROOT_FOLDER}/g" "${template}" sed -i "s//${JWT_SECRET}/g" "${template}" + sed -i "s//${SED_ROOT_FOLDER}/g" "${template}" done mv -f "$ENV_FILE" "$ROOT_FOLDER/.env" diff --git a/system-api/src/config/config.ts b/system-api/src/config/config.ts index 9a6eb762..338e4c5f 100644 --- a/system-api/src/config/config.ts +++ b/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;