summaryrefslogtreecommitdiff
path: root/playbooks.d/seaweedfs
diff options
context:
space:
mode:
Diffstat (limited to 'playbooks.d/seaweedfs')
-rw-r--r--playbooks.d/seaweedfs/description.txt1
-rw-r--r--playbooks.d/seaweedfs/etc/defaults1
-rw-r--r--playbooks.d/seaweedfs/playbook.bash48
-rw-r--r--playbooks.d/seaweedfs/share/seaweedfs-mount@.service15
4 files changed, 65 insertions, 0 deletions
diff --git a/playbooks.d/seaweedfs/description.txt b/playbooks.d/seaweedfs/description.txt
new file mode 100644
index 0000000..d14afca
--- /dev/null
+++ b/playbooks.d/seaweedfs/description.txt
@@ -0,0 +1 @@
+Scalable object storage cluster
diff --git a/playbooks.d/seaweedfs/etc/defaults b/playbooks.d/seaweedfs/etc/defaults
new file mode 100644
index 0000000..ac67585
--- /dev/null
+++ b/playbooks.d/seaweedfs/etc/defaults
@@ -0,0 +1 @@
+svc.seaweedfs=seaweedfs
diff --git a/playbooks.d/seaweedfs/playbook.bash b/playbooks.d/seaweedfs/playbook.bash
new file mode 100644
index 0000000..fabc958
--- /dev/null
+++ b/playbooks.d/seaweedfs/playbook.bash
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+
+playbook_add() {
+ local dl_arch
+ local dl_baseurl
+ local dl_binary
+ local dl_version
+
+ # Install seaweedfs
+ case "${BASHTARD_PLATFORM[arch]}" in
+ x86_64) dl_arch=amd64 ;;
+ aarch64) dl_arch=arm64 ;;
+ esac
+
+ dl_baseurl="https://github.com/seaweedfs/seaweedfs/releases/download"
+ dl_binary="$(printf "%s_%s.tar.gz" "${BASHTARD_PLATFORM[os]}" "$dl_arch")"
+ dl_version="$(config "$BASHTARD_PLAYBOOK.version" "3.65")"
+
+ buffer="$(tmpdir)"
+
+ chgdir "$buffer"
+
+ info "$BASHTARD_PLAYBOOK/add" "Fetching $dl_baseurl/$dl_version/$dl_binary"
+ curl -L "$dl_baseurl/$dl_version/$dl_binary" > "$dl_binary"
+
+ tar xzf "$dl_binary"
+ mv -v -- "weed" "$(config "fs.bindir")/weed"
+
+ # Create mount.weed symlink
+ ln -fsv "$(config "fs.bindir")/weed" "$(config "fs.bindir")/mount.weed"
+
+ # Create directories used by seaweedfs
+ mkdir -pv -- "$(config "fs.etcdir")/seaweedfs"
+}
+
+playbook_sync() {
+ file_template "seaweedfs-mount@.service"\
+ > "/etc/systemd/system/seaweedfs-mount@.service"
+}
+
+playbook_del() {
+ # Remove configuration files
+ rm -fr -- "$(config "fs.etcdir")/seaweedfs"
+
+ # Remove downloaded binary and symlinks
+ rm -fr -- "$(config "fs.bindir")/weed"
+ rm -fr -- "$(config "fs.bindir")/mount.weed"
+}
diff --git a/playbooks.d/seaweedfs/share/seaweedfs-mount@.service b/playbooks.d/seaweedfs/share/seaweedfs-mount@.service
new file mode 100644
index 0000000..438dc90
--- /dev/null
+++ b/playbooks.d/seaweedfs/share/seaweedfs-mount@.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=SeaweedFS Mount %i
+After=network.target
+
+[Service]
+Type=simple
+User=root
+Group=root
+
+ExecStart=/usr/bin/weed mount -options="/etc/seaweedfs/mount-%i.conf"
+ExecStopPost=sh -c "/bin/umount $(awk -F= '/^dir=/ { print $NF }' < /etc/seaweedfs/mount-%i.conf)"
+SyslogIdentifier=seaweedfs-mount-%i
+
+[Install]
+WantedBy=multi-user.target