summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2023-03-08 09:18:35 +0100
committerPatrick Spek <p.spek@tyil.nl>2023-03-08 09:18:35 +0100
commit2e0616dfb67c4122d1ba590deeb772168a46a833 (patch)
tree3bfbe97703c936f6d89de26b1f23082afc736bf9
parent763001fd81f624fbf4457e8cd4991e7834e4cd15 (diff)
Prep www-blog to be exported as a more generic playbook
-rw-r--r--defaults2
-rw-r--r--playbooks.d/www-blog/etc/defaults2
-rw-r--r--playbooks.d/www-blog/playbook.bash27
3 files changed, 20 insertions, 11 deletions
diff --git a/defaults b/defaults
index b5ec7fa..2a12969 100644
--- a/defaults
+++ b/defaults
@@ -11,3 +11,5 @@ dns.upstream.1=188.68.231.82
dns.upstream.2=51.83.172.84
dns.upstream.3=2a03:94e0:1804::1
dns.upstream.4=2001:470:71:6dc::53
+www-blog.path=/var/www/nl.tyil.www
+www-blog.repository=https://git.tyil.nl/blog
diff --git a/playbooks.d/www-blog/etc/defaults b/playbooks.d/www-blog/etc/defaults
deleted file mode 100644
index 5135281..0000000
--- a/playbooks.d/www-blog/etc/defaults
+++ /dev/null
@@ -1,2 +0,0 @@
-www.blog.branch=master
-www.blog.path=/var/www/nl.tyil.www
diff --git a/playbooks.d/www-blog/playbook.bash b/playbooks.d/www-blog/playbook.bash
index e217e73..c5835d6 100644
--- a/playbooks.d/www-blog/playbook.bash
+++ b/playbooks.d/www-blog/playbook.bash
@@ -1,24 +1,33 @@
#!/usr/bin/env bash
playbook_add() {
- git clone https://git.tyil.nl/blog "$(config www.blog.path)"
+ local path
+
+ path="$(config "$BASHTARD_PLAYBOOK.path" "/var/www/$BASHTARD_PLAYBOOK")"
+
+ mkdir -p -- "$path"
+ git -C "$path" init
+ git -C "$path" remote add "$(config "$BASHTARD_PLAYBOOK.remote" "origin")" "$(config "$BASHTARD_PLAYBOOK.repository")"
playbook_sync
}
playbook_sync() {
- if [[ $BASHTARD_COMMAND != "add" ]]
- then
- git -C "$(config www.blog.path)" pull origin "$(config www.blog.branch)"
- fi
+ local branch
+ local path
+ local remote
+
+ branch="$(config "$BASHTARD_PLAYBOOK.branch" "master")"
+ path="$(config "$BASHTARD_PLAYBOOK.path" "/var/www/$BASHTARD_PLAYBOOK")"
+ remote="$(config "$BASHTARD_PLAYBOOK.origin" "origin")"
+
+ git -C "$path" fetch "$remote" "$branch"
+ git -C "$path" reset --hard "$remote/$branch"
- chgdir "$(config www.blog.path)"
hugo -D # This will generate all the draft content
hugo # And this will generate the actual live blog, but won't remove the draft content
}
playbook_del() {
- rm -fr -- "$(config www.blog.path)"
-
- pkg uninstall hugo
+ rm -fr -- "$(config "$BASHTARD_PLAYBOOK.path" "/var/www/$BASHTARD_PLAYBOOK")"
}