r1
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
Sample configuration files for:
|
||||
```
|
||||
SystemD: agrariand.service
|
||||
Upstart: agrariand.conf
|
||||
OpenRC: agrariand.openrc
|
||||
agrariand.openrcconf
|
||||
CentOS: agrariand.init
|
||||
macOS: org.agrarian.agrariand.plist
|
||||
```
|
||||
have been made available to assist packagers in creating node packages here.
|
||||
|
||||
See doc/init.md for more information.
|
||||
@@ -0,0 +1,63 @@
|
||||
description "Agrarian Core Daemon"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on starting rc RUNLEVEL=[016]
|
||||
|
||||
env BITCOIND_BIN="/usr/bin/agrariand"
|
||||
env BITCOIND_USER="agrarian"
|
||||
env BITCOIND_GROUP="agrarian"
|
||||
env BITCOIND_PIDDIR="/var/run/agrariand"
|
||||
# upstart can't handle variables constructed with other variables
|
||||
env BITCOIND_PIDFILE="/var/run/agrariand/agrariand.pid"
|
||||
env BITCOIND_CONFIGFILE="/etc/agrarian/agrarian.conf"
|
||||
env BITCOIND_DATADIR="/var/lib/agrariand"
|
||||
|
||||
expect fork
|
||||
|
||||
respawn
|
||||
respawn limit 5 120
|
||||
kill timeout 60
|
||||
|
||||
pre-start script
|
||||
# this will catch non-existent config files
|
||||
# agrariand will check and exit with this very warning, but it can do so
|
||||
# long after forking, leaving upstart to think everything started fine.
|
||||
# since this is a commonly encountered case on install, just check and
|
||||
# warn here.
|
||||
if ! grep -qs '^rpcpassword=' "$BITCOIND_CONFIGFILE" ; then
|
||||
echo "ERROR: You must set a secure rpcpassword to run agrariand."
|
||||
echo "The setting must appear in $BITCOIND_CONFIGFILE"
|
||||
echo
|
||||
echo "This password is security critical to securing wallets "
|
||||
echo "and must not be the same as the rpcuser setting."
|
||||
echo "You can generate a suitable random password using the following"
|
||||
echo "command from the shell:"
|
||||
echo
|
||||
echo "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
|
||||
echo
|
||||
echo "It is recommended that you also set alertnotify so you are "
|
||||
echo "notified of problems:"
|
||||
echo
|
||||
echo "ie: alertnotify=echo %%s | mail -s \"Agrarian Alert\"" \
|
||||
"admin@foo.com"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$BITCOIND_PIDDIR"
|
||||
chmod 0755 "$BITCOIND_PIDDIR"
|
||||
chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_PIDDIR"
|
||||
chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_CONFIGFILE"
|
||||
chmod 0660 "$BITCOIND_CONFIGFILE"
|
||||
end script
|
||||
|
||||
exec start-stop-daemon \
|
||||
--start \
|
||||
--pidfile "$BITCOIND_PIDFILE" \
|
||||
--chuid $BITCOIND_USER:$BITCOIND_GROUP \
|
||||
--exec "$BITCOIND_BIN" \
|
||||
-- \
|
||||
-pid="$BITCOIND_PIDFILE" \
|
||||
-conf="$BITCOIND_CONFIGFILE" \
|
||||
-datadir="$BITCOIND_DATADIR" \
|
||||
-daemon
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# agrariand The Agrarian core server.
|
||||
#
|
||||
#
|
||||
# chkconfig: 345 80 20
|
||||
# description: agrariand
|
||||
# processname: agrariand
|
||||
#
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
|
||||
# you can override defaults in /etc/sysconfig/agrariand, see below
|
||||
if [ -f /etc/sysconfig/agrariand ]; then
|
||||
. /etc/sysconfig/agrariand
|
||||
fi
|
||||
|
||||
RETVAL=0
|
||||
|
||||
prog=agrariand
|
||||
# you can override the lockfile via BITCOIND_LOCKFILE in /etc/sysconfig/agrariand
|
||||
lockfile=${BITCOIND_LOCKFILE-/var/lock/subsys/agrariand}
|
||||
|
||||
# agrariand defaults to /usr/bin/agrariand, override with BITCOIND_BIN
|
||||
bitcoind=${BITCOIND_BIN-/usr/bin/agrariand}
|
||||
|
||||
# agrariand opts default to -disablewallet, override with BITCOIND_OPTS
|
||||
bitcoind_opts=${BITCOIND_OPTS}
|
||||
|
||||
start() {
|
||||
echo -n $"Starting $prog: "
|
||||
daemon $DAEMONOPTS $bitcoind $bitcoind_opts
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch $lockfile
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping $prog: "
|
||||
killproc $prog
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && rm -f $lockfile
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
status $prog
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: service $prog {start|stop|status|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,92 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
# backward compatibility for existing gentoo layout
|
||||
#
|
||||
if [ -d "/var/lib/agrarian/.agrarian" ]; then
|
||||
BITCOIND_DEFAULT_DATADIR="/var/lib/agrarian/.agrarian"
|
||||
else
|
||||
BITCOIND_DEFAULT_DATADIR="/var/lib/agrariand"
|
||||
fi
|
||||
|
||||
BITCOIND_CONFIGFILE=${BITCOIND_CONFIGFILE:-/etc/agrarian/agrarian.conf}
|
||||
BITCOIND_PIDDIR=${BITCOIND_PIDDIR:-/var/run/agrariand}
|
||||
BITCOIND_PIDFILE=${BITCOIND_PIDFILE:-${BITCOIND_PIDDIR}/agrariand.pid}
|
||||
BITCOIND_DATADIR=${BITCOIND_DATADIR:-${BITCOIND_DEFAULT_DATADIR}}
|
||||
BITCOIND_USER=${BITCOIND_USER:-${BITCOIN_USER:-agrarian}
|
||||
BITCOIND_GROUP=${BITCOIND_GROUP:-agrarian}
|
||||
BITCOIND_BIN=${BITCOIND_BIN:-/usr/bin/agrariand}
|
||||
BITCOIND_NICE=${BITCOIND_NICE:-${NICELEVEL:-0}}
|
||||
BITCOIND_OPTS="${BITCOIND_OPTS:-${BITCOIN_OPTS}}"
|
||||
|
||||
name="Agrarian Core Daemon"
|
||||
description="Agrarian crypto-currency p2p network daemon"
|
||||
|
||||
command="/usr/bin/agrariand"
|
||||
command_args="-pid=\"${BITCOIND_PIDFILE}\" \
|
||||
-conf=\"${BITCOIND_CONFIGFILE}\" \
|
||||
-datadir=\"${BITCOIND_DATADIR}\" \
|
||||
-daemon \
|
||||
${BITCOIND_OPTS}"
|
||||
|
||||
required_files="${BITCOIND_CONFIGFILE}"
|
||||
start_stop_daemon_args="-u ${BITCOIND_USER} \
|
||||
-N ${BITCOIND_NICE} -w 2000"
|
||||
pidfile="${BITCOIND_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="${BITCOIND_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 "${BITCOIND_USER}:${BITCOIND_GROUP}" \
|
||||
"${BITCOIND_DATADIR}"
|
||||
|
||||
checkpath \
|
||||
-d \
|
||||
--mode 0755 \
|
||||
--owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \
|
||||
"${BITCOIND_PIDDIR}"
|
||||
|
||||
checkpath -f \
|
||||
-o ${BITCOIND_USER}:${BITCOIND_GROUP} \
|
||||
-m 0660 \
|
||||
${BITCOIND_CONFIGFILE}
|
||||
|
||||
checkconfig || return 1
|
||||
}
|
||||
|
||||
checkconfig()
|
||||
{
|
||||
if ! grep -qs '^rpcpassword=' "${BITCOIND_CONFIGFILE}" ; then
|
||||
eerror ""
|
||||
eerror "ERROR: You must set a secure rpcpassword to run agrariand."
|
||||
eerror "The setting must appear in ${BITCOIND_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 recommended that you also set alertnotify so you are "
|
||||
eerror "notified of problems:"
|
||||
eerror ""
|
||||
eerror "ie: alertnotify=echo %%s | mail -s \"Agrarian Alert\"" \
|
||||
"admin@foo.com"
|
||||
eerror ""
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
# /etc/conf.d/agrariand: config file for /etc/init.d/agrariand
|
||||
|
||||
# Config file location
|
||||
#BITCOIND_CONFIGFILE="/etc/agrarian/agrarian.conf"
|
||||
|
||||
# What directory to write pidfile to? (created and owned by $BITCOIND_USER)
|
||||
#BITCOIND_PIDDIR="/var/run/agrariand"
|
||||
|
||||
# What filename to give the pidfile
|
||||
#BITCOIND_PIDFILE="${BITCOIND_PIDDIR}/agrariand.pid"
|
||||
|
||||
# Where to write agrariand data (be mindful that the blockchain is large)
|
||||
#BITCOIND_DATADIR="/var/lib/agrariand"
|
||||
|
||||
# User and group to own agrariand process
|
||||
#BITCOIND_USER="agrarian"
|
||||
#BITCOIND_GROUP="agrarian"
|
||||
|
||||
# Path to agrariand executable
|
||||
#BITCOIND_BIN="/usr/bin/agrariand"
|
||||
|
||||
# Nice value to run agrariand under
|
||||
#BITCOIND_NICE=0
|
||||
|
||||
# Additional options (avoid -conf and -datadir, use flags above)
|
||||
#BITCOIND_OPTS=""
|
||||
|
||||
# The timeout in seconds OpenRC will wait for bitcoind to terminate
|
||||
# after a SIGTERM has been raised.
|
||||
# Note that this will be mapped as argument to start-stop-daemon's
|
||||
# '--retry' option, which means you can specify a retry schedule
|
||||
# here. For more information see man 8 start-stop-daemon.
|
||||
BITCOIND_SIGTERM_TIMEOUT=60
|
||||
@@ -0,0 +1,44 @@
|
||||
# It is not recommended to modify this file in-place, because it will
|
||||
# be overwritten during package upgrades. If you want to add further
|
||||
# options or overwrite existing ones then use
|
||||
# $ systemctl edit bitcoind.service
|
||||
# See "man systemd.service" for details.
|
||||
|
||||
# Note that almost all daemon options could be specified in
|
||||
# /etc/agrarian/agrarian.conf
|
||||
|
||||
[Unit]
|
||||
Description=Agrarian daemon
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/agrariand -daemon -conf=/etc/agrarian/agrarian.conf -pid=/run/agrariand/agrariand.pid
|
||||
# Creates /run/agrariand owned by agrarian
|
||||
RuntimeDirectory=agrariand
|
||||
User=agrarian
|
||||
Type=forking
|
||||
PIDFile=/run/agrariand/agrariand.pid
|
||||
Restart=on-failure
|
||||
|
||||
# Hardening measures
|
||||
####################
|
||||
|
||||
# Provide a private /tmp and /var/tmp.
|
||||
PrivateTmp=true
|
||||
|
||||
# Mount /usr, /boot/ and /etc read-only for the process.
|
||||
ProtectSystem=full
|
||||
|
||||
# Disallow the process and all of its children to gain
|
||||
# new privileges through execve().
|
||||
NoNewPrivileges=true
|
||||
|
||||
# Use a new /dev namespace only populated with API pseudo devices
|
||||
# such as /dev/null, /dev/zero and /dev/random.
|
||||
PrivateDevices=true
|
||||
|
||||
# Deny the creation of writable and executable memory mappings.
|
||||
MemoryDenyWriteExecute=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>org.agrarian.agrariand</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/usr/local/bin/agrariand</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user