neobytes/contrib/init/neobytesd.openrc

93 lines
2.7 KiB
Plaintext
Raw Normal View History

#!/sbin/runscript
# backward compatibility for existing gentoo layout
#
2024-12-16 19:40:22 +01:00
if [ -d "/var/lib/neobytes/.neobytes" ]; then
NEOBYTESD_DEFAULT_DATADIR="/var/lib/neobytes/.neobytes"
else
2024-12-16 19:40:22 +01:00
NEOBYTESD_DEFAULT_DATADIR="/var/lib/neobytesd"
fi
2024-12-16 19:40:22 +01:00
NEOBYTESD_CONFIGFILE=${NEOBYTESD_CONFIGFILE:-/etc/neobytes/neobytes.conf}
NEOBYTESD_PIDDIR=${NEOBYTESD_PIDDIR:-/var/run/neobytesd}
NEOBYTESD_PIDFILE=${NEOBYTESD_PIDFILE:-${NEOBYTESD_PIDDIR}/neobytesd.pid}
NEOBYTESD_DATADIR=${NEOBYTESD_DATADIR:-${NEOBYTESD_DEFAULT_DATADIR}}
NEOBYTESD_USER=${NEOBYTESD_USER:-${NEOBYTES_USER:-neobytes}}
NEOBYTESD_GROUP=${NEOBYTESD_GROUP:-neobytes}
NEOBYTESD_BIN=${NEOBYTESD_BIN:-/usr/bin/neobytesd}
NEOBYTESD_NICE=${NEOBYTESD_NICE:-${NICELEVEL:-0}}
NEOBYTESD_OPTS="${NEOBYTESD_OPTS:-${NEOBYTES_OPTS}}"
2024-12-16 19:40:22 +01:00
name="Neobytes Core Daemon"
description="Neobytes cryptocurrency P2P network daemon"
2024-02-05 23:00:22 +01:00
command="/usr/bin/neobytesd"
2024-12-16 19:40:22 +01:00
command_args="-pid=\"${NEOBYTESD_PIDFILE}\" \
-conf=\"${NEOBYTESD_CONFIGFILE}\" \
-datadir=\"${NEOBYTESD_DATADIR}\" \
-daemon \
2024-12-16 19:40:22 +01:00
${NEOBYTESD_OPTS}"
2024-12-16 19:40:22 +01:00
required_files="${NEOBYTESD_CONFIGFILE}"
start_stop_daemon_args="-u ${NEOBYTESD_USER} \
-N ${NEOBYTESD_NICE} -w 2000"
pidfile="${NEOBYTESD_PIDFILE}"
# The retry schedule to use when stopping the daemon. Could be either
# a timeout in seconds or multiple signal/timeout pairs (like
# "SIGKILL/180 SIGTERM/300")
2024-12-16 19:40:22 +01:00
retry="${NEOBYTESD_SIGTERM_TIMEOUT}"
depend() {
need localmount net
}
# verify
# 1) that the datadir exists and is writable (or create it)
# 2) that a directory for the pid exists and is writable
# 3) ownership and permissions on the config file
start_pre() {
checkpath \
-d \
--mode 0750 \
2024-12-16 19:40:22 +01:00
--owner "${NEOBYTESD_USER}:${NEOBYTESD_GROUP}" \
"${NEOBYTESD_DATADIR}"
checkpath \
-d \
--mode 0755 \
2024-12-16 19:40:22 +01:00
--owner "${NEOBYTESD_USER}:${NEOBYTESD_GROUP}" \
"${NEOBYTESD_PIDDIR}"
checkpath -f \
2024-12-16 19:40:22 +01:00
-o ${NEOBYTESD_USER}:${NEOBYTESD_GROUP} \
-m 0660 \
2024-12-16 19:40:22 +01:00
${NEOBYTESD_CONFIGFILE}
checkconfig || return 1
}
checkconfig()
{
2024-12-16 19:40:22 +01:00
if ! grep -qs '^rpcpassword=' "${NEOBYTESD_CONFIGFILE}" ; then
eerror ""
2024-02-05 23:00:22 +01:00
eerror "ERROR: You must set a secure rpcpassword to run neobytesd."
2024-12-16 19:40:22 +01:00
eerror "The setting must appear in ${NEOBYTESD_CONFIGFILE}"
eerror ""
eerror "This password is security critical to securing wallets "
eerror "and must not be the same as the rpcuser setting."
eerror "You can generate a suitable random password using the following"
eerror "command from the shell:"
eerror ""
eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
eerror ""
eerror "It is also recommended that you also set alertnotify so you are "
eerror "notified of problems:"
eerror ""
2024-12-16 19:40:22 +01:00
eerror "ie: alertnotify=echo %%s | mail -s \"Neobytes Core Alert\"" \
"admin@foo.com"
eerror ""
return 1
fi
}