src.nth.io/

summaryrefslogtreecommitdiff
path: root/pleroma-otp/files
diff options
context:
space:
mode:
authorLuke Hoersten <[email protected]>2020-02-09 12:08:03 -0600
committerLuke Hoersten <[email protected]>2020-02-09 12:08:03 -0600
commitc17f28aafd1f15a8c26835196956c1c209ec5ff3 (patch)
tree471a2637b3d3b7551845af91c86be54586c2d2e5 /pleroma-otp/files
parent11746a2c064018a642486b208b2fdcaeae8ea8e5 (diff)
Moved roles to top level dir.
Diffstat (limited to 'pleroma-otp/files')
-rw-r--r--pleroma-otp/files/pleroma-s3-backup.sh26
-rw-r--r--pleroma-otp/files/[email protected]9
-rw-r--r--pleroma-otp/files/[email protected]35
3 files changed, 70 insertions, 0 deletions
diff --git a/pleroma-otp/files/pleroma-s3-backup.sh b/pleroma-otp/files/pleroma-s3-backup.sh
new file mode 100644
index 0000000..7c1d6d3
--- /dev/null
+++ b/pleroma-otp/files/pleroma-s3-backup.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+INSTANCE=$1
+DATE=`date --iso-8601`
+
+BUCKET="pleroma-${INSTANCE//_/-}-backup"
+BACKUP_DIR="/tmp/s3-backup/$BUCKET"
+BACKUP_TAR="/tmp/s3-backup/$BUCKET-$DATE.tgz"
+
+DB_NAME="pleroma_$INSTANCE"
+CONFIG="/etc/pleroma/$INSTANCE.config.exs"
+
+UPLOADS_DIR=`grep uploads $CONFIG | cut -d '"' -f 2`
+STATIC_DIR=`grep static $CONFIG | cut -d '"' -f 2`
+
+mkdir -m 775 -p "$BACKUP_DIR/"
+chown root:postgres "$BACKUP_DIR/"
+
+su postgres -c "pg_dump -d $DB_NAME --format=custom -f $BACKUP_DIR/$DB_NAME.pgdump"
+cp $CONFIG "$BACKUP_DIR/"
+cp -r $UPLOADS_DIR "$BACKUP_DIR/"
+cp -r $STATIC_DIR "$BACKUP_DIR/"
+
+tar -zc -f $BACKUP_TAR $BACKUP_DIR
+aws s3 mb "s3://$BUCKET/"
+aws s3 cp $BACKUP_TAR "s3://$BUCKET/"
diff --git a/pleroma-otp/files/[email protected] b/pleroma-otp/files/[email protected]
new file mode 100644
index 0000000..a64cae3
--- /dev/null
+++ b/pleroma-otp/files/[email protected]
@@ -0,0 +1,9 @@
+[Unit]
+Description=Pleroma s3 backup for instance "%I"
+
+[Service]
+Type=oneshot
+ExecStart=/usr/local/bin/pleroma-s3-backup.sh %i
+
+[Install]
+WantedBy=aws-s3-backup.target
diff --git a/pleroma-otp/files/[email protected] b/pleroma-otp/files/[email protected]
new file mode 100644
index 0000000..4967c63
--- /dev/null
+++ b/pleroma-otp/files/[email protected]
@@ -0,0 +1,35 @@
+[Unit]
+Description=Pleroma social network instance "%I"
+After=network.target postgresql.service nginx.service
+
+[Service]
+User=pleroma
+WorkingDirectory=/opt/pleroma
+
+Environment="HOME=/opt/pleroma"
+Environment="PLEROMA_CONFIG_PATH=/etc/pleroma/%i.config.exs"
+Environment="PLUG_TMPDIR=/tmp/%i"
+Environment="RELEASE_NODE=%[email protected]"
+
+ExecStart=/opt/pleroma/bin/pleroma start
+ExecReload=/opt/pleroma/bin/pleroma stop
+
+KillMode=process
+Restart=on-failure
+
+; Some security directives.
+; Use private /tmp and /var/tmp folders inside a new file system namespace, which are discarded after the process stops.
+PrivateTmp=true
+; The /home, /root, and /run/user folders can not be accessed by this service anymore. If your Pleroma user has its home folder in one of the restricted places, or use one of these folders as its working directory, you have to set this to false.
+ProtectHome=true
+; Mount /usr, /boot, and /etc as read-only for processes invoked by this service.
+ProtectSystem=full
+; Sets up a new /dev mount for the process and only adds API pseudo devices like /dev/null, /dev/zero or /dev/random but not physical devices. Disabled by default because it may not work on devices like the Raspberry Pi.
+PrivateDevices=false
+; Ensures that the service process and all its children can never gain new privileges through execve().
+NoNewPrivileges=true
+; Drops the sysadmin capability from the daemon.
+CapabilityBoundingSet=~CAP_SYS_ADMIN
+
+[Install]
+WantedBy=multi-user.target