From bf1d965374c36c3ea4a340088136fd6991a910d9 Mon Sep 17 00:00:00 2001 From: Jeffrey Serio <23226432+hyperreal64@users.noreply.github.com> Date: Sat, 27 Jul 2024 21:23:03 -0500 Subject: [PATCH] Refactor --- README.org | 20 ++++++++++---------- bin/add_scihub_torrents | 2 +- bin/seed_armbian_torrents | 3 +-- justfile | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/README.org b/README.org index 71669eb..5de34de 100644 --- a/README.org +++ b/README.org @@ -2,18 +2,18 @@ These are scripts I use to automate various tasks in my homelab. -** bin -- ~add_scihub_torrents~ : This script uses [[https://github.com/charmbracelet/gum][gum]] to select paginated text files that contain URLs of Sci Hub torrent files. For each selected file, the URLs are read and added to a qBittorrent instance. + ⊘ bin + - ~add_scihub_torrents~ : This script uses [[https://github.com/charmbracelet/gum][gum]] to select paginated text files that contain URLs of Sci Hub torrent files. For each selected file, the URLs are read and added to a qBittorrent instance. - ~qbth~ : This is a helper program for adding Linux and BSD distros to a qBittorrent instance. It's a bit crude, and the Python linter yells at me for it, but it gets the job done, and that's all I need it to do. Thank you. - ~qbt_sum_size~ : This script prints the total size of completed torrents and the total size of all torrents added to a qBittorrent instance. The former is a subset of the latter. - ~seed_armbian_torrents~ : This script downloads an archive from Armbian, extracts the torrent files within to a temporary directory, and adds each file to a qBittorrent instance. It first removes older Armbian torrents from the qBittorrent instance. - ~seed_scihub_torrents~ : This script finds which torrents have less than or equal to N seeders, where N is an integer argument supplied by the user. It then adds these torrents to a qBittorrent instance. -- ~server0_backup~ : This script dumps my Mastodon instance's PostgreSQL database, then uses rclone to sync ~/etc~, ~/var/log~, and ~/home/jas~ to an S3-compatible object storage bucket. It also copies the dumped Mastodon database and ~.env.production~ to the object storage bucket. +- ~server0_backup~ : This script dumps my Mastodon instance's PostgreSQL database, then uses rclone to sync ~/etc~, ~/var/log~, and ~/home/jas~ to an S3-compatible object storage bucket (MinIO). It also copies the dumped Mastodon database and ~.env.production~ to the object storage bucket. -** systemd -*** system -- ~server0-backup.service~ : A systemd service unit that runs the ~server0-backup~ script. -- ~server0-backup.timer~ : A systemd timer unit that triggers the corresponding service unit. -*** user -- ~glances.service~ : A systemd service unit for the user scope that runs a glances server. -- ~gmcapsuled.service~ : A systemd service unit for the user scope that runs the gmcapsuled Gemini server. + ⊘ systemd + ⊖ system + - ~server0-backup.service~ : A systemd service unit that runs the ~server0_backup~ script. + - ~server0-backup.timer~ : A systemd timer unit that triggers the corresponding service unit. + ⊖ user + - ~glances.service~ : A systemd service unit for the user scope that runs a glances server. + - ~gmcapsuled.service~ : A systemd service unit for the user scope that runs the gmcapsuled Gemini server. diff --git a/bin/add_scihub_torrents b/bin/add_scihub_torrents index 9fafe14..30a4846 100755 --- a/bin/add_scihub_torrents +++ b/bin/add_scihub_torrents @@ -46,7 +46,7 @@ if __name__ == "__main__": ) # Read the contents of each file and put lines (which are URLs) into a list - torrent_urls = list() + torrent_urls = [] for item in torrent_selection: with open(scihub_torrent_dir.joinpath(item), "r") as tf: urls = tf.readlines() diff --git a/bin/seed_armbian_torrents b/bin/seed_armbian_torrents index a668c7e..891432c 100755 --- a/bin/seed_armbian_torrents +++ b/bin/seed_armbian_torrents @@ -49,8 +49,7 @@ if __name__ == "__main__": with ZipFile(BytesIO(req.content)) as zip_file: zip_file.extractall(tmp_dir) - torrents = qb.torrents() - for torrent in torrents: + for torrent in qb.torrents(): if "Armbian" in torrent.get("name"): # type: ignore qb.delete_permanently(torrent.get("hash")) # type: ignore print(f"Removed {torrent.get('name')}") # type: ignore diff --git a/justfile b/justfile index e0135d0..688b6f5 100644 --- a/justfile +++ b/justfile @@ -67,7 +67,7 @@ caddy-install: sudo apt install caddy 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 - + 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 rm -fv ./thelounge*.deb