summaryrefslogtreecommitdiffstats
path: root/acid/cyche-remove
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2023-09-07 00:28:38 -0400
committerMalfurious <m@lfurio.us>2023-09-08 19:07:29 -0400
commit95531708431448d1f2ae2d7573421c2980a16a17 (patch)
tree6ca5414f83524ae703aa1ea6a391ca63c3923705 /acid/cyche-remove
parent7a7ff89ff16542d30ff7c1f70689236b8fd9c607 (diff)
downloadcychedelic-95531708431448d1f2ae2d7573421c2980a16a17.tar.gz
cychedelic-95531708431448d1f2ae2d7573421c2980a16a17.zip
acid: Remove running services no longer present in $CYCHE_SERVICES
If a service was previously managed by cychedelic, but an update to the cyche code removes it from the config file, stop the service and delete the git clone. As usual, this should leave any docker volumes intact. Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to '')
-rwxr-xr-xacid/cyche-remove20
1 files changed, 20 insertions, 0 deletions
diff --git a/acid/cyche-remove b/acid/cyche-remove
new file mode 100755
index 0000000..1aa5f36
--- /dev/null
+++ b/acid/cyche-remove
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# cyche-remove <name>
+#
+# Stop the service <name>, which was previously managed by cychedelic, and
+# remove associated files.
+
+cd "/services/$1"
+
+file=$(cat '.git/previous_file')
+slug=$(cat '.git/previous_slug')
+[ -n "$slug" ] && slug="--project-name $slug"
+
+docker compose $slug --file "$file" down \
+ --remove-orphans
+
+echo "Removing files..."
+cd ".."
+rm -rf "$1"
+echo "Done."