user/peertube: new aport #238

Merged
ayakael merged 1 commit from peertube/initial into edge 2024-01-06 06:02:31 +00:00
7 changed files with 199 additions and 0 deletions

81
user/peertube/APKBUILD Normal file
View file

@ -0,0 +1,81 @@
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=peertube
pkgver=6.0.2
pkgrel=0
pkgdesc="ActivityPub-federated video streaming platform using P2P directly in your web browser"
arch="x86_64"
url="https://joinpeertube.org/"
license="AGPL"
depends="
nodejs
ffmpeg
postgresql
openssl
redis
npm
procps-ng
"
makedepends="
yarn
"
source="
$pkgname-$pkgver.tar.gz::https://github.com/Chocobozzz/PeerTube/archive/refs/tags/v$pkgver.tar.gz
peertube-manage.sh
peertube.conf
peertube.openrc
"
builddir="$srcdir"/PeerTube-$pkgver
install="$pkgname.post-install $pkgname.pre-install $pkgname.post-upgrade"
subpackages="$pkgname-doc $pkgname-openrc"
build() {
# need to fetch devel depencencies to build
yarn install --pure-lockfile
npm run build
rm -Rf "$builddir"/node_modules
yarn install --production --pure-lockfile
}
package() {
install -dm 755 \
"$pkgdir"/usr/share/webapps \
"$pkgdir"/usr/share/doc \
"$pkgdir"/usr/share/licenses/peertube \
"$pkgdir"/etc/init.d \
"$pkgdir"/etc/conf.d
# install
cp -a "$builddir" "$pkgdir/usr/share/webapps/peertube"
# wrapper script
install -Dm755 "$srcdir"/peertube-manage.sh "$pkgdir"/usr/bin/peertube-manage
# openrc
install -Dm755 "$srcdir"/peertube.openrc "$pkgdir"/etc/init.d/peertube
install -Dm644 "$srcdir"/peertube.conf "$pkgdir"/etc/conf.d/peertube
# config file setup
rm -R "$pkgdir"/usr/share/webapps/peertube/config
install -Dm644 "$builddir"/config/production.yaml.example "$pkgdir"/etc/peertube/production.yaml
install -Dm644 "$builddir"/config/default.yaml "$pkgdir"/etc/peertube/default.yaml
sed -i "s|/var/www/peertube/storage|/var/lib/peertube|g" "$pkgdir"/etc/peertube/production.yaml "$pkgdir"/etc/peertube/default.yaml
sed -i "s| tmp:.*| tmp: '/tmp/peertube/'|" "$pkgdir"/etc/peertube/production.yaml "$pkgdir"/etc/peertube/default.yaml
sed -i "s|tmp_persistent:.*|tmp_persistent: '/var/tmp/peertube/'|" "$pkgdir"/etc/peertube/production.yaml "$pkgdir"/etc/peertube/default.yaml
sed -i "s|logs:.*|logs: '/var/log/peertube/'|" "$pkgdir"/etc/peertube/production.yaml "$pkgdir"/etc/peertube/default.yaml
sed -i "s| peertube: ''| peertube: '@@SECRET_KEY@@'|" "$pkgdir"/etc/peertube/production.yaml
# docs and licenses
mv "$pkgdir"/usr/share/webapps/peertube/support/doc "$pkgdir"/usr/share/doc/$pkgname
mv "$pkgdir"/usr/share/webapps/peertube/*.md "$pkgdir"/usr/share/doc/peertube/.
mv "$pkgdir"/usr/share/webapps/peertube/LICENSE "$pkgdir"/usr/share/licenses/peertube/.
# delete arm64 prebuild
rm "$pkgdir"/usr/share/webapps/$pkgname/node_modules/fs-native-extensions/prebuilds/linux-arm64/node.napi.node
}
sha512sums="
91bcec34902f171ffe9ab3f27ab4422319f91430cab22965a5cf9887c5293152f7f85c6fc0f355820000daea0a49327aa66f20bb4cff3850e5e3d192f347c926 peertube-6.0.2.tar.gz
92de1155410848937eeff3bef480c4a074875b4236ce0b6bf4cd7213d00173e7766d130408419c85c4432a8445a03f5d4525e4283384d906d781510cc4fd8fc0 peertube-manage.sh
494bb4daf98fcd62b354eb6fae18ccff19bef1243de083a93e438680deef1d9039e30eff8870b6955c3c7b10638e6df6cbeb4fbdb7539979466f502bcc72c843 peertube.conf
5b4d3f47d0dc2ce991971ff61c604a1566811612cff91f7e6ed19b65d0830695649ddef9afff474d916a5e6764d74bb4fa6b5c12eb5e753d8fc381cdd38ab179 peertube.openrc
"

View file

@ -0,0 +1,15 @@
#!/bin/sh
BUNDLE_DIR='/usr/share/webapps/peertube'
cd $BUNDLE_DIR
if [ "$(id -un)" != 'peertube' ]; then
source /etc/conf.d/peertube
export NODE_ENV NODE_CONFIG_DIR
exec su peertube -c '"$0" "$@"' -- npm run "$@"
else
source /etc/conf.d/peertube
export NODE_ENV NODE_CONFIG_DIR
exec npm run "$@"
fi

View file

@ -0,0 +1,2 @@
NODE_CONFIG_DIR=/etc/peertube
NODE_ENV=production

View file

@ -0,0 +1,34 @@
#!/sbin/openrc-run
name="$RC_SVCNAME"
cfgfile="/etc/conf.d/$RC_SVCNAME.conf"
pidfile="/run/$RC_SVCNAME.pid"
working_directory="/usr/share/webapps/peertube"
command="/usr/bin/node"
command_args="dist/server.js"
command_user="peertube"
command_group="peertube"
start_stop_daemon_args=""
command_background="yes"
output_log="/var/log/peertube/$RC_SVCNAME.log"
depend() {
need redis
need postgresql
}
start_pre() {
cd "$working_directory"
checkpath --directory --owner $command_user:$command_group --mode 0775 \
/var/log/peertube \
/var/lib/peertube \
/var/tmp/peertube \
/tmp/peertube
export NODE_ENV NODE_CONFIG_DIR
}
stop_pre() {
ebegin "Killing child processes"
kill $(ps -o pid= --ppid $(cat $pidfile)) || true
}

View file

@ -0,0 +1,41 @@
#!/bin/sh
set -eu
group=www-data
config_file='/etc/peertube/production.yaml'
if grep '@@SECRET_KEY@@' "$config_file" >/dev/null; then
echo "* Generating random secret in $config_file" >&2
secret_key="$(openssl rand -hex 32)"
sed -i "s|@@SECRET_KEY@@|$secret_key|" "$config_file"
fi
if [ "${0##*.}" = 'post-upgrade' ]; then
cat >&2 <<-EOF
*
* To finish Peertube upgrade run:
*
*
EOF
else
cat >&2 <<-EOF
*
* 1. Adjust settings in /etc/peertube/production.yaml
*
* 2. Create database for Peertube:
*
* psql -c "CREATE ROLE peertube PASSWORD 'top-secret' INHERIT LOGIN;"
* psql -c "CREATE DATABASE peertube OWNER peertube ENCODING 'UTF-8';"
*
* 3. Start Peertube
*
* service peertube start
*
* 4. Create admin user
*
* peertube-manage reset-password -- -u root
*
EOF
fi

View file

@ -0,0 +1 @@
peertube.post-install

View file

@ -0,0 +1,25 @@
#!/bin/sh
DATADIR='/var/lib/peertube'
if ! getent group peertube 1>/dev/null; then
echo '* Creating group peertube' 1>&2
addgroup -S peertube
fi
if ! id peertube 2>/dev/null 1>&2; then
echo '* Creating user peertube' 1>&2
adduser -DHS -G peertube -h "$DATADIR" -s /bin/sh \
-g "added by apk for peertube" peertube
passwd -u peertube 1>/dev/null # unlock
fi
if ! id -Gn peertube | grep -Fq www-data; then
echo '* Adding user peertube to group www-data' 1>&2
addgroup peertube www-data
fi
exit 0