summaryrefslogtreecommitdiff
path: root/create_service.sh
diff options
context:
space:
mode:
Diffstat (limited to 'create_service.sh')
-rwxr-xr-xcreate_service.sh24
1 files changed, 16 insertions, 8 deletions
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