1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #!/sbin/openrc-run
-
- # backward compatibility for existing gentoo layout
- #
- if [ -d "/var/lib/starwels/.starwels" ]; then
- STARWELSD_DEFAULT_DATADIR="/var/lib/starwels/.starwels"
- else
- STARWELSD_DEFAULT_DATADIR="/var/lib/starwelsd"
- fi
-
- STARWELSD_CONFIGFILE=${STARWELSD_CONFIGFILE:-/etc/starwels/starwels.conf}
- STARWELSD_PIDDIR=${STARWELSD_PIDDIR:-/var/run/starwelsd}
- STARWELSD_PIDFILE=${STARWELSD_PIDFILE:-${STARWELSD_PIDDIR}/starwelsd.pid}
- STARWELSD_DATADIR=${STARWELSD_DATADIR:-${STARWELSD_DEFAULT_DATADIR}}
- STARWELSD_USER=${STARWELSD_USER:-${STARWELS_USER:-starwels}}
- STARWELSD_GROUP=${STARWELSD_GROUP:-starwels}
- STARWELSD_BIN=${STARWELSD_BIN:-/usr/bin/starwelsd}
- STARWELSD_NICE=${STARWELSD_NICE:-${NICELEVEL:-0}}
- STARWELSD_OPTS="${STARWELSD_OPTS:-${STARWELS_OPTS}}"
-
- name="Starwels Daemon"
- description="Starwels cryptocurrency P2P network daemon"
-
- command="/usr/bin/starwelsd"
- command_args="-pid=\"${STARWELSD_PIDFILE}\" \
- -conf=\"${STARWELSD_CONFIGFILE}\" \
- -datadir=\"${STARWELSD_DATADIR}\" \
- -daemon \
- ${STARWELSD_OPTS}"
-
- required_files="${STARWELSD_CONFIGFILE}"
- start_stop_daemon_args="-u ${STARWELSD_USER} \
- -N ${STARWELSD_NICE} -w 2000"
- pidfile="${STARWELSD_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")
- retry="${STARWELSD_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 \
- --owner "${STARWELSD_USER}:${STARWELSD_GROUP}" \
- "${STARWELSD_DATADIR}"
-
- checkpath \
- -d \
- --mode 0755 \
- --owner "${STARWELSD_USER}:${STARWELSD_GROUP}" \
- "${STARWELSD_PIDDIR}"
-
- checkpath -f \
- -o ${STARWELSD_USER}:${STARWELSD_GROUP} \
- -m 0660 \
- ${STARWELSD_CONFIGFILE}
-
- checkconfig || return 1
- }
-
- checkconfig()
- {
- if ! grep -qs '^rpcpassword=' "${STARWELSD_CONFIGFILE}" ; then
- eerror ""
- eerror "ERROR: You must set a secure rpcpassword to run starwelsd."
- eerror "The setting must appear in ${STARWELSD_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 ""
- eerror "ie: alertnotify=echo %%s | mail -s \"Starwels Alert\"" \
- "admin@foo.com"
- eerror ""
- return 1
- fi
- }
|