def fallback_mount(partition, path): """Attempt to mount partition at path using ext4 first and falling back to any :return bool: success """ print("Mount ext4 storage device: {}".format(partition)) if usb.is_mounted(partition): return True if mnt_ext4(partition, path) == 0 and usb.is_mounted(partition): print("{d} is mounted as ext4 at {p}".format(d=partition, p=path)) return True print("Warning: {} usb is not mountable as ext4".format(partition)) print("Attempting to mount with any filesystem...") if mnt_any(partition, path) == 0 and usb.is_mounted(partition): print("{d} mounted at {p} with any filesystem".format(d=partition, p=path)) return True print("Error: {} usb is not mountable with any supported format".format( partition)) print("Cannot continue without all USB storage devices") return False
def setup_volatile(): if usb.is_mounted(medium): if create_swap(): enable_swap() else: print("Warning: Cannot create and enable swap!") setup_nginx()
def setup_fstab(device, mount): """Add device to fstab""" ext4_mounted = usb.is_mounted(device) if ext4_mounted: with open("/etc/fstab", "a") as file: fstab = "\nUUID={u} {m} ext4 defaults,noatime 0 0".format( u=usb.get_uuid(device), m=mount) file.write(fstab) else: print("Warning: {} usb does not seem to be ext4 formatted".format( device)) print("{} will not be added to /etc/fstab".format(device))
def check_for_destruction(device, path): """Check devices for destruction flag. If so, format with ext4""" print("Check devices for destruction flag") destroy = Path(path + "/DESTROY_ALL_DATA_ON_THIS_DEVICE/").is_dir() if destroy: print("Destruction flag found!") print("Going to destroy all data on /dev/{} in 3 seconds...".format( device)) sleep(3) unmounted = call(["umount", "/dev/" + device]) if unmounted and not usb.is_mounted(device): print("Going to format {d} with ext4 now".format(d=device)) call(["mkfs.ext4", "-F", "/dev/" + device]) if mnt_ext4(device, path) == 0 and usb.is_mounted(device): print( "{d} formatted with ext4 successfully and mounted.".format( d=device)) return True else: unmounted = call(["umount", "-f", "/dev/" + device]) if unmounted and not usb.is_mounted(device): print("Going to format {d} with ext4 now".format(d=device)) call(["mkfs.ext4", "-F", "/dev/" + device]) mounted = mnt_ext4(device, path) if mounted == 0 and usb.is_mounted(device): print("{d} formatted with ext4 successfully and mounted.". format(d=device)) return True else: print("Error mounting {}".format(device)) return False else: print("{} is not flagged for being wiped".format(device)) return True
def setup_important(): if usb.is_mounted(smallest): import noma.bitcoind print("Creating bitcoind files") noma.bitcoind.create() if noma.bitcoind.check(): noma.bitcoind.set_prune("550") noma.bitcoind.set_rpcauth( "/media/archive/archive/bitcoin/bitcoin.conf") import noma.lnd print("Creating lnd files") noma.lnd.check_wallet() if noma.lnd.check(): noma.lnd.setup_tor()
def setup_archive(): if usb.is_mounted(largest): import noma.bitcoind if noma.bitcoind.check(): noma.bitcoind.fastsync()