apkbuilds @ e7dfcd11bb8eec649cd84f09ddd2b3751dd99952

feat: add openrc for importer
diff --git a/reddit-nextcloud-importer/APKBUILD b/reddit-nextcloud-importer/APKBUILD
index 47a05580e7a5e2c34e3938ad6259cea538b3111c..44dccae186eb8d991ece2560e9e861a157fa48ee 100644
--- a/reddit-nextcloud-importer/APKBUILD
+++ b/reddit-nextcloud-importer/APKBUILD
@@ -1,13 +1,11 @@
 # Maintainer: Gabriel Arakaki Giovanini <mail@gabrielgio.me>
-pkgname=py3-reddit-nextcloud-importer
-_pkgorig=reddit-nextcloud-importer
+pkgname=reddit-nextcloud-importer
 pkgver=0.1.1
 pkgrel=0
 pkgdesc="A process to import images and videos from saved post on reddit to a instance of Nextcloud."
 url="https://git.sr.ht/~gabrielgio/reddit-nextcloud-importer"
 arch="noarch"
 license="Apache-2.0"
-option="!check" #requires more setup
 depends="
     python3
     py3-requests
@@ -17,17 +15,33 @@     py3-nextcloud-api-wrapper
     py3-praw
 "
 makedepends="python3-dev py3-setuptools_scm"
-source="$pkgname-$pkgver.tar.gz::https://artifacts.gabrielgio.me/$_pkgorig/$_pkgorig-$pkgver.tar.gz"
-builddir="$srcdir/$_pkgorig-$pkgver"
+builddir="$srcdir/$pkgname-$pkgver"
+install="$pkgname.pre-install"
+subpackages="$pkgname-openrc"
+source="$pkgname-$pkgver.tar.gz::https://artifacts.gabrielgio.me/$pkgname/$pkgname-$pkgver.tar.gz
+        $pkgname.initd
+        $pkgname.confd"
+provides="py3-reddit-nextcloud-importer=$pkgver-r$pkgrel"
+# TODO: requires many many many dependencies
+options="!check"
+
 
 build() {
 	python3 setup.py build
 }
 
 package() {
+    	# install scripts
+	install -m755 -D "$srcdir"/$pkgname.initd \
+		"$pkgdir"/etc/init.d/$pkgname
+	install -m644 -D "$srcdir"/$pkgname.confd \
+		"$pkgdir"/etc/conf.d/$pkgname
+
 	python3 setup.py install --prefix=/usr --root="$pkgdir"
 }
 
 sha512sums="
-dd983f438f7750d089f87623d183c130c17cdb0850e875993a905e59306c503e7340bdedb67c0a0ab36f50469a0d711733cdc46182e2ce8269c3db0a5996c841  py3-reddit-nextcloud-importer-0.1.1.tar.gz
+dd983f438f7750d089f87623d183c130c17cdb0850e875993a905e59306c503e7340bdedb67c0a0ab36f50469a0d711733cdc46182e2ce8269c3db0a5996c841  reddit-nextcloud-importer-0.1.1.tar.gz
+bdb27b8019736c0c36c5e72cc951039092c752e2dda06849da88c9b450778c0a5e24df564ccf63754d3955689f09c296494404659c8632a8c797eedb13f4ee0e  reddit-nextcloud-importer.initd
+64e63e65506478f5b9ad89b84539c8e4310e9f0239278d8776dae26ff60eee5f21621cc665e343a1f92e4705e2f95308d2108cf16012a5c9d8cbc5c20c89eb89  reddit-nextcloud-importer.confd
 "
diff --git a/reddit-nextcloud-importer/reddit-nextcloud-importer.confd b/reddit-nextcloud-importer/reddit-nextcloud-importer.confd
new file mode 100644
index 0000000000000000000000000000000000000000..ad77d8bdc5683cfba6d330a406de6422c3109cf8
--- /dev/null
+++ b/reddit-nextcloud-importer/reddit-nextcloud-importer.confd
@@ -0,0 +1,7 @@
+client_id=""
+client_secret=""
+reddit_username=""
+reddit_password=""
+nextcloud_host=""
+nextcloud_username=""
+nextcloud_password=""
diff --git a/reddit-nextcloud-importer/reddit-nextcloud-importer.initd b/reddit-nextcloud-importer/reddit-nextcloud-importer.initd
new file mode 100644
index 0000000000000000000000000000000000000000..b78cf293aaaeefc22a44a1edc904d1546e82e231
--- /dev/null
+++ b/reddit-nextcloud-importer/reddit-nextcloud-importer.initd
@@ -0,0 +1,18 @@
+#!/sbin/openrc-run
+supervisor="supervise-daemon"
+
+name="reddit-nextcloud-importer"
+command="/usr/bin/python3"
+command_args="-m reddit-nextcloud-importer -c ${client_id} -s ${client_secret} -u ${reddit_username} -p ${reddit_password} -P ${nextcloud_password} -U ${nextcloud_username} -o ${nextcloud_host}"
+command_background="yes"
+
+#output_log="/var/log/$name/$name.log"
+#error_log="/var/log/$name/$name.err"
+supervise_daemon_args="--user www-data:www-data"
+pidfile="/run/$name.pid"
+
+
+depend() {
+	use net
+}
+
diff --git a/reddit-nextcloud-importer/reddit-nextcloud-importer.pre-install b/reddit-nextcloud-importer/reddit-nextcloud-importer.pre-install
new file mode 100644
index 0000000000000000000000000000000000000000..74f1b591e16d12b52c7f15812c77334cfe0f3151
--- /dev/null
+++ b/reddit-nextcloud-importer/reddit-nextcloud-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