2019-06-15 23:02:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
source /usr/share/mynode/mynode_config.sh
|
|
|
|
|
|
|
|
# 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
|
|
|
|
echo '' >> /etc/resolv.conf
|
|
|
|
echo '# Added at myNode startup' >> /etc/resolv.conf
|
|
|
|
echo 'nameserver 8.8.8.8' >> /etc/resolv.conf
|
|
|
|
echo 'nameserver 8.8.4.4' >> /etc/resolv.conf
|
|
|
|
echo 'nameserver 1.1.1.1' >> /etc/resolv.conf
|
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
|
|
|
|
|
2020-05-01 01:37:17 +00:00
|
|
|
# Customize logo for resellers
|
|
|
|
if [ -f /opt/mynode/custom/reseller ]; then
|
|
|
|
if [ -f /opt/mynode/custom/logo_custom.png ]; then
|
|
|
|
cp -f /opt/mynode/custom/logo_custom.png /var/www/mynode/static/images/logo.png
|
|
|
|
else
|
|
|
|
cp -f /var/www/mynode/static/images/logo_original.png /var/www/mynode/static/images/logo.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.png
|
|
|
|
else
|
|
|
|
cp -f /var/www/mynode/static/images/logo_dark_original.png /var/www/mynode/static/images/logo_dark.png
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2020-01-17 04:22:31 +00:00
|
|
|
# Verify we are in a clean state
|
2019-12-05 04:28:56 +00:00
|
|
|
if [ $IS_RASPI -eq 1 ] || [ $IS_ROCKPRO64 -eq 1 ]; then
|
2019-06-15 23:02:44 +00:00
|
|
|
dphys-swapfile swapoff || true
|
|
|
|
dphys-swapfile uninstall || true
|
|
|
|
fi
|
|
|
|
umount /mnt/hdd || true
|
|
|
|
|
2019-12-12 01:34:34 +00:00
|
|
|
# Check drive
|
|
|
|
set +e
|
2020-03-04 18:41:52 +00:00
|
|
|
if [ $IS_X86 = 0 ]; then
|
|
|
|
touch /tmp/repairing_drive
|
|
|
|
for d in /dev/sd*1; do
|
|
|
|
echo "Repairing drive $d ...";
|
|
|
|
fsck -y $d > /tmp/fsck_results 2>&1
|
|
|
|
RC=$?
|
|
|
|
if [ "$RC" -ne 0 ]; then
|
|
|
|
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
|
|
|
|
|
|
|
# Mount HDD (format if necessary)
|
|
|
|
while [ ! -f /mnt/hdd/.mynode ]
|
|
|
|
do
|
2020-03-25 01:07:45 +00:00
|
|
|
# Clear status
|
|
|
|
rm -f $MYNODE_DIR/.mynode_status
|
2019-06-15 23:02:44 +00:00
|
|
|
mount_drive.tcl || true
|
2020-03-30 02:04:42 +00:00
|
|
|
sleep 5
|
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
|
|
|
|
|
|
|
|
|
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
|
|
|
|
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-01-26 21:57:48 +00:00
|
|
|
mkdir -p /mnt/hdd/mynode/rtl_backup
|
2019-12-21 06:07:21 +00:00
|
|
|
mkdir -p /tmp/flask_uploads
|
2019-06-15 23:02:44 +00:00
|
|
|
echo "drive_mounted" > $MYNODE_DIR/.mynode_status
|
|
|
|
chmod 777 $MYNODE_DIR/.mynode_status
|
|
|
|
rm -rf $MYNODE_DIR/.mynode_bitcoind_synced
|
|
|
|
|
|
|
|
|
|
|
|
# Setup SD Card (if necessary)
|
2019-11-17 04:20:23 +00:00
|
|
|
mkdir -p /run/tor
|
|
|
|
mkdir -p /var/run/tor
|
2019-07-06 01:45:42 +00:00
|
|
|
mkdir -p /home/bitcoin/.mynode/
|
2019-06-15 23:02:44 +00:00
|
|
|
mkdir -p /home/admin/.bitcoin/
|
|
|
|
chown admin:admin /home/admin/.bitcoin/
|
2019-07-06 01:45:42 +00:00
|
|
|
rm -rf /etc/motd # Remove simple motd for update-motd.d
|
2019-06-15 23:02:44 +00:00
|
|
|
|
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
|
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
|
|
|
|
|
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-06-29 16:41:49 +00:00
|
|
|
# Setup LND Node Name
|
2019-07-06 01:45:42 +00:00
|
|
|
if [ ! -f /mnt/hdd/mynode/settings/.lndalias ]; then
|
|
|
|
echo "mynodebtc.com [myNode]" > /mnt/hdd/mynode/settings/.lndalias
|
2019-06-15 23:02:44 +00:00
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
|
|
|
# RTL config
|
2020-01-22 03:46:14 +00:00
|
|
|
sudo -u bitcoin mkdir -p /opt/mynode/RTL/
|
2020-01-26 21:57:48 +00:00
|
|
|
chown -R bitcoin:bitcoin /mnt/hdd/mynode/rtl_backup/
|
2020-05-07 03:20:49 +00:00
|
|
|
if [ ! -f /opt/mynode/RTL/RTL-Config.json ]; then
|
|
|
|
cp -f /usr/share/mynode/RTL-Config.json /opt/mynode/RTL/RTL-Config.json
|
|
|
|
fi
|
2019-07-28 23:34:08 +00:00
|
|
|
if [ -f /home/bitcoin/.mynode/.hashedpw ]; then
|
|
|
|
HASH=$(cat /home/bitcoin/.mynode/.hashedpw)
|
2020-02-10 19:25:41 +00:00
|
|
|
sed -i "s/\"multiPassHashed\":.*/\"multiPassHashed\": \"$HASH\",/g" /opt/mynode/RTL/RTL-Config.json
|
2019-07-28 23:34:08 +00:00
|
|
|
fi
|
2020-02-10 19:25:41 +00:00
|
|
|
chown bitcoin:bitcoin /opt/mynode/RTL/RTL-Config.json
|
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
|
|
|
|
|
2019-06-29 16:41:49 +00:00
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Update files that need RPC password (needed if upgrades overwrite files)
|
2019-07-06 01:45:42 +00:00
|
|
|
PW=$(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
|
2019-06-15 23:02:44 +00:00
|
|
|
sed -i "s/mynode:.*@/mynode:$PW@/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
|
|
|
|
sed -i "s/BTCEXP_BITCOIND_PASS=.*/BTCEXP_BITCOIND_PASS=$PW/g" /opt/mynode/btc-rpc-explorer/.env
|
|
|
|
fi
|
2019-07-06 01:45:42 +00:00
|
|
|
echo "BTC_RPC_PASSWORD=$PW" > /mnt/hdd/mynode/settings/.btcrpc_environment
|
|
|
|
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/rpcpassword=.*/rpcpassword=$PW/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
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
|
|
|
|
|
|
|
# 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
|
|
|
|
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
|
2019-12-05 04:28:56 +00:00
|
|
|
if [ $IS_RASPI -eq 1 ] || [ $IS_ROCKPRO64 -eq 1 ]; then
|
2019-06-15 23:02:44 +00:00
|
|
|
if [ ! -f /mnt/hdd/swapfile ]; then
|
|
|
|
dd if=/dev/zero of=/mnt/hdd/swapfile count=1000 bs=1MiB
|
|
|
|
chmod 600 /mnt/hdd/swapfile
|
|
|
|
fi
|
|
|
|
mkswap /mnt/hdd/swapfile
|
|
|
|
dphys-swapfile swapon
|
|
|
|
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
|
|
|
|
|
|
|
|
|
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
|
2019-10-08 03:11:31 +00:00
|
|
|
|
2019-07-28 21:02:56 +00:00
|
|
|
# Check for new versions
|
|
|
|
wget $LATEST_VERSION_URL -O /usr/share/mynode/latest_version || true
|
2020-02-24 01:39:40 +00:00
|
|
|
wget $LATEST_BETA_VERSION_URL -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
|
|
|
|
echo "stable" > $MYNODE_DIR/.mynode_status
|
|
|
|
fi
|