diff --git a/bin/armbian-tx-stats-html.nu b/bin/.archived/armbian-tx-stats-html.nu
similarity index 100%
rename from bin/armbian-tx-stats-html.nu
rename to bin/.archived/armbian-tx-stats-html.nu
diff --git a/bin/backup-to-minio b/bin/.archived/backup-to-minio.bash
similarity index 100%
rename from bin/backup-to-minio
rename to bin/.archived/backup-to-minio.bash
diff --git a/bin/seed-armbian-tx.nu b/bin/.archived/seed-armbian-tx.nu
similarity index 100%
rename from bin/seed-armbian-tx.nu
rename to bin/.archived/seed-armbian-tx.nu
diff --git a/bin/tx-stats-html.nu b/bin/.archived/tx-stats-html.nu
similarity index 100%
rename from bin/tx-stats-html.nu
rename to bin/.archived/tx-stats-html.nu
diff --git a/bin/mastodon-backup b/bin/mastodon-backup
new file mode 100755
index 0000000..6ffbeda
--- /dev/null
+++ b/bin/mastodon-backup
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+set -eu
+
+trap "mv /home/mastodon/db-backup.sql.temp /home/mastodon/db-backup.sql" SIGHUP SIGINT SIGQUIT SIGTERM
+trap "rm -v /home/mastodon/db-backup.sql.temp" EXIT
+
+mv -v /home/mastodon/db-backup.sql /home/mastodon/db-backup.sql.temp
+
+pg_dump -U mastodon -Fc mastodon_production -p 5432 -f /home/mastodon/db-backup.sql
+
+rclone sync -c /home/mastodon/live/public/system/ /mnt/mastodon/system
+
+rclone copy -c /home/mastodon/db-backup.sql /mnt/mastodon
+
+rclone copy -c /home/mastodon/live/.env.production /mnt/mastodon
+
+exit 0
diff --git a/bin/mastodon-db-backup b/bin/mastodon-db-backup
deleted file mode 100755
index f099742..0000000
--- a/bin/mastodon-db-backup
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-
-sudo -u mastodon pg_dump -U mastodon -Fc mastodon_production -p 5432 -f "mastodon-db-$(date '+%Y-%m-%d').sql"
diff --git a/bin/mastodon-to-minio b/bin/mastodon-to-minio
deleted file mode 100755
index 7fee144..0000000
--- a/bin/mastodon-to-minio
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env bash
-
-DB_FILENAME="/home/mastodon/db-backup-$(date '+%Y-%m-%d').sql"
-
-if ! pg_dump -U mastodon -Fc mastodon_production -p 5432 -f "$DB_FILENAME"; then
- echo "Error creating backup of mastodon_production database"
- exit 1
-else
- echo "Backup of mastodon_production database completed"
-fi
-
-find /home/mastodon \
- -maxdepth 1 \
- -type f \
- \( -name "*.sql" -and -not -wholename "$DB_FILENAME" \) \
- -delete
-
-if ! rclone copy --transfers=4 /home/mastodon/live/public/system minio:mastodata; then
- echo "Error rcloning /home/mastodon/live/public/system to MinIO instance"
- exit 1
-fi
-
-if ! rclone copy "${DB_FILENAME}" minio:mastodata; then
- echo "Error rcloning ${DB_FILENAME} to MinIO instance"
- exit 1
-fi
-
-if ! rclone copy /home/mastodon/live/.env.production minio:mastodata; then
- echo "Error rcloning /home/mastodon/live/.env.production to MinIO instance"
- exit 1
-fi
-
-exit 0
diff --git a/bin/qbt-sum-size b/bin/qbt-sum-size
index 32da097..50eb468 100755
--- a/bin/qbt-sum-size
+++ b/bin/qbt-sum-size
@@ -1,11 +1,20 @@
#!/usr/bin/env python3
-#
-# Dependencies: python-qbittorrent
-# pip install --user python-qbittorrent
-#
-# On Debian:
-# pip install --user python-qbittorrent --break-system-packages
+"""qbt-sum-size
+
+Usage:
+ qbt-sum-size (HOSTNAME) (USERNAME) (PASSWORD)
+ qbt-sum-size -h
+
+Examples:
+ qbt-sum-size "http://localhost:8080" "admin" "adminadmin"
+ qbt-sum-size "https://cat.seedhost.eu/lol/qbittorrent" "lol" "supersecretpassword"
+
+Options:
+ -h, --help show this help message and exit
+"""
+
+from docopt import docopt
from qbittorrent import Client
@@ -33,11 +42,11 @@ def human_bytes(bites: int) -> str:
if __name__ == "__main__":
- # Instantiate a qbittorrent client
- qb = Client("http://localhost:8080/")
+ args = docopt(__doc__)
- # username and password not required when 'Bypass from localhost' setting is active.
- qb.login()
+ # Initialize client and login
+ qb = Client(args["HOSTNAME"])
+ qb.login(username=args["USERNAME"], password=args["PASSWORD"])
# get torrents
torrents = qb.torrents()
diff --git a/bin/seed-armbian-torrents b/bin/seed-armbian-torrents
index e9ac6f0..9f7e9fc 100755
--- a/bin/seed-armbian-torrents
+++ b/bin/seed-armbian-torrents
@@ -18,7 +18,7 @@ from qbittorrent import Client
if __name__ == "__main__":
- qb = Client("http://10.0.0.81:8080/")
+ qb = Client("http://localhost:8080/")
qb.login()
with TemporaryDirectory() as tmp_dir:
diff --git a/justfile b/justfile
index 67511a4..a5b9d93 100644
--- a/justfile
+++ b/justfile
@@ -1,21 +1,8 @@
## Justfile (https://github.com/casey/justfile)
-##
-## Orange Pi 5+ x 3
-##
-## Services:
-## - ArchiveBox
-## - Caddy web server
-## - gmcapsuled
-## - Mastodon auxiliary scripts
-## - qBittorrent + WireGuard
-## - Tailscale
-## - The Lounge IRC
distro := `grep -G "\bID\b" /etc/os-release | awk -F= '{print $2}'`
release := `grep "VERSION_CODENAME" /etc/os-release | awk -F= '{print $2}'`
run_user := env_var("USER")
-archivebox_data := "/nfs/archivebox"
-archivebox_nfs := "10.0.0.6:/mnt/coffeeNAS/archivebox"
default: common
@@ -35,7 +22,6 @@ common:
curl \
firewalld \
git \
- glances \
htop \
httpie \
ifplugd \
@@ -65,13 +51,6 @@ caddy-install:
sudo apt update
sudo apt install caddy
-archivebox-mnt-nfs:
- sudo mkdir -p {{archivebox_data}}
- if ! df -h | grep "archivebox"; then sudo chown -R {{run_user}}:{{run_user}} {{archivebox_data}}; fi
- if ! grep "archivebox" /etc/fstab; then echo "{{archivebox_nfs}} {{archivebox_data}} nfs4 soft,intr,rsize=8192,wsize=8192" | sudo tee -a /etc/fstab; fi
- sudo systemctl daemon-reload
- sudo mount -av
-
archivebox-install:
sudo apt install -y pipx python3-dev python3-pip nodejs npm curl wget git ripgrep
pipx install archivebox
@@ -85,13 +64,6 @@ archivebox-init:
archivebox-setup:
cd {{archivebox_data}} && archivebox setup
-mastodon-aux-setup:
- sudo cp -v "${PWD}/bin/mastodon-to-minio" /usr/local/bin/
- sudo chmod +x /usr/local/bin/mastodon-to-minio
- sudo cp -v "${PWD}/systemd/system/mastodon-to-minio.service" /etc/systemd/system/
- sudo cp -v "${PWD}/systemd/system/mastodon-to-minio.timer" /etc/systemd/system/
- sudo systemctl enable --now mastodon-to-minio.timer
-
thelounge-install:
curl -s https://api.github.com/repos/thelounge/thelounge-deb/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -qi -
sudo apt install -y ./thelounge*.deb
@@ -106,12 +78,6 @@ qbt-install:
sudo apt update
sudo apt install -y qbittorrent-cli
-qbittorrent-install:
- sudo apt install -y qbittorrent-nox wireguard-tools lynx parallel wget curl httpie
-
-qbittorrent-enable:
- sudo systemctl enable --now qbittorrent-nox@{{run_user}}.service
-
scihub-setup:
mkdir ~/scihub-torrent-urls
lynx -dump -nonumbers -listonly=on https://libgen.rs/repository_torrent/ | grep "\.torrent" | tee ~/scihub-torrent-urls/urls.txt
diff --git a/systemd/system/backup-to-minio.service b/systemd/system/.archived/backup-to-minio.service
similarity index 100%
rename from systemd/system/backup-to-minio.service
rename to systemd/system/.archived/backup-to-minio.service
diff --git a/systemd/system/backup-to-minio.timer b/systemd/system/.archived/backup-to-minio.timer
similarity index 100%
rename from systemd/system/backup-to-minio.timer
rename to systemd/system/.archived/backup-to-minio.timer
diff --git a/systemd/system/mastodon-to-minio.service b/systemd/system/.archived/mastodon-to-minio.service
similarity index 100%
rename from systemd/system/mastodon-to-minio.service
rename to systemd/system/.archived/mastodon-to-minio.service
diff --git a/systemd/system/mastodon-to-minio.timer b/systemd/system/.archived/mastodon-to-minio.timer
similarity index 100%
rename from systemd/system/mastodon-to-minio.timer
rename to systemd/system/.archived/mastodon-to-minio.timer
diff --git a/systemd/system/mastodon-backup.service b/systemd/system/mastodon-backup.service
new file mode 100644
index 0000000..e21e62a
--- /dev/null
+++ b/systemd/system/mastodon-backup.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=mastodon-backup
+AssertFileIsExecutable=/home/mastodon/bin/mastodon-backup
+Requires=mnt-mastodon.mount
+After=mnt-mastodon.mount
+
+[Service]
+Type=oneshot
+User=mastodon
+Group=mastodon
+ExecStart=/home/mastodon/bin/mastodon-backup
+
+[Install]
+WantedBy=multi-user.target
diff --git a/systemd/system/mastodon-backup.timer b/systemd/system/mastodon-backup.timer
new file mode 100644
index 0000000..b99ccd1
--- /dev/null
+++ b/systemd/system/mastodon-backup.timer
@@ -0,0 +1,9 @@
+[Unit]
+Description=mastodon-backup
+
+[Timer]
+OnCalendar=Sun *-*-* 03:30:00
+Persistent=true
+
+[Install]
+WantedBy=timers.target
diff --git a/systemd/system/mnt-mastodon.mount b/systemd/system/mnt-mastodon.mount
new file mode 100644
index 0000000..81d878a
--- /dev/null
+++ b/systemd/system/mnt-mastodon.mount
@@ -0,0 +1,15 @@
+[Unit]
+Description=mastodon-data NFS share from TrueNAS (10.0.0.81)
+DefaultDependencies=no
+Conflicts=umount.target
+After=network-online.target remote-fs.target
+Before=umount.target
+
+[Mount]
+What=10.0.0.81:/mnt/coffeeNAS/mastodon-data
+Where=/mnt/mastodon
+Type=nfs
+Options=defaults
+
+[Install]
+WantedBy=multi-user.target
diff --git a/systemd/user/seed-armbian-tx.service b/systemd/user/.archived/seed-armbian-tx.service
similarity index 100%
rename from systemd/user/seed-armbian-tx.service
rename to systemd/user/.archived/seed-armbian-tx.service
diff --git a/systemd/user/seed-armbian-tx.timer b/systemd/user/.archived/seed-armbian-tx.timer
similarity index 100%
rename from systemd/user/seed-armbian-tx.timer
rename to systemd/user/.archived/seed-armbian-tx.timer
diff --git a/systemd/user/transmission-trackers.service b/systemd/user/.archived/transmission-trackers.service
similarity index 100%
rename from systemd/user/transmission-trackers.service
rename to systemd/user/.archived/transmission-trackers.service
diff --git a/systemd/user/transmission-trackers.timer b/systemd/user/.archived/transmission-trackers.timer
similarity index 100%
rename from systemd/user/transmission-trackers.timer
rename to systemd/user/.archived/transmission-trackers.timer
diff --git a/systemd/user/tx-stats-html.service b/systemd/user/.archived/tx-stats-html.service
similarity index 100%
rename from systemd/user/tx-stats-html.service
rename to systemd/user/.archived/tx-stats-html.service
diff --git a/systemd/user/tx-stats-html.timer b/systemd/user/.archived/tx-stats-html.timer
similarity index 100%
rename from systemd/user/tx-stats-html.timer
rename to systemd/user/.archived/tx-stats-html.timer
diff --git a/systemd/user/glances.service b/systemd/user/glances.service
new file mode 100644
index 0000000..238f13e
--- /dev/null
+++ b/systemd/user/glances.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Glances
+After=network.target
+AssertFileIsExecutable=/home/jas/.local/bin/glances
+
+[Service]
+ExecStart=/home/jas/.local/bin/glances -s
+Restart=always
+RemainAfterExit=no
+
+[Install]
+WantedBy=default.target