Commit 9ef27122 authored by Natanael Copa's avatar Natanael Copa

main/tinyproxy: modernize, update initd script, and split -openrc

- modernize APKBUILD
- import updated initd script from Gentoo
- use /run instead of /var/run
- split -openrc subpackage
parent 739e583b
......@@ -2,7 +2,7 @@
# Maintainer: Michael Mason <ms13sp@gmail.com>
pkgname=tinyproxy
pkgver=1.10.0
pkgrel=1
pkgrel=2
pkgdesc="Lightweight HTTP proxy"
pkgusers="tinyproxy"
pkggroups="tinyproxy"
......@@ -12,23 +12,17 @@ license="GPL-2.0-or-later"
depends=
makedepends="asciidoc"
install="tinyproxy.pre-install"
subpackages="$pkgname-doc"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://github.com/$pkgname/$pkgname/releases/download/$pkgver/$pkgname-$pkgver.tar.gz
tinyproxy.initd"
_builddir="$srcdir/$pkgname-$pkgver"
builddir="$srcdir/$pkgname-$pkgver"
prepare() {
cd "$_builddir"
for i in $source; do
case $i in
*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
esac
done
default_prepare
# set default user to tinyproxy:tinyproxy and correct pidfile
sed -i -e 's:^User.*:User tinyproxy:' \
-e 's:^Group.*:Group tinyproxy:' \
-e 's:^PidFile.*:PidFile "/var/run/tinyproxy/tinyproxy.pid":' \
-e 's:^PidFile.*:PidFile "/run/tinyproxy/tinyproxy.pid":' \
etc/tinyproxy.conf.in
}
......@@ -41,18 +35,17 @@ build() {
--localstatedir=/var \
--sysconfdir=/etc \
--disable-dependency-tracking \
--enable-reverse \
|| return 1
make || return 1
--enable-reverse
make
}
package() {
cd "$_builddir"
make DESTDIR="$pkgdir" install || return 1
install -d -D -o tinyproxy -g tinyproxy "$pkgdir"/var/run/tinyproxy
make DESTDIR="$pkgdir" install
install -d -D -o tinyproxy -g tinyproxy "$pkgdir"/run/tinyproxy
install -d -D -o tinyproxy -g tinyproxy "$pkgdir"/var/log/tinyproxy
install -Dm755 "$srcdir"/tinyproxy.initd "$pkgdir"/etc/init.d/tinyproxy
}
sha512sums="53187adef865672a6c29f126189cf896bd02f8b0789ee2ee00b82d93b952c70dacdd2c82b0845392e518560e75e6ee107ce7662d1ec71108f293ba1d7de6aa2a tinyproxy-1.10.0.tar.gz
7ef08d290acec161d0c2257885c10bc5c827a72bcc67d842c4a0396d114d1f6acabd40643e051f4c233798b449046e8c8a449ebe404f9ac4c93238adbff7909b tinyproxy.initd"
cd440ed686e8128ed46441ca29da8376c4d28e9e34ae9b85c18eb2f1681d60c0c04b79401a7368f917eeab6768965d6c867d0ac6578a7858557c11b356446c02 tinyproxy.initd"
#!/sbin/openrc-run
# Copyright 1999-2004 Gentoo Foundation
# Copyright 1999-2018 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-proxy/tinyproxy/files/tinyproxy.initd,v 1.1 2008/02/16 07:11:25 mrness Exp $
CONFFILE="/etc/tinyproxy/${SVCNAME}.conf"
get_config() {
res=$(awk '$1 == "'$1'" { s=$2 } END { print s }' "$CONFFILE")
depend() {
use logger dns
need net
after firewall
if [ "x$res" = "x" ]; then
echo "$2"
else
eval echo "$res"
fi
}
checkconfig() {
if [ ! -f "${CONFFILE}" ]; then
eerror "Configuration file ${CONFFILE} not found!"
return 1
fi
: ${CONFFILE:="/etc/${SVCNAME}/${SVCNAME}.conf"}
PIDFILE=$(sed -n -e 's/^[[:space:]]*PidFile[[:space:]]\+"\(.*\)"[[:space:]]*$/\1/p' "${CONFFILE}")
return 0
}
command=/usr/bin/tinyproxy
command_args="-c ${CONFFILE}"
pidfile=$(get_config PidFile /run/tinyproxy/${SVCNAME}.pid)
depend() {
config "$CONFFILE"
use dns
start() {
checkconfig || return 1
checkpath --directory --owner tinyproxy:tinyproxy /var/run/tinyproxy
ebegin "Starting tinyproxy"
if [ -n "${PIDFILE}" ]; then
start-stop-daemon --start --pidfile "${PIDFILE}" --startas /usr/bin/tinyproxy -- -c "${CONFFILE}"
else
start-stop-daemon --start --exec /usr/bin/tinyproxy -- -c "${CONFFILE}"
fi
eend $?
[ "$(get_config Syslog Off)" = "On" ] && \
use logger
}
stop() {
checkconfig || return 1
start_pre() {
piddir=$(dirname ${pidfile})
ebegin "Stopping tinyproxy"
if [ -n "${PIDFILE}" ]; then
start-stop-daemon --stop --pidfile "${PIDFILE}"
else
start-stop-daemon --stop --exec /usr/bin/tinyproxy
fi
eend $?
if [ "${piddir}" = "/run" ]; then
eerror "Please change your PidFile settings to be within the"
eerror "/run/tinyproxy directory"
eend 1
else
checkpath -d -o $(get_config User tinyproxy):$(get_config Group tinyproxy) ${piddir}
fi
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment