Skip to content

Commit

Permalink
net-im/coturn: sane logging defaults thanks to Andrey Utkin. New syst…
Browse files Browse the repository at this point in the history
…emd unit, see bug 605302

Package-Manager: Portage-2.3.3, Repoman-2.3.1
  • Loading branch information
Andreas Schuerch committed Apr 1, 2017
1 parent 41b5150 commit 781c7df
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright 1999-2016 Gentoo Foundation
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6
inherit eutils user
inherit eutils user systemd
DESCRIPTION="coturn TURN server project"
HOMEPAGE="https://github.com/${PN}/${PN}"

Expand Down Expand Up @@ -30,6 +30,10 @@ RDEPEND="dev-libs/libevent[ssl]
DEPEND="${RDEPEND}"

src_configure() {
sed 's:#log-file=/var/tmp/turn.log:log-file=/var/log/turnserver.log:' \
-i "${S}/examples/etc/turnserver.conf" || die "sed for logdir failed"
sed 's:#simple-log:simple-log:' -i "${S}/examples/etc/turnserver.conf" \
|| die "sed for simple-log failed"
if ! use mongodb; then
export TURN_NO_MONGO=yes
fi
Expand All @@ -52,12 +56,14 @@ src_configure() {
src_install() {
default
newinitd "${FILESDIR}/turnserver.init" turnserver
insinto /etc/logrotate.d
newins "${FILESDIR}/logrotate.${PN}" "${PN}"
systemd_dounit "${FILESDIR}/${PN}.service"
}

pkg_postinst() {
enewgroup turnserver
enewuser turnserver -1 -1 -1 turnserver
elog "Be aware that the default path for logfiles in coturn is /var/tmp!"
elog "You should copy /etc/turnserver.conf.default to"
elog "/etc/turnserver.conf and change not only the log option."
elog "You need to copy /etc/turnserver.conf.default to"
elog "/etc/turnserver.conf and do your settings there."
}
16 changes: 11 additions & 5 deletions net-im/coturn/coturn-9999.ebuild
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright 1999-2016 Gentoo Foundation
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6
inherit eutils user
inherit eutils user systemd
DESCRIPTION="coturn TURN server project"
HOMEPAGE="https://github.com/${PN}/${PN}"

Expand Down Expand Up @@ -30,6 +30,10 @@ RDEPEND="dev-libs/libevent[ssl]
DEPEND="${RDEPEND}"

src_configure() {
sed 's:#log-file=/var/tmp/turn.log:log-file=/var/log/turnserver.log:' \
-i "${S}/examples/etc/turnserver.conf" || die "sed for logdir failed"
sed 's:#simple-log:simple-log:' -i "${S}/examples/etc/turnserver.conf" \
|| die "sed for simple-log failed"
if ! use mongodb; then
export TURN_NO_MONGO=yes
fi
Expand All @@ -52,12 +56,14 @@ src_configure() {
src_install() {
default
newinitd "${FILESDIR}/turnserver.init" turnserver
insinto /etc/logrotate.d
newins "${FILESDIR}/logrotate.${PN}" "${PN}"
systemd_dounit "${FILESDIR}/${PN}.service"
}

pkg_postinst() {
enewgroup turnserver
enewuser turnserver -1 -1 -1 turnserver
elog "Be aware that the default path for logfiles in coturn is /var/tmp!"
elog "You should copy /etc/turnserver.conf.default to"
elog "/etc/turnserver.conf and change not only the log option."
elog "You need to copy /etc/turnserver.conf.default to"
elog "/etc/turnserver.conf and do your settings there."
}
17 changes: 17 additions & 0 deletions net-im/coturn/files/coturn.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=turnserver daemon
After=networking.target

[Service]
Type=simple
User=turnserver
Group=turnserver
PermissionsStartOnly=true
ExecStartPre=/bin/bash -c "[ -f /var/log/turnserver.log ] || touch /var/log/turnserver.log && chown turnserver:turnserver /var/log/turnserver.log && chmod 660 /var/log/turnserver.log"
ExecStartPre=/bin/bash -c "[ -d /var/run/turnserver ] || mkdir /var/run/turnserver && chown turnserver:turnserver /var/run/turnserver"
ExecStart=/usr/bin/turnserver --pidfile /var/run/turnserver/turnserver.pid
Restart=always
RestartSec=30s

[Install]
WantedBy=multi-user.target
15 changes: 15 additions & 0 deletions net-im/coturn/files/logrotate.coturn
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

/var/log/turnserver.log {
daily
rotate 7
create 660 turnserver turnserver
notifempty
size 50M
sharedscripts
missingok
postrotate
[ -f /var/run/turnserver/turnserver.pid ] && kill -HUP `cat /var/run/turnserver/turnserver.pid`
endscript
}
3 changes: 2 additions & 1 deletion net-im/coturn/files/turnserver.init
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/sbin/openrc-run
# Copyright 1999-2013 Gentoo Foundation
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2


Expand All @@ -13,6 +13,7 @@ depend() {
start() {
ebegin "Starting turnserver"
checkpath -q -d -m 0755 -o turnserver:turnserver /var/run/turnserver
checkpath -q -f -m 0660 -o turnserver:turnserver /var/log/turnserver.log
start-stop-daemon --start --user turnserver --exec /usr/bin/turnserver -- -o \
--pidfile /var/run/turnserver/turnserver.pid >/dev/null
eend $?
Expand Down

0 comments on commit 781c7df

Please sign in to comment.