2019-06-15 23:02:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
2021-01-02 01:33:51 +00:00
|
|
|
shopt -s nullglob
|
2019-06-15 23:02:44 +00:00
|
|
|
|
|
|
|
source /usr/share/mynode/mynode_config.sh
|
2020-09-07 21:13:45 +00:00
|
|
|
source /usr/share/mynode/mynode_app_versions.sh
|
2019-06-15 23:02:44 +00:00
|
|
|
|
|
|
|
# Verify FS is mounted as R/W
|
|
|
|
if [ ! -w / ]; then
|
2020-04-09 01:42:49 +00:00
|
|
|
touch /tmp/sd_rw_error
|
2019-06-15 23:02:44 +00:00
|
|
|
mount -o remount,rw /;
|
|
|
|
fi
|
|
|
|
|
2020-04-07 17:08:38 +00:00
|
|
|
# Set sticky bit on /tmp
|
|
|
|
chmod +t /tmp
|
|
|
|
|
2020-01-16 02:53:50 +00:00
|
|
|
# Make sure resolv.conf is a symlink to so resolvconf works
|
2020-01-20 03:25:45 +00:00
|
|
|
# if [ ! -h /etc/resolv.conf ]; then
|
|
|
|
# rm -f /etc/resolv.conf
|
2020-01-21 01:33:58 +00:00
|
|
|
# mkdir -p /etc/resolvconf/run/
|
2020-01-20 03:25:45 +00:00
|
|
|
# touch /etc/resolvconf/run/resolv.conf
|
|
|
|
# ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf
|
|
|
|
|
|
|
|
# sync
|
|
|
|
# reboot
|
|
|
|
# sleep 10s
|
|
|
|
# exit 1
|
|
|
|
# fi
|
2020-04-07 17:08:38 +00:00
|
|
|
|
2020-01-20 03:25:45 +00:00
|
|
|
# Add some DNS servers to make domain lookup more likely
|
2021-02-27 22:51:36 +00:00
|
|
|
needDns=0
|
|
|
|
grep "Added at myNode startup" /etc/resolv.conf || needDns=1
|
|
|
|
if [ $needDns = 1 ]; then
|
|
|
|
echo '' >> /etc/resolv.conf
|
|
|
|
echo '# Added at myNode startup' >> /etc/resolv.conf
|
|
|
|
echo 'nameserver 1.1.1.1' >> /etc/resolv.conf
|
|
|
|
echo 'nameserver 208.67.222.222' >> /etc/resolv.conf
|
|
|
|
echo 'nameserver 8.8.8.8' >> /etc/resolv.conf
|
|
|
|
echo 'nameserver 8.8.4.4' >> /etc/resolv.conf
|
|
|
|
fi
|
2019-09-24 01:50:02 +00:00
|
|
|
|
|
|
|
# Disable autosuspend for USB drives
|
2020-02-04 04:03:35 +00:00
|
|
|
if [ -d /sys/bus/usb/devices/ ]; then
|
|
|
|
for dev in /sys/bus/usb/devices/*/power/control; do echo "on" > $dev; done
|
|
|
|
fi
|
2019-09-24 01:50:02 +00:00
|
|
|
|
2019-11-30 03:42:34 +00:00
|
|
|
# Verify SD card permissions and folders are OK
|
|
|
|
mkdir -p /home/admin/.config/
|
|
|
|
chown -R admin:admin /home/admin/.config/
|
|
|
|
|
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Expand Root FS
|
|
|
|
mkdir -p /var/lib/mynode
|
2019-07-06 01:45:42 +00:00
|
|
|
|
|
|
|
if [ ! -f /var/lib/mynode/.expanded_rootfs ]; then
|
|
|
|
if [ $IS_RASPI -eq 1 ]; then
|
2019-06-15 23:02:44 +00:00
|
|
|
raspi-config --expand-rootfs
|
|
|
|
touch /var/lib/mynode/.expanded_rootfs
|
|
|
|
fi
|
2019-12-17 03:49:25 +00:00
|
|
|
if [ $IS_ROCK64 = 1 ] || [ $IS_ROCKPRO64 = 1 ]; then
|
2019-07-06 01:45:42 +00:00
|
|
|
/usr/lib/armbian/armbian-resize-filesystem start
|
2019-07-06 01:48:38 +00:00
|
|
|
touch /var/lib/mynode/.expanded_rootfs
|
2019-07-06 01:45:42 +00:00
|
|
|
fi
|
2019-06-15 23:02:44 +00:00
|
|
|
fi
|
|
|
|
|
2021-02-26 05:24:56 +00:00
|
|
|
|
|
|
|
# Setup SD Card (if necessary)
|
|
|
|
mkdir -p /run/tor
|
|
|
|
mkdir -p /var/run/tor
|
|
|
|
mkdir -p /home/bitcoin/.mynode/
|
|
|
|
mkdir -p /home/admin/.bitcoin/
|
|
|
|
chown admin:admin /home/admin/.bitcoin/
|
|
|
|
rm -rf /etc/motd # Remove simple motd for update-motd.d
|
|
|
|
|
|
|
|
|
2020-05-01 01:37:17 +00:00
|
|
|
# Customize logo for resellers
|
2020-07-19 03:16:51 +00:00
|
|
|
if [ -f /opt/mynode/custom/logo_custom.png ]; then
|
|
|
|
cp -f /opt/mynode/custom/logo_custom.png /var/www/mynode/static/images/logo_custom.png
|
|
|
|
fi
|
|
|
|
if [ -f /opt/mynode/custom/logo_dark_custom.png ]; then
|
|
|
|
cp -f /opt/mynode/custom/logo_dark_custom.png /var/www/mynode/static/images/logo_dark_custom.png
|
2020-05-01 01:37:17 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2020-01-17 04:22:31 +00:00
|
|
|
# Verify we are in a clean state
|
2021-03-18 00:18:32 +00:00
|
|
|
if [ $IS_X86 = 1 ]; then
|
2021-03-17 23:55:43 +00:00
|
|
|
swapoff -a || true
|
2019-06-15 23:02:44 +00:00
|
|
|
fi
|
2021-03-17 23:55:43 +00:00
|
|
|
dphys-swapfile swapoff || true
|
|
|
|
dphys-swapfile uninstall || true
|
2019-06-15 23:02:44 +00:00
|
|
|
umount /mnt/hdd || true
|
|
|
|
|
2021-02-04 01:11:19 +00:00
|
|
|
|
2021-02-26 05:24:56 +00:00
|
|
|
# Generate myNode serial number
|
|
|
|
while [ ! -f /home/bitcoin/.mynode/mynode_serial ] || [ ! -s /home/bitcoin/.mynode/mynode_serial ]
|
|
|
|
do
|
|
|
|
# Generate random serial for backup devices that don't have serial numbers
|
|
|
|
sleep 10s
|
|
|
|
< /dev/urandom tr -dc a-f0-9 | head -c${1:-16} > /home/bitcoin/.mynode/mynode_serial
|
|
|
|
chmod 644 /home/bitcoin/.mynode/mynode_serial
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2021-02-10 05:37:43 +00:00
|
|
|
# Clone tool was opened
|
2021-02-09 04:29:42 +00:00
|
|
|
if [ -f /home/bitcoin/open_clone_tool ]; then
|
2021-02-04 01:11:19 +00:00
|
|
|
rm -f /home/bitcoin/open_clone_tool
|
|
|
|
echo "drive_clone" > $MYNODE_STATUS_FILE
|
|
|
|
sync
|
|
|
|
while [ 1 ]; do
|
|
|
|
python3 /usr/bin/clone_drive.py || true
|
|
|
|
sleep 60s
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Check drive (only if exactly 1 is found)
|
2019-12-12 01:34:34 +00:00
|
|
|
set +e
|
2021-02-10 05:37:43 +00:00
|
|
|
if [ $IS_X86 = 0 ]; then
|
2020-03-04 18:41:52 +00:00
|
|
|
touch /tmp/repairing_drive
|
2021-01-02 01:33:51 +00:00
|
|
|
for d in /dev/sd*1 /dev/hd*1 /dev/vd*1 /dev/nvme*p1; do
|
2020-03-04 18:41:52 +00:00
|
|
|
echo "Repairing drive $d ...";
|
|
|
|
fsck -y $d > /tmp/fsck_results 2>&1
|
|
|
|
RC=$?
|
2020-07-10 04:23:13 +00:00
|
|
|
echo "" >> /tmp/fsck_results
|
|
|
|
echo "Code: $RC" >> /tmp/fsck_results
|
2020-08-06 23:10:32 +00:00
|
|
|
if [ "$RC" -ne 0 ] && [ "$RC" -ne 8 ] ; then
|
2020-03-04 18:41:52 +00:00
|
|
|
touch /tmp/fsck_error
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2019-12-22 03:27:14 +00:00
|
|
|
rm -f /tmp/repairing_drive
|
2019-12-12 01:34:34 +00:00
|
|
|
set -e
|
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
|
2021-02-04 01:11:19 +00:00
|
|
|
# Mount HDD (normal boot, format if necessary)
|
2019-06-15 23:02:44 +00:00
|
|
|
while [ ! -f /mnt/hdd/.mynode ]
|
|
|
|
do
|
2021-02-04 01:11:19 +00:00
|
|
|
# Normal boot - find drive
|
|
|
|
rm -f $MYNODE_STATUS_FILE # Clear status
|
2019-06-15 23:02:44 +00:00
|
|
|
mount_drive.tcl || true
|
2021-02-04 01:11:19 +00:00
|
|
|
sleep 5s
|
2019-06-15 23:02:44 +00:00
|
|
|
done
|
|
|
|
|
2019-09-22 21:45:43 +00:00
|
|
|
|
2020-03-24 17:19:18 +00:00
|
|
|
# Check for docker reset
|
|
|
|
if [ -f /home/bitcoin/reset_docker ]; then
|
|
|
|
rm -rf /mnt/hdd/mynode/docker
|
|
|
|
rm /home/bitcoin/reset_docker
|
|
|
|
sync
|
|
|
|
reboot
|
|
|
|
sleep 60s
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2021-01-28 04:01:34 +00:00
|
|
|
# Check drive usage
|
2021-02-04 01:11:19 +00:00
|
|
|
mb_available=$(df --block-size=M /mnt/hdd | grep /dev | awk '{print $4}' | cut -d'M' -f1)
|
|
|
|
if [ $mb_available -le 1200 ]; then
|
2021-01-28 04:01:34 +00:00
|
|
|
echo "drive_full" > $MYNODE_STATUS_FILE
|
|
|
|
sleep 10s
|
2021-02-04 01:11:19 +00:00
|
|
|
mb_available=$(df --block-size=M /mnt/hdd | grep /dev | awk '{print $4}' | cut -d'M' -f1)
|
|
|
|
fi
|
2021-01-28 04:01:34 +00:00
|
|
|
|
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Setup Drive
|
|
|
|
mkdir -p /mnt/hdd/mynode
|
2019-07-06 01:45:42 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/settings
|
2019-07-13 18:26:00 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/.config
|
2019-06-15 23:02:44 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/bitcoin
|
|
|
|
mkdir -p /mnt/hdd/mynode/lnd
|
2020-11-17 00:55:20 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/loop
|
|
|
|
mkdir -p /mnt/hdd/mynode/pool
|
2021-02-19 01:17:02 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/faraday
|
|
|
|
mkdir -p /mnt/hdd/mynode/lit
|
2019-06-15 23:02:44 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/quicksync
|
|
|
|
mkdir -p /mnt/hdd/mynode/redis
|
|
|
|
mkdir -p /mnt/hdd/mynode/mongodb
|
|
|
|
mkdir -p /mnt/hdd/mynode/electrs
|
2019-11-12 03:20:10 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/docker
|
2020-07-16 04:33:32 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/rtl
|
2020-01-26 21:57:48 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/rtl_backup
|
2020-06-10 02:50:03 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/whirlpool
|
2020-06-26 04:30:17 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/lnbits
|
2020-07-08 04:16:10 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/specter
|
2021-02-09 04:29:42 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/ckbunker
|
2021-02-13 06:07:49 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/sphinxrelay
|
2021-02-18 03:22:05 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/joinmarket
|
2021-02-23 02:39:14 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/mempool
|
2021-03-23 05:08:34 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/tor_backup
|
2019-12-21 06:07:21 +00:00
|
|
|
mkdir -p /tmp/flask_uploads
|
2020-08-21 18:31:47 +00:00
|
|
|
echo "drive_mounted" > $MYNODE_STATUS_FILE
|
|
|
|
chmod 777 $MYNODE_STATUS_FILE
|
2019-06-15 23:02:44 +00:00
|
|
|
rm -rf $MYNODE_DIR/.mynode_bitcoind_synced
|
|
|
|
|
|
|
|
|
2020-02-29 16:48:00 +00:00
|
|
|
# Sync product key (SD preferred)
|
|
|
|
cp -f /home/bitcoin/.mynode/.product_key* /mnt/hdd/mynode/settings/ || true
|
|
|
|
cp -f /mnt/hdd/mynode/settings/.product_key* home/bitcoin/.mynode/ || true
|
|
|
|
|
2019-08-10 01:08:50 +00:00
|
|
|
# Make any users we need to
|
|
|
|
useradd -m -s /bin/bash pivpn || true
|
2021-02-18 03:22:05 +00:00
|
|
|
useradd -m -s /bin/bash joinmarket || true
|
|
|
|
|
|
|
|
# User updates and settings
|
|
|
|
grep "joinmarket" /etc/sudoers || (echo 'joinmarket ALL=(ALL) NOPASSWD:ALL' | EDITOR='tee -a' visudo)
|
2019-06-15 23:02:44 +00:00
|
|
|
|
2019-10-24 00:55:49 +00:00
|
|
|
# Regen SSH keys (check if force regen or keys are missing / empty)
|
|
|
|
while [ ! -f /home/bitcoin/.mynode/.gensshkeys ] ||
|
|
|
|
[ ! -f /etc/ssh/ssh_host_ecdsa_key.pub ] ||
|
|
|
|
[ ! -s /etc/ssh/ssh_host_ecdsa_key.pub ] ||
|
|
|
|
[ ! -f /etc/ssh/ssh_host_ed25519_key.pub ] ||
|
|
|
|
[ ! -s /etc/ssh/ssh_host_ed25519_key.pub ] ||
|
|
|
|
[ ! -f /etc/ssh/ssh_host_rsa_key.pub ] ||
|
|
|
|
[ ! -s /etc/ssh/ssh_host_rsa_key.pub ]
|
|
|
|
do
|
|
|
|
sleep 10s
|
2019-06-15 23:02:44 +00:00
|
|
|
rm -rf /etc/ssh/ssh_host_*
|
|
|
|
dpkg-reconfigure openssh-server
|
|
|
|
systemctl restart ssh
|
|
|
|
|
|
|
|
touch /home/bitcoin/.mynode/.gensshkeys
|
2019-10-24 04:18:46 +00:00
|
|
|
sync
|
|
|
|
sleep 5s
|
2019-10-24 00:55:49 +00:00
|
|
|
done
|
2019-06-15 23:02:44 +00:00
|
|
|
|
2020-01-26 00:21:09 +00:00
|
|
|
# Gen RSA keys
|
2020-01-26 20:45:17 +00:00
|
|
|
sudo -u admin mkdir -p /home/admin/.ssh
|
|
|
|
chown -R admin:admin /home/admin/.ssh
|
2020-01-26 00:21:09 +00:00
|
|
|
if [ ! -f /home/admin/.ssh/id_rsa ]; then
|
|
|
|
sudo -u admin ssh-keygen -t rsa -f /home/admin/.ssh/id_rsa -N ""
|
|
|
|
fi
|
2020-01-28 01:46:43 +00:00
|
|
|
sudo -u admin touch /home/admin/.ssh/authorized_keys || true
|
2020-01-26 00:21:09 +00:00
|
|
|
if [ ! -f /root/.ssh/id_rsa_btcpay ]; then
|
2020-01-28 03:39:12 +00:00
|
|
|
sudo rm -rf /root/.ssh/id_rsa_btcpay
|
2020-01-26 00:21:09 +00:00
|
|
|
ssh-keygen -t rsa -f /root/.ssh/id_rsa_btcpay -q -P "" -m PEM
|
|
|
|
echo "# Key used by BTCPay Server" >> /root/.ssh/authorized_keys
|
|
|
|
cat /root/.ssh/id_rsa_btcpay.pub >> /root/.ssh/authorized_keys
|
|
|
|
fi
|
|
|
|
|
2021-02-26 05:24:56 +00:00
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Randomize RPC password
|
2019-10-24 00:55:49 +00:00
|
|
|
while [ ! -f /mnt/hdd/mynode/settings/.btcrpcpw ] || [ ! -s /mnt/hdd/mynode/settings/.btcrpcpw ]
|
|
|
|
do
|
2019-06-15 23:02:44 +00:00
|
|
|
# Write random pw to .btcrpcpw
|
2019-10-24 00:55:49 +00:00
|
|
|
sleep 10s
|
2019-07-06 01:45:42 +00:00
|
|
|
< /dev/urandom tr -dc A-Za-z0-9 | head -c${1:-24} > /mnt/hdd/mynode/settings/.btcrpcpw
|
|
|
|
chown bitcoin:bitcoin /mnt/hdd/mynode/settings/.btcrpcpw
|
|
|
|
chmod 600 /mnt/hdd/mynode/settings/.btcrpcpw
|
2019-10-24 00:55:49 +00:00
|
|
|
done
|
2019-06-15 23:02:44 +00:00
|
|
|
|
2019-10-24 04:18:46 +00:00
|
|
|
# Default QuickSync
|
|
|
|
if [ ! -f /mnt/hdd/mynode/settings/.setquicksyncdefault ]; then
|
|
|
|
# Default x86 to no QuickSync
|
|
|
|
if [ $IS_X86 = 1 ]; then
|
|
|
|
touch /mnt/hdd/mynode/settings/quicksync_disabled
|
|
|
|
fi
|
2020-01-26 00:21:09 +00:00
|
|
|
# Default RockPro64 to no QuickSync
|
|
|
|
if [ $IS_ROCKPRO64 = 1 ]; then
|
|
|
|
touch /mnt/hdd/mynode/settings/quicksync_disabled
|
|
|
|
fi
|
2019-10-24 04:18:46 +00:00
|
|
|
# Default SSD to no QuickSync
|
|
|
|
DRIVE=$(cat /tmp/.mynode_drive)
|
|
|
|
HDD=$(lsblk $DRIVE -o ROTA | tail -n 1 | tr -d '[:space:]')
|
|
|
|
if [ "$HDD" = "0" ]; then
|
|
|
|
touch /mnt/hdd/mynode/settings/quicksync_disabled
|
|
|
|
fi
|
2020-02-23 06:57:49 +00:00
|
|
|
# If there is a USB->SATA adapter, assume we have an SSD and default to no QS
|
2020-02-27 00:27:42 +00:00
|
|
|
set +e
|
2020-02-23 06:57:49 +00:00
|
|
|
lsusb | grep "SATA 6Gb/s bridge"
|
|
|
|
RC=$?
|
2020-02-27 00:27:42 +00:00
|
|
|
set -e
|
2020-02-23 06:57:49 +00:00
|
|
|
if [ "$RC" = "0" ]; then
|
|
|
|
touch /mnt/hdd/mynode/settings/quicksync_disabled
|
|
|
|
fi
|
2020-01-22 04:58:03 +00:00
|
|
|
# Default small drives to no QuickSync
|
|
|
|
DRIVE_SIZE=$(df /mnt/hdd | grep /dev | awk '{print $2}')
|
2020-01-22 04:58:28 +00:00
|
|
|
if (( ${DRIVE_SIZE} <= 800000000 )); then
|
2020-01-22 04:58:03 +00:00
|
|
|
touch /mnt/hdd/mynode/settings/quicksync_disabled
|
|
|
|
fi
|
2019-10-24 04:18:46 +00:00
|
|
|
touch /mnt/hdd/mynode/settings/.setquicksyncdefault
|
|
|
|
fi
|
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
|
2019-06-29 16:41:49 +00:00
|
|
|
# BTC Config
|
2019-11-04 04:50:47 +00:00
|
|
|
source /usr/bin/mynode_gen_bitcoin_config.sh
|
2019-06-29 16:41:49 +00:00
|
|
|
|
|
|
|
# LND Config
|
2019-11-04 04:50:47 +00:00
|
|
|
source /usr/bin/mynode_gen_lnd_config.sh
|
2019-06-29 16:41:49 +00:00
|
|
|
|
2021-03-09 03:55:39 +00:00
|
|
|
# Loop Config
|
|
|
|
source /usr/bin/mynode_gen_loop_config.sh
|
|
|
|
|
|
|
|
# Pool Config
|
|
|
|
source /usr/bin/mynode_gen_pool_config.sh
|
|
|
|
|
2021-02-19 01:17:02 +00:00
|
|
|
|
|
|
|
# Setup symlinks for bitcoin user so they have access to commands
|
|
|
|
users="bitcoin"
|
|
|
|
services="bitcoin lnd lit loop pool faraday"
|
|
|
|
for u in $users; do
|
|
|
|
for s in $services; do
|
|
|
|
if [ ! -L /home/$u/.$s ]; then
|
|
|
|
if [ -d /home/$u/.$s ]; then
|
|
|
|
mv /home/$u/.$s /home/$u/.${s}_backup || true # Backup just in case
|
|
|
|
fi
|
|
|
|
sudo -u $u ln -s /mnt/hdd/mynode/$s /home/$u/.$s
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
2020-11-17 02:51:15 +00:00
|
|
|
|
2021-02-19 01:17:02 +00:00
|
|
|
# Setup symlinks for adming (need to be careful here - lnd,bitcoin can't be symlinked)
|
|
|
|
if [ ! -L /home/admin/.pool ]; then # Pool Config (symlink so admin user can run pool commands)
|
2020-11-17 02:51:15 +00:00
|
|
|
mv /home/admin/.pool /home/admin/.pool_backup || true
|
|
|
|
ln -s /mnt/hdd/mynode/pool /home/admin/.pool
|
|
|
|
fi
|
2021-02-19 01:17:02 +00:00
|
|
|
if [ ! -L /home/admin/.loop ]; then # Loop Config (symlink so admin user can run loop commands)
|
|
|
|
mv /home/admin/.loop /home/admin/.loop_backup || true
|
|
|
|
ln -s /mnt/hdd/mynode/loop /home/admin/.loop
|
|
|
|
fi
|
2020-11-17 02:51:15 +00:00
|
|
|
|
2021-01-23 04:55:44 +00:00
|
|
|
# Dojo - move to HDD
|
|
|
|
if [ -d /opt/mynode/dojo ] && [ ! -d /mnt/hdd/mynode/dojo ] ; then
|
|
|
|
mv /opt/mynode/dojo /mnt/hdd/mynode/dojo
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2021-03-09 03:55:39 +00:00
|
|
|
# Setup electrs
|
|
|
|
cp -f /usr/share/mynode/electrs.toml /mnt/hdd/mynode/electrs/electrs.toml
|
|
|
|
# Update for testnet
|
|
|
|
if [ -f /mnt/hdd/mynode/settings/.testnet_enabled ]; then
|
|
|
|
sed -i "s/bitcoin/testnet/g" /mnt/hdd/mynode/electrs/electrs.toml || true
|
|
|
|
else
|
|
|
|
sed -i "s/testnet/bitcoin/g" /mnt/hdd/mynode/electrs/electrs.toml || true
|
|
|
|
fi
|
|
|
|
|
2019-06-29 16:41:49 +00:00
|
|
|
# RTL config
|
2020-07-16 04:33:32 +00:00
|
|
|
sudo -u bitcoin mkdir -p /opt/mynode/RTL
|
|
|
|
sudo -u bitcoin mkdir -p /mnt/hdd/mynode/rtl
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/rtl
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/rtl_backup
|
|
|
|
# If local settings file is not a symlink, delete and setup symlink to HDD
|
|
|
|
if [ ! -L /opt/mynode/RTL/RTL-Config.json ]; then
|
|
|
|
rm -f /opt/mynode/RTL/RTL-Config.json
|
|
|
|
sudo -u bitcoin ln -s /mnt/hdd/mynode/rtl/RTL-Config.json /opt/mynode/RTL/RTL-Config.json
|
2020-05-07 03:20:49 +00:00
|
|
|
fi
|
2020-07-16 04:33:32 +00:00
|
|
|
# If config file on HDD does not exist, create it
|
|
|
|
if [ ! -f /mnt/hdd/mynode/rtl/RTL-Config.json ]; then
|
|
|
|
cp -f /usr/share/mynode/RTL-Config.json /mnt/hdd/mynode/rtl/RTL-Config.json
|
|
|
|
fi
|
2021-01-02 22:05:13 +00:00
|
|
|
# Force update of RTL config file (increment to force new update)
|
|
|
|
RTL_CONFIG_UPDATE_NUM=1
|
|
|
|
if [ ! -f /mnt/hdd/mynode/rtl/update_settings_$RTL_CONFIG_UPDATE_NUM ]; then
|
|
|
|
cp -f /usr/share/mynode/RTL-Config.json /mnt/hdd/mynode/rtl/RTL-Config.json
|
|
|
|
touch /mnt/hdd/mynode/rtl/update_settings_$RTL_CONFIG_UPDATE_NUM
|
|
|
|
fi
|
2020-07-16 04:33:32 +00:00
|
|
|
# Update RTL config file to use mynode pw
|
2019-07-28 23:34:08 +00:00
|
|
|
if [ -f /home/bitcoin/.mynode/.hashedpw ]; then
|
|
|
|
HASH=$(cat /home/bitcoin/.mynode/.hashedpw)
|
2020-07-16 04:33:32 +00:00
|
|
|
sed -i "s/\"multiPassHashed\":.*/\"multiPassHashed\": \"$HASH\",/g" /mnt/hdd/mynode/rtl/RTL-Config.json
|
2019-07-28 23:34:08 +00:00
|
|
|
fi
|
2021-03-09 03:55:39 +00:00
|
|
|
# Update for testnet
|
|
|
|
if [ -f /mnt/hdd/mynode/settings/.testnet_enabled ]; then
|
|
|
|
sed -i "s/mainnet/testnet/g" /mnt/hdd/mynode/rtl/RTL-Config.json || true
|
|
|
|
else
|
|
|
|
sed -i "s/testnet/mainnet/g" /mnt/hdd/mynode/rtl/RTL-Config.json || true
|
|
|
|
fi
|
2019-06-29 16:41:49 +00:00
|
|
|
|
2019-10-05 01:30:56 +00:00
|
|
|
# BTC RPC Explorer Config
|
2020-02-19 03:02:07 +00:00
|
|
|
cp /usr/share/mynode/btc_rpc_explorer_env /opt/mynode/btc-rpc-explorer/.env
|
|
|
|
chown bitcoin:bitcoin /opt/mynode/btc-rpc-explorer/.env
|
|
|
|
|
2020-06-28 02:12:54 +00:00
|
|
|
# LNBits Config
|
2020-07-07 02:13:45 +00:00
|
|
|
if [ -d /opt/mynode/lnbits ]; then
|
|
|
|
cp /usr/share/mynode/lnbits.env /opt/mynode/lnbits/.env
|
|
|
|
chown bitcoin:bitcoin /opt/mynode/lnbits/.env
|
|
|
|
fi
|
2020-06-28 02:12:54 +00:00
|
|
|
|
2020-07-08 04:16:10 +00:00
|
|
|
# Setup Specter
|
2020-07-08 04:33:57 +00:00
|
|
|
if [ -d /home/bitcoin/.specter ] && [ ! -L /home/bitcoin/.specter ] ; then
|
2020-07-08 04:16:10 +00:00
|
|
|
# Migrate to HDD
|
|
|
|
cp -r -f /home/bitcoin/.specter/* /mnt/hdd/mynode/specter/
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/specter
|
|
|
|
rm -rf /home/bitcoin/.specter
|
|
|
|
sync
|
|
|
|
fi
|
|
|
|
if [ ! -L /home/bitcoin/.specter ]; then
|
|
|
|
# Setup symlink to HDD
|
|
|
|
sudo -u bitcoin ln -s /mnt/hdd/mynode/specter /home/bitcoin/.specter
|
|
|
|
fi
|
2020-08-07 04:06:51 +00:00
|
|
|
if [ -f /mnt/hdd/mynode/specter/config.json ]; then
|
|
|
|
# Setup config file to point to local bitcoin instance
|
|
|
|
BTCRPCPW=$(cat /mnt/hdd/mynode/settings/.btcrpcpw)
|
|
|
|
sed -i "s#\"datadir\": .*#\"datadir\": \"/home/bitcoin/.bitcoin\",#g" /mnt/hdd/mynode/specter/config.json
|
|
|
|
sed -i "s#\"user\": .*#\"user\": \"mynode\",#g" /mnt/hdd/mynode/specter/config.json
|
|
|
|
sed -i "s#\"password\": .*#\"password\": \"$BTCRPCPW\",#g" /mnt/hdd/mynode/specter/config.json
|
|
|
|
sed -i "s#\"port\": .*#\"port\": \"8332\",#g" /mnt/hdd/mynode/specter/config.json
|
|
|
|
sed -i "s#\"host\": .*#\"host\": \"localhost\",#g" /mnt/hdd/mynode/specter/config.json
|
|
|
|
sed -i "s#\"protocol\": .*#\"protocol\": \"http\"#g" /mnt/hdd/mynode/specter/config.json
|
|
|
|
fi
|
2020-07-08 04:16:10 +00:00
|
|
|
|
2020-07-17 06:02:59 +00:00
|
|
|
# Setup Thunderhub
|
2020-07-30 00:19:55 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/thunderhub/
|
|
|
|
if [ ! -f /mnt/hdd/mynode/thunderhub/.env.local ]; then
|
|
|
|
cp -f /usr/share/mynode/thunderhub.env /mnt/hdd/mynode/thunderhub/.env.local
|
|
|
|
fi
|
|
|
|
if [ ! -f /mnt/hdd/mynode/thunderhub/thub_config.yaml ]; then
|
|
|
|
cp -f /usr/share/mynode/thub_config.yaml /mnt/hdd/mynode/thunderhub/thub_config.yaml
|
|
|
|
fi
|
2020-07-17 06:02:59 +00:00
|
|
|
if [ -f /mnt/hdd/mynode/thunderhub/thub_config.yaml ]; then
|
|
|
|
if [ -f /home/bitcoin/.mynode/.hashedpw_bcrypt ]; then
|
|
|
|
HASH_BCRYPT=$(cat /home/bitcoin/.mynode/.hashedpw_bcrypt)
|
2020-07-17 23:10:23 +00:00
|
|
|
sed -i "s#masterPassword:.*#masterPassword: \"thunderhub-$HASH_BCRYPT\"#g" /mnt/hdd/mynode/thunderhub/thub_config.yaml
|
2020-07-17 06:02:59 +00:00
|
|
|
fi
|
2021-03-09 03:55:39 +00:00
|
|
|
if [ -f /mnt/hdd/mynode/settings/.testnet_enabled ]; then
|
|
|
|
sed -i "s/mainnet/testnet/g" /mnt/hdd/mynode/thunderhub/thub_config.yaml || true
|
|
|
|
else
|
|
|
|
sed -i "s/testnet/mainnet/g" /mnt/hdd/mynode/thunderhub/thub_config.yaml || true
|
|
|
|
fi
|
2020-07-17 06:02:59 +00:00
|
|
|
fi
|
2021-03-09 03:55:39 +00:00
|
|
|
|
2020-07-30 00:19:55 +00:00
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/thunderhub
|
2020-07-17 06:02:59 +00:00
|
|
|
|
2021-02-10 05:37:43 +00:00
|
|
|
# Setup CKBunker
|
|
|
|
CKBUNKER_CONFIG_UPDATE_NUM=1
|
|
|
|
if [ ! -f /mnt/hdd/mynode/ckbunker/update_settings_$CKBUNKER_CONFIG_UPDATE_NUM ]; then
|
|
|
|
cp -f /usr/share/mynode/ckbunker_settings.yaml /mnt/hdd/mynode/ckbunker/settings.yaml
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/ckbunker/settings.yaml
|
|
|
|
|
|
|
|
touch /mnt/hdd/mynode/ckbunker/update_settings_$CKBUNKER_CONFIG_UPDATE_NUM
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Setup Sphinx Relay
|
2021-02-13 06:07:49 +00:00
|
|
|
SPHINXRELAY_CONFIG_UPDATE_NUM=1
|
|
|
|
if [ ! -f /mnt/hdd/mynode/sphinxrelay/update_settings_$SPHINXRELAY_CONFIG_UPDATE_NUM ]; then
|
|
|
|
cp -f /usr/share/mynode/sphinxrelay_app.json /mnt/hdd/mynode/sphinxrelay/app.json
|
|
|
|
cp -f /usr/share/mynode/sphinxrelay_config.json /mnt/hdd/mynode/sphinxrelay/config.json
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/sphinxrelay
|
|
|
|
|
|
|
|
touch /mnt/hdd/mynode/sphinxrelay/update_settings_$SPHINXRELAY_CONFIG_UPDATE_NUM
|
|
|
|
fi
|
|
|
|
if [ -d /opt/mynode/sphinxrelay/config ]; then
|
|
|
|
if [ ! -L /opt/mynode/sphinxrelay/config/app.json ] || [ ! -L /opt/mynode/sphinxrelay/config/config.json ]; then
|
|
|
|
rm -f /opt/mynode/sphinxrelay/config/app.json
|
|
|
|
rm -f /opt/mynode/sphinxrelay/config/config.json
|
|
|
|
sudo -u bitcoin ln -s /mnt/hdd/mynode/sphinxrelay/app.json /opt/mynode/sphinxrelay/config/app.json
|
|
|
|
sudo -u bitcoin ln -s /mnt/hdd/mynode/sphinxrelay/config.json /opt/mynode/sphinxrelay/config/config.json
|
|
|
|
chown -R bitcoin:bitcoin /opt/mynode/sphinxrelay/config/*
|
2021-02-10 05:37:43 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-02-18 03:22:05 +00:00
|
|
|
# Setup JoinMarket
|
|
|
|
if [ ! -L /home/joinmarket/.joinmarket ]; then
|
|
|
|
rm -rf /home/joinmarket/.joinmarket
|
|
|
|
sudo -u joinmarket ln -s /mnt/hdd/mynode/joinmarket /home/joinmarket/.joinmarket
|
|
|
|
fi
|
|
|
|
# Migrate data from bitcoin user? - Might be confusing later if an old copy of wallet is used
|
|
|
|
# if [ -f /home/bitcoin/.joinmarket/joinmarket.cfg ] && [ ! -f /mnt/hdd/mynode/joinmarket/joinmarket.cfg ]; then
|
|
|
|
# cp /home/bitcoin/.joinmarket/joinmarket.cfg /mnt/hdd/mynode/joinmarket/joinmarket.cfg
|
|
|
|
# fi
|
|
|
|
# for f in wallets logs cmtdata; do
|
|
|
|
# if [ -d /home/bitcoin/.joinmarket/$f ] && [ ! -d /mnt/hdd/mynode/joinmarket/$f ]; then
|
|
|
|
# cp -r /home/bitcoin/.joinmarket/$f /home/joinmarket/.joinmarket/
|
|
|
|
# fi
|
|
|
|
# done
|
|
|
|
if [ ! -f /mnt/hdd/mynode/joinmarket/joinmarket.cfg ]; then
|
|
|
|
cp /usr/share/mynode/joinmarket.cfg /mnt/hdd/mynode/joinmarket/joinmarket.cfg
|
|
|
|
fi
|
|
|
|
chown -R joinmarket:joinmarket /mnt/hdd/mynode/joinmarket
|
|
|
|
|
2021-02-23 02:39:14 +00:00
|
|
|
# Setup Mempool
|
|
|
|
cp -f /usr/share/mynode/mempool-docker-compose.yml /mnt/hdd/mynode/mempool/docker-compose.yml
|
|
|
|
if [ ! -f /mnt/hdd/mynode/mempool/.env ]; then
|
|
|
|
cp -f /usr/share/mynode/mempool.env /mnt/hdd/mynode/mempool/.env
|
|
|
|
fi
|
|
|
|
if [ $IS_RASPI -eq 1 ]; then
|
|
|
|
sed -i "s|MARIA_DB_IMAGE=.*|MARIA_DB_IMAGE=hypriot/rpi-mysql:latest|g" /mnt/hdd/mynode/mempool/.env
|
|
|
|
fi
|
|
|
|
|
2021-03-23 05:08:34 +00:00
|
|
|
# Backup Tor files
|
|
|
|
for f in /var/lib/tor/mynode*; do
|
|
|
|
rsync --ignore-existing -r -avh $f /mnt/hdd/mynode/tor_backup/ || true
|
|
|
|
done
|
|
|
|
cp -a -f /mnt/hdd/mynode/tor_backup/. /var/lib/tor/ || true
|
2021-03-26 02:43:34 +00:00
|
|
|
chown debian-tor:debian-tor /var/lib/tor
|
2021-03-23 05:08:34 +00:00
|
|
|
systemctl restart tor || true
|
|
|
|
|
2020-07-08 03:13:01 +00:00
|
|
|
# Setup udev
|
|
|
|
chown root:root /etc/udev/rules.d/* || true
|
|
|
|
udevadm trigger
|
|
|
|
udevadm control --reload-rules
|
|
|
|
groupadd plugdev || true
|
|
|
|
sudo usermod -aG plugdev bitcoin
|
2019-06-29 16:41:49 +00:00
|
|
|
|
2020-08-07 04:06:51 +00:00
|
|
|
# Update other files that need RPC password (needed if upgrades overwrite files)
|
|
|
|
BTCRPCPW=$(cat /mnt/hdd/mynode/settings/.btcrpcpw)
|
2019-06-15 23:02:44 +00:00
|
|
|
if [ -f /opt/mynode/LndHub/config.js ]; then
|
2020-01-26 19:59:38 +00:00
|
|
|
cp -f /usr/share/mynode/lndhub-config.js /opt/mynode/LndHub/config.js
|
2020-08-07 04:06:51 +00:00
|
|
|
sed -i "s/mynode:.*@/mynode:$BTCRPCPW@/g" /opt/mynode/LndHub/config.js
|
2020-01-26 19:59:38 +00:00
|
|
|
chown bitcoin:bitcoin /opt/mynode/LndHub/config.js
|
2019-06-15 23:02:44 +00:00
|
|
|
fi
|
|
|
|
if [ -f /opt/mynode/btc-rpc-explorer/.env ]; then
|
2020-08-07 04:06:51 +00:00
|
|
|
sed -i "s/BTCEXP_BITCOIND_PASS=.*/BTCEXP_BITCOIND_PASS=$BTCRPCPW/g" /opt/mynode/btc-rpc-explorer/.env
|
2019-06-15 23:02:44 +00:00
|
|
|
fi
|
2021-02-18 03:22:05 +00:00
|
|
|
if [ -f /mnt/hdd/mynode/joinmarket/joinmarket.cfg ]; then
|
|
|
|
sed -i "s/rpc_password = .*/rpc_password = $BTCRPCPW/g" /mnt/hdd/mynode/joinmarket/joinmarket.cfg
|
|
|
|
fi
|
2021-02-23 02:39:14 +00:00
|
|
|
if [ -f /mnt/hdd/mynode/mempool/.env ]; then
|
|
|
|
sed -i "s/BITCOIN_RPC_PASS=.*/BITCOIN_RPC_PASS=$BTCRPCPW/g" /mnt/hdd/mynode/mempool/.env
|
|
|
|
fi
|
2020-08-07 04:06:51 +00:00
|
|
|
echo "BTC_RPC_PASSWORD=$BTCRPCPW" > /mnt/hdd/mynode/settings/.btcrpc_environment
|
2019-07-06 01:45:42 +00:00
|
|
|
chown bitcoin:bitcoin /mnt/hdd/mynode/settings/.btcrpc_environment
|
2019-06-15 23:02:44 +00:00
|
|
|
if [ -f /mnt/hdd/mynode/bitcoin/bitcoin.conf ]; then
|
2019-08-20 01:36:58 +00:00
|
|
|
sed -i "s/rpcauth=.*/$RPCAUTH/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
2019-06-15 23:02:44 +00:00
|
|
|
fi
|
2019-08-20 01:36:58 +00:00
|
|
|
cp -f /mnt/hdd/mynode/bitcoin/bitcoin.conf /home/admin/.bitcoin/bitcoin.conf
|
|
|
|
chown admin:admin /home/admin/.bitcoin/bitcoin.conf
|
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
|
2021-02-23 02:39:14 +00:00
|
|
|
# Append bitcoin UID and GID to btcrpc_environment
|
|
|
|
BITCOIN_UID=$(id -u bitcoin)
|
|
|
|
BITCOIN_GID=$(id -g bitcoin)
|
|
|
|
echo "BITCOIN_UID=$BITCOIN_UID" >> /mnt/hdd/mynode/settings/.btcrpc_environment
|
|
|
|
echo "BITCOIN_GID=$BITCOIN_GID" >> /mnt/hdd/mynode/settings/.btcrpc_environment
|
|
|
|
|
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Reset BTCARGS
|
|
|
|
echo "BTCARGS=" > /mnt/hdd/mynode/bitcoin/env
|
|
|
|
|
|
|
|
|
|
|
|
# Set proper permissions on drive
|
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/quicksync)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/quicksync
|
|
|
|
fi
|
2019-07-06 01:45:42 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/settings)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/settings
|
|
|
|
fi
|
2019-07-13 18:26:00 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/.config)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/.config
|
|
|
|
fi
|
2019-06-15 23:02:44 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/bitcoin)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/bitcoin
|
|
|
|
fi
|
|
|
|
USER=$(stat -c '%U' /home/bitcoin)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R --no-dereference bitcoin:bitcoin /home/bitcoin
|
|
|
|
fi
|
|
|
|
USER=$(stat -c '%U' /home/bitcoin/.mynode)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /home/bitcoin/.mynode
|
|
|
|
fi
|
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/lnd)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/lnd
|
|
|
|
fi
|
2020-11-17 00:55:20 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/loop)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/loop
|
|
|
|
fi
|
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/pool)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/pool
|
|
|
|
fi
|
2021-02-19 01:17:02 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/faraday)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/faraday
|
|
|
|
fi
|
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/lit)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/lit
|
|
|
|
fi
|
2020-06-10 02:50:03 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/whirlpool)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/whirlpool
|
|
|
|
fi
|
2020-06-26 04:30:17 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/lnbits)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/lnbits
|
|
|
|
fi
|
2020-07-16 04:33:32 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/rtl)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/rtl
|
|
|
|
fi
|
2020-07-08 04:16:10 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/specter)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/specter
|
|
|
|
fi
|
2021-02-09 04:29:42 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/ckbunker)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/ckbunker
|
|
|
|
fi
|
2021-02-13 06:07:49 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/sphinxrelay)
|
2021-02-09 04:29:42 +00:00
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
2021-02-13 06:07:49 +00:00
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/sphinxrelay
|
2021-02-09 04:29:42 +00:00
|
|
|
fi
|
2021-02-18 03:22:05 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/joinmarket)
|
|
|
|
if [ "$USER" != "joinmarket" ]; then
|
|
|
|
chown -R joinmarket:joinmarket /mnt/hdd/mynode/joinmarket
|
|
|
|
fi
|
2021-03-23 05:08:34 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/tor_backup)
|
|
|
|
if [ "$USER" != "debian-tor" ]; then
|
|
|
|
chown -R debian-tor:debian-tor /mnt/hdd/mynode/tor_backup
|
|
|
|
fi
|
2019-06-15 23:02:44 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/redis)
|
|
|
|
if [ "$USER" != "redis" ]; then
|
|
|
|
chown -R redis:redis /mnt/hdd/mynode/redis
|
|
|
|
fi
|
|
|
|
chown -R redis:redis /etc/redis/
|
2019-07-27 17:07:00 +00:00
|
|
|
#USER=$(stat -c '%U' /mnt/hdd/mynode/mongodb)
|
|
|
|
#if [ "$USER" != "mongodb" ]; then
|
|
|
|
# chown -R mongodb:mongodb /mnt/hdd/mynode/mongodb
|
|
|
|
#fi
|
2019-06-15 23:02:44 +00:00
|
|
|
USER=$(stat -c '%U' /mnt/hdd/mynode/electrs)
|
|
|
|
if [ "$USER" != "bitcoin" ]; then
|
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/electrs
|
|
|
|
fi
|
|
|
|
chown bitcoin:bitcoin /mnt/hdd/
|
|
|
|
chown bitcoin:bitcoin /mnt/hdd/mynode/
|
|
|
|
|
|
|
|
|
|
|
|
# Setup swap on new HDD
|
2020-05-23 03:18:50 +00:00
|
|
|
if [ ! -f /mnt/hdd/mynode/settings/swap_size ]; then
|
|
|
|
# Set defaults
|
|
|
|
touch /mnt/hdd/mynode/settings/swap_size
|
|
|
|
echo "2" > /mnt/hdd/mynode/settings/swap_size
|
|
|
|
sed -i "s|CONF_SWAPSIZE=.*|CONF_SWAPSIZE=2048|" /etc/dphys-swapfile
|
|
|
|
else
|
|
|
|
# Update swap config file in case upgrade overwrote file
|
|
|
|
SWAP=$(cat /mnt/hdd/mynode/settings/swap_size)
|
|
|
|
SWAP_MB=$(($SWAP * 1024))
|
|
|
|
sed -i "s|CONF_SWAPSIZE=.*|CONF_SWAPSIZE=$SWAP_MB|" /etc/dphys-swapfile
|
|
|
|
fi
|
2021-03-17 23:55:43 +00:00
|
|
|
|
|
|
|
SWAP=$(cat /mnt/hdd/mynode/settings/swap_size)
|
|
|
|
if [ "$SWAP" -ne "0" ]; then
|
|
|
|
dphys-swapfile install || true
|
|
|
|
dphys-swapfile swapon || true
|
2019-06-15 23:02:44 +00:00
|
|
|
fi
|
|
|
|
|
2019-08-19 02:25:55 +00:00
|
|
|
|
|
|
|
# Make sure every enabled service is really enabled
|
|
|
|
# This can happen from full-SD card upgrades
|
|
|
|
STARTUP_MODIFIED=0
|
|
|
|
if [ -f $ELECTRS_ENABLED_FILE ]; then
|
|
|
|
if systemctl status electrs | grep "disabled;"; then
|
|
|
|
systemctl enable electrs
|
|
|
|
STARTUP_MODIFIED=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -f $LNDHUB_ENABLED_FILE ]; then
|
|
|
|
if systemctl status lndhub | grep "disabled;"; then
|
|
|
|
systemctl enable lndhub
|
|
|
|
STARTUP_MODIFIED=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -f $BTCRPCEXPLORER_ENABLED_FILE ]; then
|
|
|
|
if systemctl status btc_rpc_explorer | grep "disabled;"; then
|
|
|
|
systemctl enable btc_rpc_explorer
|
|
|
|
STARTUP_MODIFIED=1
|
|
|
|
fi
|
|
|
|
fi
|
2020-01-17 04:22:31 +00:00
|
|
|
if [ -f $MEMPOOLSPACE_ENABLED_FILE ]; then
|
|
|
|
if systemctl status mempoolspace | grep "disabled;"; then
|
|
|
|
systemctl enable mempoolspace
|
|
|
|
STARTUP_MODIFIED=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -f $BTCPAYSERVER_ENABLED_FILE ]; then
|
|
|
|
if systemctl status btcpayserver | grep "disabled;"; then
|
|
|
|
systemctl enable btcpayserver
|
|
|
|
STARTUP_MODIFIED=1
|
|
|
|
fi
|
|
|
|
fi
|
2019-08-19 02:25:55 +00:00
|
|
|
if [ -f $VPN_ENABLED_FILE ]; then
|
|
|
|
if systemctl status vpn | grep "disabled;"; then
|
|
|
|
systemctl enable vpn
|
|
|
|
systemctl enable openvpn || true
|
|
|
|
STARTUP_MODIFIED=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ $STARTUP_MODIFIED -eq 1 ]; then
|
|
|
|
sync
|
|
|
|
reboot
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2020-08-11 04:08:38 +00:00
|
|
|
# Generate certificates
|
|
|
|
echo "Generating certificates..."
|
|
|
|
/usr/bin/mynode_gen_cert.sh https 825
|
|
|
|
/usr/bin/mynode_gen_cert_electrs.sh
|
|
|
|
|
|
|
|
# Setup nginx HTTPS proxy
|
|
|
|
mkdir -p /var/log/nginx || true
|
|
|
|
mkdir -p /etc/nginx || true
|
|
|
|
rm -f /etc/nginx/modules-enabled/50-mod-* || true # Remove unnecessary files
|
2020-08-21 18:49:07 +00:00
|
|
|
echo "gen_dhparam" > $MYNODE_STATUS_FILE
|
2020-08-13 01:42:41 +00:00
|
|
|
/usr/bin/mynode_gen_dhparam.sh
|
2020-08-21 18:49:07 +00:00
|
|
|
echo "drive_mounted" > $MYNODE_STATUS_FILE
|
2020-08-11 04:08:38 +00:00
|
|
|
cp -f /usr/share/mynode/nginx.conf /etc/nginx/nginx.conf
|
|
|
|
systemctl restart nginx || true
|
|
|
|
|
2019-08-19 02:25:55 +00:00
|
|
|
|
2020-09-07 21:13:45 +00:00
|
|
|
# Update latest version files
|
|
|
|
echo $BTC_VERSION > $BTC_LATEST_VERSION_FILE
|
|
|
|
echo $LND_VERSION > $LND_LATEST_VERSION_FILE
|
|
|
|
echo $LOOP_VERSION > $LOOP_LATEST_VERSION_FILE
|
2020-11-26 19:22:50 +00:00
|
|
|
echo $POOL_VERSION > $POOL_LATEST_VERSION_FILE
|
|
|
|
echo $ELECTRS_VERSION > $ELECTRS_LATEST_VERSION_FILE
|
2020-09-07 21:13:45 +00:00
|
|
|
echo $LNDHUB_VERSION > $LNDHUB_LATEST_VERSION_FILE
|
|
|
|
echo $CARAVAN_VERSION > $CARAVAN_LATEST_VERSION_FILE
|
|
|
|
echo $CORSPROXY_VERSION > $CORSPROXY_LATEST_VERSION_FILE
|
|
|
|
echo $JOINMARKET_VERSION > $JOINMARKET_LATEST_VERSION_FILE
|
2021-02-18 03:22:05 +00:00
|
|
|
echo $JOININBOX_VERSION > $JOININBOX_LATEST_VERSION_FILE
|
2020-09-07 21:13:45 +00:00
|
|
|
echo $WHIRLPOOL_VERSION > $WHIRLPOOL_LATEST_VERSION_FILE
|
|
|
|
echo $RTL_VERSION > $RTL_LATEST_VERSION_FILE
|
|
|
|
echo $BTCRPCEXPLORER_VERSION > $BTCRPCEXPLORER_LATEST_VERSION_FILE
|
|
|
|
echo $LNBITS_VERSION > $LNBITS_LATEST_VERSION_FILE
|
|
|
|
echo $SPECTER_VERSION > $SPECTER_LATEST_VERSION_FILE
|
|
|
|
echo $THUNDERHUB_VERSION > $THUNDERHUB_LATEST_VERSION_FILE
|
|
|
|
echo $LNDCONNECT_VERSION > $LNDCONNECT_LATEST_VERSION_FILE
|
2021-02-09 04:29:42 +00:00
|
|
|
echo $CKBUNKER_VERSION > $CKBUNKER_LATEST_VERSION_FILE
|
2021-02-13 06:07:49 +00:00
|
|
|
echo $SPHINXRELAY_VERSION > $SPHINXRELAY_LATEST_VERSION_FILE
|
2020-09-07 21:13:45 +00:00
|
|
|
|
|
|
|
|
2019-10-08 03:11:31 +00:00
|
|
|
# Weird hacks
|
|
|
|
chmod +x /usr/bin/electrs || true # Once, a device didn't have the execute bit set for electrs
|
2020-03-04 18:50:30 +00:00
|
|
|
timedatectl set-ntp True || true # Make sure NTP is enabled for Tor and Bitcoin
|
2020-07-02 20:07:47 +00:00
|
|
|
rm -f /var/swap || true # Remove old swap file to save SD card space
|
2020-07-26 04:08:24 +00:00
|
|
|
systemctl enable check_in || true
|
2020-08-11 04:08:38 +00:00
|
|
|
|
2019-10-08 03:11:31 +00:00
|
|
|
|
2019-07-28 21:02:56 +00:00
|
|
|
# Check for new versions
|
2020-10-30 03:19:07 +00:00
|
|
|
torify wget $LATEST_VERSION_URL --timeout=30 -O /usr/share/mynode/latest_version || true
|
|
|
|
torify wget $LATEST_BETA_VERSION_URL --timeout=30 -O /usr/share/mynode/latest_beta_version || true
|
2019-06-15 23:02:44 +00:00
|
|
|
|
|
|
|
# Update current state
|
|
|
|
if [ -f $QUICKSYNC_DIR/.quicksync_complete ]; then
|
2020-08-21 18:31:47 +00:00
|
|
|
echo "stable" > $MYNODE_STATUS_FILE
|
2019-06-15 23:02:44 +00:00
|
|
|
fi
|