From 09f27804ee013b2816330bc567cc0f60c6b43e0d Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Mon, 25 Dec 2023 22:07:01 +0100 Subject: feat: Add reddit-importer --- apks/reddit-importer/APKBUILD | 39 ++++++++++++++++++++++++ apks/reddit-importer/reddit-importer.confd | 11 +++++++ apks/reddit-importer/reddit-importer.initd | 27 ++++++++++++++++ apks/reddit-importer/reddit-importer.pre-install | 9 ++++++ 4 files changed, 86 insertions(+) create mode 100644 apks/reddit-importer/APKBUILD create mode 100644 apks/reddit-importer/reddit-importer.confd create mode 100644 apks/reddit-importer/reddit-importer.initd create mode 100644 apks/reddit-importer/reddit-importer.pre-install diff --git a/apks/reddit-importer/APKBUILD b/apks/reddit-importer/APKBUILD new file mode 100644 index 0000000..c75c4bd --- /dev/null +++ b/apks/reddit-importer/APKBUILD @@ -0,0 +1,39 @@ +# Maintainer: Gabriel Arakaki Giovanini +pkgname=reddit-importer +pkgver=0_git20231225 +pkgrel=0 +_commit=e5ce82abf59dc28bcc84a336053a95a58cf27c16 +pkgdesc="A process to import images and videos from liked post on reddit local folder." +url="https://git.sr.ht/~gabrielgio/reddit-importer" +arch="x86_64" +license="MIT" +options="!check" # this can't be tested +depends=" + gallery-dl +" +makedepends="go make" +builddir="$srcdir/$pkgname-$_commit" +install="$pkgname.pre-install" +subpackages="$pkgname-openrc" +source="$pkgname-$_commit.tar.gz::https://git.sr.ht/~gabrielgio/$pkgname/archive/$_commit.tar.gz + $pkgname.initd + $pkgname.confd" + + +build() { + make +} + +package() { + install -m755 -D "$srcdir"/$pkgname.initd \ + "$pkgdir"/etc/init.d/$pkgname + install -m644 -D "$srcdir"/$pkgname.confd \ + "$pkgdir"/etc/conf.d/$pkgname + install -Dm755 bin/reddit-importer "$pkgdir"/usr/bin/reddit-importer +} + +sha512sums=" +06cbe8dc28737b4f3fa265f4af1d0dd82e2e0ad8e15e7b0efec3de6e56a7677cf9d61d82100b777a8238331bb31d98b61a427e0c9899ce391e191fcc8d765d85 reddit-importer-e5ce82abf59dc28bcc84a336053a95a58cf27c16.tar.gz +8d992bbcf8d0b9f54ce7659c9c6d27dc886b488432daad0c0857e31b006cc54b11096e056d996bb4d831babf72306e274a24a4ab77a904fa7dcf0430875e597f reddit-importer.initd +d277a7144b89a1f100c7f2fe2a645b16ddfdcfd23ee594d24d171fc2965c342f8fce5aabff2f9ca40905d4ad7272daa586c7c8bbdf98711e627f511b07306695 reddit-importer.confd +" diff --git a/apks/reddit-importer/reddit-importer.confd b/apks/reddit-importer/reddit-importer.confd new file mode 100644 index 0000000..3e562a5 --- /dev/null +++ b/apks/reddit-importer/reddit-importer.confd @@ -0,0 +1,11 @@ +client_id="" +client_secret="" +reddit_username="" +reddit_password="" +tmp_dir="/tmp/$RC_SVCNAME/" + +# for my local set I use www-data for most of my service. Change it to fit yours +cmd_user="www-data:www-data" + +# File to redirect stdout/stderr into. Set to empty string to disable. +#logfile="/var/log/$RC_SVCNAME.log" diff --git a/apks/reddit-importer/reddit-importer.initd b/apks/reddit-importer/reddit-importer.initd new file mode 100644 index 0000000..7298269 --- /dev/null +++ b/apks/reddit-importer/reddit-importer.initd @@ -0,0 +1,27 @@ +#!/sbin/openrc-run +supervisor="supervise-daemon" + +name="reddit-importer" +command="/usr/bin/reddit-importer" +command_args="-id ${client_id} + --secret ${client_secret} + -username ${reddit_username} + -password ${reddit_password} + " +command_background="yes" + +supervise_daemon_args="--user $cmd_user -d $tmp_dir" +pidfile="/run/$RC_SVCNAME.pid" +output_log="$logfile" +error_log="$logfile" + +start_pre() { + if [ "$logfile" ]; then + checkpath --file --mode 0640 --owner "cmd_user" "$logfile" || return 1 + fi + checkpath --directory --owner "$cmd_user" --mode 0775 "$tmp_dir" || return 1 +} + +depend() { + use net +} diff --git a/apks/reddit-importer/reddit-importer.pre-install b/apks/reddit-importer/reddit-importer.pre-install new file mode 100644 index 0000000..74f1b59 --- /dev/null +++ b/apks/reddit-importer/reddit-importer.pre-install @@ -0,0 +1,9 @@ +#!/bin/sh + +user=www-data +group=www-data + +addgroup -S $group 2>/dev/null +adduser -S -D -h /var/lib/$user -s /sbin/nologin -G $group -g $user $user 2>/dev/null + +exit 0 -- cgit v1.2.3