1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-19 09:15:30 +03:00
aports/testing/i2pd/i2pd.initd
opal hart 262b38de90 testing/i2pd: Allow for use with syslog
Currently the init script for i2pd expects I2PD_LOG to be set and
proceeds to touch the file on service start. However, i2pd is allowed to
log to stdout/syslog which does not require this log file to be created.
This patch removes the mandation that I2PD_LOG be set in
/etc/conf.d/i2pd and will only touch the file if the log variable is
set. For anyone using the default log-to-file settings, there is no
noticeable change in functionality.
2018-11-01 15:29:26 +00:00

52 lines
1.4 KiB
Text

#!/sbin/openrc-run
# Copyright 1999-2016 Gentoo Foundation
# Copyright 2018 l-n-s <supervillain@riseup.net>
# Distributed under the terms of the GNU General Public License v2
description="C++ daemon for accessing the I2P network"
description_graceful="Graceful shutdown, takes 10 minutes"
command="/usr/sbin/i2pd"
command_args="${I2PD_OPTIONS}"
user="${I2PD_USER}:${I2PD_GROUP}"
start_stop_daemon_args="
--user \"${user}\"
--pidfile \"${I2PD_PID}\"
--progress
"
retry="SIGTERM/20/SIGKILL/20"
I2PD_PID_DIR=$(dirname "${I2PD_PID}")
extra_started_commands="graceful"
depend() {
need net
after firewall
use dns logger netmount
}
start_pre() {
if [ -z "${I2PD_USER}" ] || \
[ -z "${I2PD_GROUP}" ] || \
[ -z "${I2PD_PID}" ] || \
[ -z "${I2PD_OPTIONS}" ] ; then
eerror "Not all variables I2PD_USER, I2PD_GROUP, I2PD_PID, I2PD_OPTIONS are defined."
eerror "Check your /etc/conf.d/i2pd."
return 1
fi
if [ -n "${I2PD_LOG}" ]; then
checkpath -f -o "${user}" "${I2PD_LOG}"
fi
checkpath -d -m 0750 -o "${user}" "${I2PD_PID_DIR}"
}
graceful() {
# on SIGINT, i2pd stops accepting tunnels and shuts down in 600 seconds
ebegin "Gracefully stopping i2pd, this takes 10 minutes"
mark_service_stopping
eval start-stop-daemon --stop ${start_stop_daemon_args} \
--exec "${command}" --retry 'SIGINT/620/SIGTERM/20/SIGKILL/20'
eend $? && mark_service_stopped
}