View previous topic :: View next topic |
Author |
Message |
Ralphred l33t
Joined: 31 Dec 2013 Posts: 709
|
Posted: Mon Jan 27, 2025 9:04 am Post subject: Looking for feedback on init scripts |
|
|
So a friend of mine has been setting up some Gentoo hosts for XMR mining using monerod and p2pool. The software "seems fine" but is always demonstrated as "extract to ./, then run ./<command> <options>". One of the packages from ::guru has an init script but it's a bit simplistic, the other doesn't.
As the topic suggests, I'd like some feedback to make these more stable/reliable in situations I've overlooked: /etc.conf.d/p2pool: | P2POOL_USR="monero"
P2POOL_GRP="monero"
P2POOL_DIR="/var/p2pool" #see --data-dir in docs
# Connect to host/port
ARGS="--host 10.0.0.248"
ARGS="${ARGS} --zmq-port 18083"
# Listen on ip:port
ARGS="${ARGS} --p2p 10.0.0.248:37889"
#ARGS="${ARGS} --p2p 10.0.0.248:37888 --mini" #comment out the above line is using this
# Other config
ARGS="${ARGS} --wallet replace_with_your_wallet_string"
ARGS="${ARGS} --data-dir ${P2POOL_DIR}" |
/etc/init.d/p2pool: | #!/sbin/openrc-run
name="P2Pool Daemon"
description="Connects crypto mining apps to a Monero daemon"
pidfile="/var/run/p2pool.pid"
command=/usr/bin/p2pool
command_args="${ARGS}"
supervisor=supervise-daemon
supervise_daemon_args="-u ${P2POOL_USR} -g ${P2POOL_GRP} -m 3 --respawn-period 40 -1 /var/log/p2pool.log -2 /var/log/p2pool_err.log -d ${P2POOL_DIR}"
depend() {
need localmount
need net
want monerod
}
start_pre() {
checkpath -o ${P2POOL_USR}:${P2POOL_GRP} -d ${P2POOL_DIR}
if [ ! -c ${P2POOL_DIR}/p2pool.log ];then
[ -e ${P2POOL_DIR}/p2pool.log ] && rm -rf ${P2POOL_DIR}/p2pool.log
ln -s /dev/null ${P2POOL_DIR}/p2pool.log;
fi
checkpath -o ${P2POOL_USR}:${P2POOL_GRP} -f /var/log/p2pool.log /var/log/p2pool_err.log
} |
/etc/conf.d/monero: | monerod_args="--config-file /etc/monero/monerod.conf --non-interactive"
monerod_user=monero
monerod_group=monerod |
/etc/init.d/monerod: | #!/sbin/openrc-run
# Copyright 2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
pidfile=/var/run/monerod.pid
command=/usr/bin/monerod
command_args="${monerod_args}"
supervisor=supervise-daemon
supervise_daemon_args="-u ${monerod_user} -g ${monerod_group} -m 3 --respawn-period 40"
name="Monero P2P Daemon"
description="Connects to the Monero P2P network"
depend() {
need localmount
need net
}
start_pre() {
#defaults
data_dir="/var/lib/monero"
log_file="/var/log/monero/monero.log"
#try to grab non-defaults from /etc/monero/monero.conf
grep -q "^data-dir=" /etc/monero/monerod.conf && data_dir=$(awk '/^data-dir=/{print$1}' /etc/monero/monerod.conf|sed 's/data-dir=//')
grep -q "^log-file=" /etc/monero/monerod.conf && log_file=$(awk '/^log-file=/{print$1}' /etc/monero/monerod.conf|sed 's/log-file=//')
#sanity checks
checkpath -o ${monerod_user}:${monerod_group} -d ${data_dir}
checkpath -d $(dirname ${log_file})
checkpath -o ${monerod_user}:${monerod_group} -f ${log_file}
} | As I'm also trying to pull the configured directory/files /etc/monero/monerod.conf snippet: | ...
## database storage
data-dir=/mnt/storage/xmr-blockchain
#prune-blockchain=1
...
## logging
log-file=/var/log/monerod.log
... |
|
|
Back to top |
|
|
grknight Retired Dev
Joined: 20 Feb 2015 Posts: 1995
|
Posted: Mon Jan 27, 2025 1:48 pm Post subject: |
|
|
To be more portable between supervisors and explicit in meaning, I recommend the following should be expanded:
/etc/init.d/p2pool: | supervise_daemon_args="-u ${P2POOL_USR} -g ${P2POOL_GRP} -m 3 --respawn-period 40 -1 /var/log/p2pool.log -2 /var/log/p2pool_err.log -d ${P2POOL_DIR}" | to
/etc/init.d/p2pool: | command_user="${P2POOL_USR}:${P2POOL_GRP}"
directory="${P2POOL_DIR}"
respawn_max="3"
respawn_period="40"
output_log="/var/log/p2pool.log"
error_log="/var/log/p2pool_err.log" |
/etc/init.d/monerod: | supervise_daemon_args="-u ${monerod_user} -g ${monerod_group} -m 3 --respawn-period 40" | to /etc/init.d/monerod: | command_user="${monerod_user}:${monerod_group}"
respawn_max="3"
respawn_period="40" |
|
|
Back to top |
|
|
Ralphred l33t
Joined: 31 Dec 2013 Posts: 709
|
Posted: Mon Jan 27, 2025 4:31 pm Post subject: |
|
|
grknight wrote: | <Helpful things> | Thanks, just the sort of constructive criticism I was hoping for. |
|
Back to top |
|
|
|