From 732221c3f96b092904a5a6b41ea27ed917756926 Mon Sep 17 00:00:00 2001 From: nolim1t Date: Tue, 28 Apr 2020 16:17:19 +0700 Subject: [PATCH 01/32] Partition utility (pre-release) --- contrib/README.md | 2 +- contrib/partitioner/partitioner.py | 127 +++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 contrib/partitioner/partitioner.py diff --git a/contrib/README.md b/contrib/README.md index 954d0bb..f5df266 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -3,5 +3,5 @@ ## Utility Register * keysend/ - Experimental Keysend functionality - +* partitioner/ - Experimental tool for partitioning drives diff --git a/contrib/partitioner/partitioner.py b/contrib/partitioner/partitioner.py new file mode 100644 index 0000000..247d7c4 --- /dev/null +++ b/contrib/partitioner/partitioner.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python3 + +''' +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. +''' +import os +import sys +import glob +import re + +usb_dev_pattern = ['sd.*'] +usb_part_pattern = ['sd.[1-9]*'] +sd_dev_pattern = ['mmcblk*'] +sd_part_pattern = ['mmcblk.p[1-9]*'] + +def dev_size(device): + path = '/sys/block/' + num_sectors = open(path + device + '/size').read().rstrip('\n') + sector_size = open(path + device + '/queue/hw_sector_size').read().rstrip('\n') + return (int(num_sectors)*int(sector_size)) + +def usb_devs(): + devices = [] + for device in glob.glob('/sys/block/*'): + for pattern in usb_dev_pattern: + if re.compile(pattern).match(os.path.basename(device)): + devices.append(os.path.basename(device)) + return devices + +def usb_partitions(): + partitions = [] + for device in usb_devs(): + for partition in glob.glob('/sys/block/' + str(device) + '/*'): + for pattern in usb_part_pattern: + if re.compile(pattern).match(os.path.basename(partition)): + partitions.append(os.path.basename(partition)) + return partitions + +def usb_part_size(partition): + try: + path = '/sys/block/' + device = partition[:-1] + num_sectors = open(path + device + '/' + partition + '/size').read().rstrip('\n') + sector_size = open(path + device + '/queue/hw_sector_size').read().rstrip('\n') + except TypeError: + print("Not enough USB devices available") + sys.exit(1) + else: + return (int(num_sectors)*int(sector_size)) + +def uuid_table(): + device_table = os.popen('blkid').read().splitlines() + devices = {} + for device in device_table: + dev = device.split(":")[0].split("/")[2] + uuid = device.split('"')[1] + devices[dev] = uuid + return devices + +def get_uuid(device): + uuids = uuid_table() + return str(uuids[device]) + +def usb_partition_table(): + table = {} + for partition in usb_partitions(): + table[partition] = int(usb_part_size(partition)) + return table + +def main(): + print('USB Configuration') + if len(usb_devs()) == 1: + first_part = dev_size('sda') / (1000*1000) + print('Size: ' + str(first_part)) + prune_setting = int(first_part / 2) + partitions = usb_partitions() + if first_part < 512000: + print("Pruning the config") + os.system('/bin/sed -i "s/prune=550/prune=' + str(prune_setting) + '/g;" bitcoin/bitcoin.conf') + else: + print("Switching off pruning") + os.system('/bin/sed -i "s/prune=550/#prune=550/g;" bitcoin/bitcoin.conf') + os.system('/bin/sed -i "s/#txindex=1/txindex=1/g;" bitcoin/bitcoin.conf') + + print('Creating data mount') + os.system('mkdir -p /mnt/data') + print('Initializing filesystem') + os.system('/sbin/mkfs.ext4 -F /dev/sda1') + first_partition_uuid = get_uuid('sda1') + os.system('/bin/mount -t ext4 /dev/sda1 /mnt/data') + print('Setup secrets, bitcoin, nginx, and lnd directory') + os.system('/bin/cp -fr /home/umbrel/secrets /mnt/data') + os.system('/bin/cp -fr /home/umbrel/bitcoin /mnt/data') + os.system('/bin/cp -fr /home/umbrel/lnd /mnt/data') + os.system('/bin/cp -fr /home/umbrel/nginx /mnt/data') + print('Setup filesystem permissions') + os.system('/bin/chown -R 1000.1000 /mnt/data') + print('Unmounting partition') + os.system('/bin/umount /mnt/data') + print('Update /etc/fstab') + os.system('echo "UUID=' + first_partition_uuid + ' /mnt/data ext4 defaults,noatime 0 0" >> /etc/fstab') + print('Remounting through /bin/mount') + os.system('/bin/mount -a'); + print('Remove old folders') + os.system('/bin/rm -fr /home/umbrel/secrets') + os.system('/bin/rm -fr /home/umbrel/bitcoin') + os.system('/bin/rm -fr /home/umbrel/lnd') + os.system('/bin/rm -fr /home/umbrel/nginx') + print('Set up symlinks') + os.system('/bin/ln -s /mnt/data/secrets /home/umbrel/secrets') + os.system('/bin/ln -s /mnt/data/bitcoin /home/umbrel/bitcoin') + os.system('/bin/ln -s /mnt/data/lnd /home/umbrel/lnd') + os.system('/bin/ln -s /mnt/data/lnd /home/umbrel/nginx') + else: + print('No drives or unexpected number of drives detected!') +if __name__ == '__main__': + if os.geteuid() == 0: + main() + else: + print("Must run as root") + From 8bb017c66892099b90e7d61ce2c03f4c0c257131 Mon Sep 17 00:00:00 2001 From: nolim1t Date: Tue, 28 Apr 2020 21:31:03 +0700 Subject: [PATCH 02/32] Check to see if we should preserve it or not --- contrib/partitioner/partitioner.py | 124 +++++++++++++++++++++-------- 1 file changed, 90 insertions(+), 34 deletions(-) mode change 100644 => 100755 contrib/partitioner/partitioner.py diff --git a/contrib/partitioner/partitioner.py b/contrib/partitioner/partitioner.py old mode 100644 new mode 100755 index 247d7c4..60a7f17 --- a/contrib/partitioner/partitioner.py +++ b/contrib/partitioner/partitioner.py @@ -9,6 +9,11 @@ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' + +''' +Libraries should be system standard libraries if possible +''' + import os import sys import glob @@ -73,55 +78,106 @@ def usb_partition_table(): table[partition] = int(usb_part_size(partition)) return table +''' +Main Entrypoint +''' + def main(): - print('USB Configuration') + print('USB Configuration script') + homedirpath = os.path.expanduser("~umbrel") + ''' + If /mnt/data doesn't exist + ''' + if not os.path.exists('/mnt/data'): + print('Creating data mount') + os.mkdir('/mnt/data') + else: + print('Data mount exists') + + if len(usb_devs()) == 1: - first_part = dev_size('sda') / (1000*1000) - print('Size: ' + str(first_part)) - prune_setting = int(first_part / 2) + if len(usb_partitions()) == 1: + try: + os.system('/bin/mount -t ext4 /dev/' + usb_partitions()[0] + ' /mnt/data') + # if .rekt exists or bitcoin directory doesnt exist + if os.path.exists('/mnt/data/.rekt') or not os.path.exists('/mnt/data/bitcoin'): + print('REKT file exists so lets format it') + print('Initializing filesystem') + os.system('/sbin/mkfs.ext4 -F /dev/' + usb_partitions()[0]) + ''' + Get Size of SDA and partition info + ''' + first_part = dev_size('sda') / (1000*1000) + prune_setting = int(first_part / 2) + + if first_part < 512000: + print("Pruning the config") + os.system('/bin/sed -i "s/prune=550/prune=' + str(prune_setting) + '/g;" bitcoin/bitcoin.conf') + else: + print("Switching off pruning") + os.system('/bin/sed -i "s/prune=550/#prune=550/g;" bitcoin/bitcoin.conf') + os.system('/bin/sed -i "s/#txindex=1/txindex=1/g;" bitcoin/bitcoin.conf') + + ''' + Setup secrets, bitcoin, nginx, and lnd directory.. as a new install + ''' + print('Setup secrets, bitcoin, nginx, and lnd directory.. as a new install') + os.system('/bin/cp -fr ' + homedirpath + '/secrets /mnt/data') + os.system('/bin/cp -fr ' + homedirpath + '/bitcoin /mnt/data') + os.system('/bin/cp -fr ' + homedirpath + '/lnd /mnt/data') + os.system('/bin/cp -fr ' + homedirpath + '/nginx /mnt/data') + else: + ''' + No need to do anything + ''' + print('REKT file does not exist so we will preserve it') + + print('Unmounting partition') + os.system('/bin/umount /mnt/data') + except: + print("Error mounting the directory") + + + # If volume not mounted + if not os.path.exists(' /mnt/data/lost+found'): + os.system('/bin/mount -t ext4 /dev/sda1 /mnt/data') + + # Get UUID of the partition we just created partitions = usb_partitions() - if first_part < 512000: - print("Pruning the config") - os.system('/bin/sed -i "s/prune=550/prune=' + str(prune_setting) + '/g;" bitcoin/bitcoin.conf') - else: - print("Switching off pruning") - os.system('/bin/sed -i "s/prune=550/#prune=550/g;" bitcoin/bitcoin.conf') - os.system('/bin/sed -i "s/#txindex=1/txindex=1/g;" bitcoin/bitcoin.conf') + first_partition_uuid = get_uuid(partitions[0]) - print('Creating data mount') - os.system('mkdir -p /mnt/data') - print('Initializing filesystem') - os.system('/sbin/mkfs.ext4 -F /dev/sda1') - first_partition_uuid = get_uuid('sda1') - os.system('/bin/mount -t ext4 /dev/sda1 /mnt/data') - print('Setup secrets, bitcoin, nginx, and lnd directory') - os.system('/bin/cp -fr /home/umbrel/secrets /mnt/data') - os.system('/bin/cp -fr /home/umbrel/bitcoin /mnt/data') - os.system('/bin/cp -fr /home/umbrel/lnd /mnt/data') - os.system('/bin/cp -fr /home/umbrel/nginx /mnt/data') - print('Setup filesystem permissions') + print('Setup filesystem permissions (UID=1000 GID=1000)') os.system('/bin/chown -R 1000.1000 /mnt/data') + print('Unmounting partition') os.system('/bin/umount /mnt/data') + print('Update /etc/fstab') os.system('echo "UUID=' + first_partition_uuid + ' /mnt/data ext4 defaults,noatime 0 0" >> /etc/fstab') + print('Remounting through /bin/mount') os.system('/bin/mount -a'); - print('Remove old folders') - os.system('/bin/rm -fr /home/umbrel/secrets') - os.system('/bin/rm -fr /home/umbrel/bitcoin') - os.system('/bin/rm -fr /home/umbrel/lnd') - os.system('/bin/rm -fr /home/umbrel/nginx') + + print('Remove old folders (after copying)') + os.system('/bin/rm -fr ' + homedirpath + '/secrets') + os.system('/bin/rm -fr ' + homedirpath + '/bitcoin') + os.system('/bin/rm -fr ' + homedirpath + '/lnd') + os.system('/bin/rm -fr ' + homedirpath + '/nginx') print('Set up symlinks') - os.system('/bin/ln -s /mnt/data/secrets /home/umbrel/secrets') - os.system('/bin/ln -s /mnt/data/bitcoin /home/umbrel/bitcoin') - os.system('/bin/ln -s /mnt/data/lnd /home/umbrel/lnd') - os.system('/bin/ln -s /mnt/data/lnd /home/umbrel/nginx') + os.system('/bin/ln -s /mnt/data/secrets ' + homedirpath + '/secrets') + os.system('/bin/ln -s /mnt/data/bitcoin ' + homedirpath + '/bitcoin') + os.system('/bin/ln -s /mnt/data/lnd ' + homedirpath + '/lnd') + os.system('/bin/ln -s /mnt/data/nginx ' + homedirpath + '/nginx') else: print('No drives or unexpected number of drives detected!') + +''' +Actual entrypoint +''' + if __name__ == '__main__': + # Check if root if os.geteuid() == 0: main() else: - print("Must run as root") - + print("Must run as root (UID 0)") From 39ccdf06d3d4c90f42e2adae85dfb76a7264e4c8 Mon Sep 17 00:00:00 2001 From: nolim1t Date: Tue, 28 Apr 2020 21:48:04 +0700 Subject: [PATCH 03/32] Fix up mount issue --- contrib/partitioner/partitioner.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/partitioner/partitioner.py b/contrib/partitioner/partitioner.py index 60a7f17..a154013 100755 --- a/contrib/partitioner/partitioner.py +++ b/contrib/partitioner/partitioner.py @@ -102,8 +102,12 @@ def main(): # if .rekt exists or bitcoin directory doesnt exist if os.path.exists('/mnt/data/.rekt') or not os.path.exists('/mnt/data/bitcoin'): print('REKT file exists so lets format it') + # unmount before format + os.system('/bin/umount /mnt/data') print('Initializing filesystem') os.system('/sbin/mkfs.ext4 -F /dev/' + usb_partitions()[0]) + # remount + os.system('/bin/mount -t ext4 /dev/' + usb_partitions()[0] + ' /mnt/data') ''' Get Size of SDA and partition info ''' From 3071cc595512cfa8709e63744e45a483af0d7108 Mon Sep 17 00:00:00 2001 From: nolim1t Date: Tue, 28 Apr 2020 22:00:14 +0700 Subject: [PATCH 04/32] Switch of neutrino mode if bitcoind is not ready --- contrib/partitioner/partitioner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/partitioner/partitioner.py b/contrib/partitioner/partitioner.py index a154013..14ccab8 100755 --- a/contrib/partitioner/partitioner.py +++ b/contrib/partitioner/partitioner.py @@ -101,7 +101,7 @@ def main(): os.system('/bin/mount -t ext4 /dev/' + usb_partitions()[0] + ' /mnt/data') # if .rekt exists or bitcoin directory doesnt exist if os.path.exists('/mnt/data/.rekt') or not os.path.exists('/mnt/data/bitcoin'): - print('REKT file exists so lets format it') + print('REKT file exists OR bitcoin folder not found... So lets format it') # unmount before format os.system('/bin/umount /mnt/data') print('Initializing filesystem') @@ -121,6 +121,8 @@ def main(): print("Switching off pruning") os.system('/bin/sed -i "s/prune=550/#prune=550/g;" bitcoin/bitcoin.conf') os.system('/bin/sed -i "s/#txindex=1/txindex=1/g;" bitcoin/bitcoin.conf') + print("Switch of pruning on LND side") + os.system('/bin/sed -i "s/bitcoin.node=neutrino/bitcoin.node=bitcoind/g;" lnd/lnd.conf') ''' Setup secrets, bitcoin, nginx, and lnd directory.. as a new install From 449185bede5bc602278f5d3efa014d39f179688b Mon Sep 17 00:00:00 2001 From: nolim1t Date: Wed, 29 Apr 2020 17:56:45 +0700 Subject: [PATCH 05/32] Don't use neutrino for the script as discussed --- contrib/partitioner/partitioner.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/contrib/partitioner/partitioner.py b/contrib/partitioner/partitioner.py index 14ccab8..35b65b4 100755 --- a/contrib/partitioner/partitioner.py +++ b/contrib/partitioner/partitioner.py @@ -121,8 +121,6 @@ def main(): print("Switching off pruning") os.system('/bin/sed -i "s/prune=550/#prune=550/g;" bitcoin/bitcoin.conf') os.system('/bin/sed -i "s/#txindex=1/txindex=1/g;" bitcoin/bitcoin.conf') - print("Switch of pruning on LND side") - os.system('/bin/sed -i "s/bitcoin.node=neutrino/bitcoin.node=bitcoind/g;" lnd/lnd.conf') ''' Setup secrets, bitcoin, nginx, and lnd directory.. as a new install From f45cea226e10289603b1fdebcda7008e071ebca8 Mon Sep 17 00:00:00 2001 From: nolim1t Date: Wed, 29 Apr 2020 18:04:45 +0700 Subject: [PATCH 06/32] Allow for mounting of any supported filesystems. Added more commenting --- contrib/partitioner/partitioner.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/partitioner/partitioner.py b/contrib/partitioner/partitioner.py index 35b65b4..b652dbf 100755 --- a/contrib/partitioner/partitioner.py +++ b/contrib/partitioner/partitioner.py @@ -98,8 +98,9 @@ def main(): if len(usb_devs()) == 1: if len(usb_partitions()) == 1: try: - os.system('/bin/mount -t ext4 /dev/' + usb_partitions()[0] + ' /mnt/data') - # if .rekt exists or bitcoin directory doesnt exist + os.system('/bin/mount /dev/' + usb_partitions()[0] + ' /mnt/data') + # if .rekt exists or bitcoin directory doesnt exist (because the drive is a factory default) + # then wipe the drive and format it with EXT4 if os.path.exists('/mnt/data/.rekt') or not os.path.exists('/mnt/data/bitcoin'): print('REKT file exists OR bitcoin folder not found... So lets format it') # unmount before format From 1e8451171534421f2652adbc19a9c013b70c2886 Mon Sep 17 00:00:00 2001 From: nolim1t Date: Wed, 29 Apr 2020 20:56:22 +0700 Subject: [PATCH 07/32] Replacing paths that are missing --- contrib/partitioner/partitioner.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/contrib/partitioner/partitioner.py b/contrib/partitioner/partitioner.py index b652dbf..3fc493a 100755 --- a/contrib/partitioner/partitioner.py +++ b/contrib/partitioner/partitioner.py @@ -135,7 +135,29 @@ def main(): ''' No need to do anything ''' - print('REKT file does not exist so we will preserve it') + print('REKT file does not exist OR bitcoin folder exists so we will preserve it. But lets check for all the other folders') + + ''' + Check other folders in partition3 + - secrets + - lnd + - nginx + ''' + # Secrets folder + if not os.path.exists('/mnt/data/secrets'): + print('secrets folder does\'nt exist!') + os.system('/bin/cp -fr ' + homedirpath + '/secrets /mnt/data') + + # Check LND folder + if not os.path.exists('/mnt/data/lnd'): + print('lnd folder does\'nt exist!') + os.system('/bin/cp -fr ' + homedirpath + '/lnd /mnt/data') + + # Check nginx folder + if not os.path.exists('/mnt/data/nginx'): + print('nginx folder does\'nt exist!') + os.system('/bin/cp -fr ' + homedirpath + '/nginx /mnt/data') + print('Unmounting partition') os.system('/bin/umount /mnt/data') From 80a4938a61d2de9acd6da37cf05f56b098d887c3 Mon Sep 17 00:00:00 2001 From: nolim1t Date: Sun, 24 May 2020 23:17:00 +0700 Subject: [PATCH 08/32] Update partitioner with db folder --- contrib/partitioner/partitioner.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/contrib/partitioner/partitioner.py b/contrib/partitioner/partitioner.py index 3fc493a..c1729b8 100755 --- a/contrib/partitioner/partitioner.py +++ b/contrib/partitioner/partitioner.py @@ -116,18 +116,19 @@ def main(): prune_setting = int(first_part / 2) if first_part < 512000: - print("Pruning the config") + print("Pruning the config, because drive is less than 512 GB") os.system('/bin/sed -i "s/prune=550/prune=' + str(prune_setting) + '/g;" bitcoin/bitcoin.conf') else: - print("Switching off pruning") + print("Switching off pruning, and turn on txindex") os.system('/bin/sed -i "s/prune=550/#prune=550/g;" bitcoin/bitcoin.conf') os.system('/bin/sed -i "s/#txindex=1/txindex=1/g;" bitcoin/bitcoin.conf') ''' - Setup secrets, bitcoin, nginx, and lnd directory.. as a new install + Setup secrets, db, bitcoin, nginx, and lnd directory.. as a new install ''' - print('Setup secrets, bitcoin, nginx, and lnd directory.. as a new install') + print('Setup secrets, db, bitcoin, nginx, and lnd directory.. as a new install') os.system('/bin/cp -fr ' + homedirpath + '/secrets /mnt/data') + os.system('/bin/cp -fr ' + homedirpath + '/db /mnt/data') os.system('/bin/cp -fr ' + homedirpath + '/bitcoin /mnt/data') os.system('/bin/cp -fr ' + homedirpath + '/lnd /mnt/data') os.system('/bin/cp -fr ' + homedirpath + '/nginx /mnt/data') @@ -140,6 +141,7 @@ def main(): ''' Check other folders in partition3 - secrets + - db - lnd - nginx ''' @@ -148,6 +150,11 @@ def main(): print('secrets folder does\'nt exist!') os.system('/bin/cp -fr ' + homedirpath + '/secrets /mnt/data') + # db folder + if not os.path.exists('/mnt/data/db'): + print('db folder does\'nt exist!') + os.system('/bin/cp -fr ' + homedirpath + '/db /mnt/data') + # Check LND folder if not os.path.exists('/mnt/data/lnd'): print('lnd folder does\'nt exist!') @@ -187,11 +194,13 @@ def main(): print('Remove old folders (after copying)') os.system('/bin/rm -fr ' + homedirpath + '/secrets') + os.system('/bin/rm -fr ' + homedirpath + '/db') os.system('/bin/rm -fr ' + homedirpath + '/bitcoin') os.system('/bin/rm -fr ' + homedirpath + '/lnd') os.system('/bin/rm -fr ' + homedirpath + '/nginx') print('Set up symlinks') os.system('/bin/ln -s /mnt/data/secrets ' + homedirpath + '/secrets') + os.system('/bin/ln -s /mnt/data/db ' + homedirpath + '/db') os.system('/bin/ln -s /mnt/data/bitcoin ' + homedirpath + '/bitcoin') os.system('/bin/ln -s /mnt/data/lnd ' + homedirpath + '/lnd') os.system('/bin/ln -s /mnt/data/nginx ' + homedirpath + '/nginx') From dd9330ee37d7c4b0825ff8e638a6224b12411d0f Mon Sep 17 00:00:00 2001 From: nolim1t Date: Wed, 3 Jun 2020 17:29:51 +0700 Subject: [PATCH 09/32] Add absolute paths for pruning to work properly (so this tool can be run from anywhere in the system) --- contrib/partitioner/partitioner.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/partitioner/partitioner.py b/contrib/partitioner/partitioner.py index c1729b8..dfcebe4 100755 --- a/contrib/partitioner/partitioner.py +++ b/contrib/partitioner/partitioner.py @@ -117,11 +117,11 @@ def main(): if first_part < 512000: print("Pruning the config, because drive is less than 512 GB") - os.system('/bin/sed -i "s/prune=550/prune=' + str(prune_setting) + '/g;" bitcoin/bitcoin.conf') + os.system('/bin/sed -i "s/prune=550/prune=' + str(prune_setting) + '/g;" ' + str(homedirpath) + '/bitcoin/bitcoin.conf') else: print("Switching off pruning, and turn on txindex") - os.system('/bin/sed -i "s/prune=550/#prune=550/g;" bitcoin/bitcoin.conf') - os.system('/bin/sed -i "s/#txindex=1/txindex=1/g;" bitcoin/bitcoin.conf') + os.system('/bin/sed -i "s/prune=550/#prune=550/g;" ' + str(homedirpath) + '/bitcoin/bitcoin.conf') + os.system('/bin/sed -i "s/#txindex=1/txindex=1/g;" ' + str(homedirpath) + '/bitcoin/bitcoin.conf') ''' Setup secrets, db, bitcoin, nginx, and lnd directory.. as a new install @@ -200,7 +200,7 @@ def main(): os.system('/bin/rm -fr ' + homedirpath + '/nginx') print('Set up symlinks') os.system('/bin/ln -s /mnt/data/secrets ' + homedirpath + '/secrets') - os.system('/bin/ln -s /mnt/data/db ' + homedirpath + '/db') + os.system('/bin/ln -s /mnt/data/db ' + homedirpath + '/db') os.system('/bin/ln -s /mnt/data/bitcoin ' + homedirpath + '/bitcoin') os.system('/bin/ln -s /mnt/data/lnd ' + homedirpath + '/lnd') os.system('/bin/ln -s /mnt/data/nginx ' + homedirpath + '/nginx') From b5242a93689a05e636d971ebc1b783720d185e4c Mon Sep 17 00:00:00 2001 From: nolim1t Date: Tue, 9 Jun 2020 20:36:48 +0700 Subject: [PATCH 11/32] Latest PR --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2c699ba..99643e6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -41,12 +41,12 @@ services: network_mode: host stop_grace_period: 1m30s dashboard: - image: getumbrel/dashboard:v0.2.0 + image: getumbrel/dashboard:v0.2.1 logging: *default-logging restart: always network_mode: host manager: - image: getumbrel/manager:v0.1.0 + image: getumbrel/manager:v0.1.1 logging: *default-logging restart: unless-stopped network_mode: host @@ -59,7 +59,7 @@ services: JWT_PRIVATE_KEY_FILE: "/db/jwt-private-key/jwt.key" JWT_EXPIRATION: "3600" middleware: - image: getumbrel/middleware:v0.1.0 + image: getumbrel/middleware:v0.1.1 command: ["./wait-for-node-manager.sh", "localhost", "npm", "start"] logging: *default-logging restart: unless-stopped From 5ccbfcd0aacaeef10763fee6691d66838ccf6259 Mon Sep 17 00:00:00 2001 From: nolim1t Date: Tue, 9 Jun 2020 21:10:05 +0700 Subject: [PATCH 12/32] Add swap --- contrib/partitioner/partitioner.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contrib/partitioner/partitioner.py b/contrib/partitioner/partitioner.py index dfcebe4..cfbe322 100755 --- a/contrib/partitioner/partitioner.py +++ b/contrib/partitioner/partitioner.py @@ -132,6 +132,15 @@ def main(): os.system('/bin/cp -fr ' + homedirpath + '/bitcoin /mnt/data') os.system('/bin/cp -fr ' + homedirpath + '/lnd /mnt/data') os.system('/bin/cp -fr ' + homedirpath + '/nginx /mnt/data') + + if not os.path.exists('/mnt/data/swap'): + print('Add swap to partition') + os.system('sed -i "/CONF_SWAPFILE/s/^#//g; " /etc/dphys-swapfile') + os.system('sed -i "s/\/var\/swap/\/mnt\/data\/swap/g; " /etc/dphys-swapfile') + os.system('sed -i "s/CONF_SWAPSIZE=100/CONF_SWAPSIZE=2000/g; " /etc/dphys-swapfile') + print('Restarting dphys swapfile') + os.system('/etc/init.d/dphys-swapfile restart') + else: ''' No need to do anything