From c0ab7feac52fc00e66417db22b25162130a4e6e3 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Mon, 13 Jan 2025 21:24:32 -0800 Subject: fix create service script for infra and add phoneassistant role --- create_service.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'create_service.sh') diff --git a/create_service.sh b/create_service.sh index 7f6766c..febf42a 100755 --- a/create_service.sh +++ b/create_service.sh @@ -20,16 +20,16 @@ SERVICE_ORIGIN=$(prompt_with_default "Enter service origin URL" "git@git.simponi INTERNAL=$(prompt_with_default "Is the service internal? (yes/no)" "no") SERVICE_HOST=$(prompt_with_default "Enter service host" "ryo") PACKAGE_PATH=$(prompt_with_default "Enter package path" "$HOME/git/simponic/$SERVICE") -HATECOMPUTERS_API_KEY=$(prompt_with_default "Enter hatecomputers API key (paste from clipboard)" "$(pbpaste)") +HATECOMPUTERS_API_KEY=$(prompt_with_default "Enter hatecomputers API key (paste from clipboard)" "$(wl-paste)") function render_template() { cp -r template $PACKAGE_PATH - ggrep -rlZ "{{ service }}" $PACKAGE_PATH | xargs -0 gsed -i "s/{{ service }}/$SERVICE/g" - ggrep -rlZ "{{ service_host }}" $PACKAGE_PATH | xargs -0 gsed -i "s/{{ service_host }}/$SERVICE_HOST/g" - ggrep -rlZ "{{ service_repo }}" $PACKAGE_PATH | xargs -0 gsed -i "s/{{ service_repo }}/$(echo $SERVICE_REPO | sed 's/\//\\\//g')/g" - ggrep -rlZ "{{ service_port }}" $PACKAGE_PATH | xargs -0 gsed -i "s/{{ service_port }}/$SERVICE_PORT/g" - ggrep -rlZ "{{ service_title }}" $PACKAGE_PATH | xargs -0 gsed -i "s/{{ service_title }}/$SERVICE_TITLE/g" + grep -rlZ "{{ service }}" $PACKAGE_PATH | xargs -0 sed -i "s/{{ service }}/$SERVICE/g" + grep -rlZ "{{ service_host }}" $PACKAGE_PATH | xargs -0 sed -i "s/{{ service_host }}/$SERVICE_HOST/g" + grep -rlZ "{{ service_repo }}" $PACKAGE_PATH | xargs -0 sed -i "s/{{ service_repo }}/$(echo $SERVICE_REPO | sed 's/\//\\\//g')/g" + grep -rlZ "{{ service_port }}" $PACKAGE_PATH | xargs -0 sed -i "s/{{ service_port }}/$SERVICE_PORT/g" + grep -rlZ "{{ service_title }}" $PACKAGE_PATH | xargs -0 sed -i "s/{{ service_title }}/$SERVICE_TITLE/g" } function test_and_commit_code() { @@ -60,12 +60,12 @@ function add_dns_records() { name="$SERVICE.internal.simponic.xyz." content="$SERVICE_HOST.internal.simponic.xyz." curl -H "Authorization: Bearer $HATECOMPUTERS_API_KEY" \ - -F "type=CNAME&name=$name&content=$content.internal.simponic.xyz.&ttl=43200&internal=on" \ + -F "type=CNAME&name=$name&content=$content&ttl=43200&internal=on" \ $DNS_ENDPOINT else name="$SERVICE.simponic.xyz." content="$SERVICE_HOST.simponic.xyz." - gsed -i "s|;; CNAME Records|;; CNAME Records\n$name\t43200\tIN\tCNAME\t$content|" $BIND_FILE + sed -i "s|;; CNAME Records|;; CNAME Records\n$name\t43200\tIN\tCNAME\t$content|" $BIND_FILE fi } @@ -149,6 +149,14 @@ function create_role() { group: root mode: 0777 +- name: ensure $SERVICE env exist + file: + path: /etc/docker/compose/$SERVICE/.env + state: file + owner: root + group: root + mode: 0700 + - name: build $SERVICE docker-compose.yml.j2 template: src: ../templates/docker-compose.yml.j2 -- cgit v1.2.3-70-g09d2