Add new production installation script and related files

This commit is contained in:
wiz
2022-03-07 20:25:48 +01:00
parent 09e3791cee
commit 1e87c3857b
16 changed files with 1828 additions and 57 deletions

View File

@@ -0,0 +1,39 @@
zfs_enable="YES"
sendmail_enable="NONE"
clear_tmp_enable="YES"
syslogd_flags="-b 127.0.0.1"
dumpdev="NO"
hostname="mempool.local"
ifconfig_genet0="DHCP"
local_unbound_enable="YES"
ntpdate_enable="YES"
ntpdate_hosts="time.nist.gov"
sshd_enable="NO"
openssh_enable="YES"
openssh_flags=" \
-o 'Port 22' \
-o 'UseDNS no' \
-o 'KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256' \
-o 'AuthenticationMethods publickey,keyboard-interactive' \
-o 'PermitRootLogin no' \
"
firewall_enable="YES"
firewall_quiet="YES"
firewall_type="workstation"
firewall_myservices="8333/tcp"
firewall_allowservices="any"
firewall_logdeny="YES"
firewall_trusted="192.168.0.0/16,172.16.0.0/12,10.0.0.0/8"
bitcoin_enable="YES"
bitcoin_testnet_enable="YES"
nginx_enable="YES"
tor_enable="YES"
mysql_enable="YES"
mysql_dbdir="/mysql"

View File

@@ -0,0 +1,179 @@
#!/bin/sh
# PROVIDE: bitcoin
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable :
# bitcoin_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable bitcoin
# bitcoin_user (str) Set to "bitcoin" by default.
# bitcoin_group (str) Set to "bitcoin" by default.
# bitcoin_conf (str) Set to "/bitcoin/bitcoin.conf" by default.
# bitcoin_data_dir (str) Set to "/bitcoin" by default.
# bitcoin_syslog_facility(str) Set to "local0" by default.
# bitcoin_syslog_priority(str) Set to "info" by default.
# bitcoinlimits_enable (bool) Set to "NO" by default.
# Set it to "YES" to enable bitcoinlimits
# bitcoinlimits_args Set to "-e -U ${bitcoin_user}" by default
. /etc/rc.subr
name="bitcoin"
rcvar=bitcoin_enable
start_precmd="bitcoin_precmd"
start_cmd="bitcoin_start"
restart_precmd="bitcoin_checkconfig"
reload_precmd="bitcoin_checkconfig"
configtest_cmd="bitcoin_checkconfig"
status_cmd="bitcoin_status"
stop_cmd="bitcoin_stop"
stop_postcmd="bitcoin_wait"
command="/usr/local/bin/bitcoind"
daemon_command="/usr/sbin/daemon"
extra_commands="configtest"
pidfile="/bitcoin/bitcoind.pid"
: ${bitcoin_enable:="NO"}
: ${bitcoinlimits_enable:="NO"}
load_rc_config ${name}
: ${bitcoin_user:="bitcoin"}
: ${bitcoin_group:="bitcoin"}
: ${bitcoin_data_dir:="/bitcoin"}
: ${bitcoin_config_file:="/bitcoin/bitcoin.conf"}
: ${bitcoin_syslog_facility:="local0"}
: ${bitcoin_syslog_priority:="info"}
: ${bitcoin_syslog_tag:="bitcoin"}
: ${bitcoin_kill_after:="300"}
: ${bitcoinlimits_args:="-e -U ${bitcoin_user}"}
# set up dependant variables
procname="${command}"
required_files="${bitcoin_config_file}"
pidfile="${bitcoin_data_dir}/bitcoind.pid"
bitcoin_checkconfig()
{
echo "Performing sanity check on bitcoin configuration:"
if [ ! -d "${bitcoin_data_dir}" ]
then
echo "Missing data directory: ${bitcoin_data_dir}"
exit 1
fi
chown -R "${bitcoin_user}:${bitcoin_group}" "${bitcoin_data_dir}"
if [ ! -f "${bitcoin_config_file}" ]
then
echo "Missing configuration file: ${bitcoin_config_file}"
exit 1
fi
if [ ! -x "${command}" ]
then
echo "Missing executable: ${command}"
exit 1
fi
return 0
}
bitcoin_cleanup()
{
rm -f "${pidfile}"
}
bitcoin_precmd()
{
bitcoin_checkconfig
pid=$(check_pidfile "${pidfile}" "${procname}")
if [ -z "${pid}" ]
then
echo "Bitcoind is not running"
rm -f "${pidfile}"
fi
if checkyesno bitcoinlimits_enable
then
eval $(/usr/bin/limits ${bitcoinlimits_args}) 2>/dev/null
else
return 0
fi
}
bitcoin_status()
{
local pid
pid=$(check_pidfile "${pidfile}" "${procname}")
if [ -z "${pid}" ]
then
echo "Bitcoind is not running"
return 1
else
echo "Bitcoind running, pid: ${pid}"
fi
}
bitcoin_start()
{
echo "Starting bitcoin:"
cd "${bitcoin_data_dir}" || return 1
${daemon_command} \
-u "${bitcoin_user}" \
-l "${bitcoin_syslog_facility}" \
-s "${bitcoin_syslog_priority}" \
-T "${bitcoin_syslog_tag}" \
${command} \
-printtoconsole=1 \
-conf="${bitcoin_config_file}" \
-datadir="${bitcoin_data_dir}"
}
bitcoin_stop()
{
echo "Stopping bitcoin:"
pid=$(check_pidfile "${pidfile}" "${procname}")
if [ -z "${pid}" ]
then
echo "Bitcoind is not running"
return 1
else
kill ${pid}
fi
}
bitcoin_wait()
{
local n="${bitcoin_kill_after}"
echo "Waiting for bitcoin shutdown:"
while :
do
printf '.'
pid=$(check_pidfile "${pidfile}" "${procname}")
if [ -z "${pid}" ]
then
printf '\n'
break
fi
sleep 1
n=$((${n} - 1))
if [ ${n} -eq 0 -a -f "${pidfile}" ]
then
printf "\nForce shutdown"
kill -9 $(cat "${pidfile}")
for n in 1 2 3
do
printf '.'
sleep 1
done
printf '\n'
break
fi
done
rm -f "${pidfile}"
echo "Shutdown complete"
}
run_rc_command "$1"

View File

@@ -0,0 +1,180 @@
#!/bin/sh
# PROVIDE: bitcoin_testnet
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable :
# bitcoin_testnet_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable bitcoin
# bitcoin_testnet_user (str) Set to "bitcoin" by default.
# bitcoin_testnet_group (str) Set to "bitcoin" by default.
# bitcoin_testnet_conf (str) Set to "/bitcoin/bitcoin.conf" by default.
# bitcoin_testnet_data_dir (str) Set to "/var/db/bitcoin" by default.
# bitcoin_testnet_syslog_facility(str) Set to "local0" by default.
# bitcoin_testnet_syslog_priority(str) Set to "info" by default.
# bitcoinlimits_enable (bool) Set to "NO" by default.
# Set it to "YES" to enable bitcoinlimits
# bitcoinlimits_args Set to "-e -U ${bitcoin_testnet_user}" by default
. /etc/rc.subr
name="bitcoin_testnet"
rcvar=bitcoin_testnet_enable
start_precmd="bitcoin_testnet_precmd"
start_cmd="bitcoin_testnet_start"
restart_precmd="bitcoin_testnet_checkconfig"
reload_precmd="bitcoin_testnet_checkconfig"
configtest_cmd="bitcoin_testnet_checkconfig"
status_cmd="bitcoin_testnet_status"
stop_cmd="bitcoin_testnet_stop"
stop_postcmd="bitcoin_testnet_wait"
command="/usr/local/bin/bitcoind"
daemon_command="/usr/sbin/daemon"
extra_commands="configtest"
pidfile="/bitcoin/bitcoin.pid"
: ${bitcoin_testnet_enable:="NO"}
: ${bitcoinlimits_enable:="NO"}
load_rc_config ${name}
: ${bitcoin_testnet_user:="bitcoin"}
: ${bitcoin_testnet_group:="bitcoin"}
: ${bitcoin_testnet_data_dir:="/bitcoin"}
: ${bitcoin_testnet_config_file:="/bitcoin/bitcoin.conf"}
: ${bitcoin_testnet_syslog_facility:="local0"}
: ${bitcoin_testnet_syslog_priority:="info"}
: ${bitcoin_testnet_syslog_tag:="bitcoin"}
: ${bitcoin_testnet_kill_after:="300"}
: ${bitcoinlimits_args:="-e -U ${bitcoin_testnet_user}"}
# set up dependant variables
procname="${command}"
required_files="${bitcoin_testnet_config_file}"
pidfile="${bitcoin_testnet_data_dir}/testnet3/bitcoind.pid"
bitcoin_testnet_checkconfig()
{
echo "Performing sanity check on bitcoin configuration:"
if [ ! -d "${bitcoin_testnet_data_dir}" ]
then
echo "Missing data directory: ${bitcoin_testnet_data_dir}"
exit 1
fi
chown -R "${bitcoin_testnet_user}:${bitcoin_testnet_group}" "${bitcoin_testnet_data_dir}"
if [ ! -f "${bitcoin_testnet_config_file}" ]
then
echo "Missing configuration file: ${bitcoin_testnet_config_file}"
exit 1
fi
if [ ! -x "${command}" ]
then
echo "Missing executable: ${command}"
exit 1
fi
return 0
}
bitcoin_testnet_cleanup()
{
rm -f "${pidfile}"
}
bitcoin_testnet_precmd()
{
bitcoin_testnet_checkconfig
pid=$(check_pidfile "${pidfile}" "${procname}")
if [ -z "${pid}" ]
then
echo "Bitcoind is not running"
rm -f "${pidfile}"
fi
if checkyesno bitcoinlimits_enable
then
eval $(/usr/bin/limits ${bitcoinlimits_args}) 2>/dev/null
else
return 0
fi
}
bitcoin_testnet_status()
{
local pid
pid=$(check_pidfile "${pidfile}" "${procname}")
if [ -z "${pid}" ]
then
echo "Bitcoind is not running"
return 1
else
echo "Bitcoind running, pid: ${pid}"
fi
}
bitcoin_testnet_start()
{
echo "Starting bitcoin:"
cd "${bitcoin_testnet_data_dir}" || return 1
${daemon_command} \
-u "${bitcoin_testnet_user}" \
-l "${bitcoin_testnet_syslog_facility}" \
-s "${bitcoin_testnet_syslog_priority}" \
-T "${bitcoin_testnet_syslog_tag}" \
${command} \
-testnet \
-printtoconsole=1 \
-conf="${bitcoin_testnet_config_file}" \
-datadir="${bitcoin_testnet_data_dir}"
}
bitcoin_testnet_stop()
{
echo "Stopping bitcoin:"
pid=$(check_pidfile "${pidfile}" "${procname}")
if [ -z "${pid}" ]
then
echo "Bitcoind is not running"
return 1
else
kill ${pid}
fi
}
bitcoin_testnet_wait()
{
local n="${bitcoin_testnet_kill_after}"
echo "Waiting for bitcoin shutdown:"
while :
do
printf '.'
pid=$(check_pidfile "${pidfile}" "${procname}")
if [ -z "${pid}" ]
then
printf '\n'
break
fi
sleep 1
n=$((${n} - 1))
if [ ${n} -eq 0 -a -f "${pidfile}" ]
then
printf "\nForce shutdown"
kill -9 $(cat "${pidfile}")
for n in 1 2 3
do
printf '.'
sleep 1
done
printf '\n'
break
fi
done
rm -f "${pidfile}"
echo "Shutdown complete"
}
run_rc_command "$1"

View File

@@ -0,0 +1,12 @@
--- a/src/raw.rs 2020-10-22 05:59:43.747207000 +0000
+++ b/src/raw2.rs 2020-10-22 06:00:04.016688000 +0000
@@ -82,9 +82,6 @@
Sc2CharTerm = sc!(_SC_2_CHAR_TERM),
Sc2CVersion = 96, // TODO(joshlf): Switch to a libc constant once it's added
Sc2Upe = sc!(_SC_2_UPE),
- ScXbs5Ilp32Off32 = sc!(_SC_XBS5_ILP32_OFF32),
- ScXbs5Ilp32Offbig = sc!(_SC_XBS5_ILP32_OFFBIG),
- ScXbs5LpbigOffbig = sc!(_SC_XBS5_LPBIG_OFFBIG),
}
/// Query the system's configuration.

View File

@@ -0,0 +1,3 @@
local0.info /var/log/bitcoind.mainnet
local1.info /var/log/bitcoind.testnet
local2.info /var/log/elementsd.liquid