From: alex Date: Tue, 28 Jun 2022 20:17:21 +0000 (-0700) Subject: ... X-Git-Url: http://git.infiniteadaptability.org/?a=commitdiff_plain;h=0e462dd8d79261094f6955d82328ad58f8bde3db;p=cold ... --- diff --git a/cold-setup b/cold-setup index 81127a7..4d72ca4 100755 --- a/cold-setup +++ b/cold-setup @@ -30,7 +30,7 @@ bitcoin_core_start() { log_info "starting bitcoin core..." mkdir -p "$DATA_DIRECTORY" - bitcoind -daemonwait -datadir="$DATA_DIRECTORY" -chain=regtest &> /dev/null + bitcoind -daemonwait -datadir="$DATA_DIRECTORY" &> /dev/null log_info "bitcoin core started" } @@ -273,14 +273,14 @@ usage() { usb_crypt_open() { log_info "usb encrypted... opening..." - cryptsetup luksOpen "$USB_PATH" "$USB_DECRYPT_NAME" + sudo cryptsetup luksOpen "$USB_PATH" "$USB_DECRYPT_NAME" USB_PATH_PRE_DECRYPT="$USB_PATH" USB_PATH="/dev/mapper/$USB_DECRYPT_NAME" } usb_crypt_close() { log_info "closing encrypted usb..." - cryptsetup luksClose "$USB_DECRYPT_NAME" + sudo cryptsetup luksClose "$USB_DECRYPT_NAME" USB_PATH="$USB_PATH_PRE_DECRYPT" USB_PATH_PRE_DECRYPT="" } @@ -312,12 +312,12 @@ usb_detect() { usb_encrypt() { log_info "encrypting $USB_PATH..." - cryptsetup luksFormat --type luks2 "$USB_PATH" + sudo cryptsetup luksFormat --type luks2 "$USB_PATH" } usb_eject() { log_info "ejecting $USB_PATH..." - eject "$USB_PATH" + sudo eject "$USB_PATH" log_info "ejected $USB_PATH" } @@ -342,34 +342,40 @@ usb_load() { } usb_mount() { - if [[ -n "$ENCRYPTION" ]]; then - usb_decrypt - fi - mkdir -p "$USB_DIRECTORY" log_info "mounting $USB_PATH at $USB_DIRECTORY" - mount "$USB_PATH" "$USB_DIRECTORY" + sudo mount "$USB_PATH" "$USB_DIRECTORY" + local USERNAME="`whoami`" + sudo chown "$USERNAME:$USERNAME" "$USB_DIRECTORY" } usb_setup() { - wipefs -a "$USB_PATH" + sudo wipefs -af "$USB_PATH" log_info "filesystem wiped from $USB_PATH" if [[ -n "$ENCRYPTION" ]]; then usb_encrypt + usb_crypt_open fi log_info "zero'ing $USB_PATH" - dd if=/dev/zero of="$USB_PATH" + + # this is necessary because dd will write until + # no space left on device and then error out. We + # wish to ignore this error. + set +e + sudo dd if=/dev/zero of="$USB_PATH" + set -e + log_info "$USB_PATH filled with zeroes" - mkfs.ext4 "$USB_PATH" + sudo mkfs.ext4 "$USB_PATH" log_info "created new filesystem on $USB_PATH" } usb_unmount() { log_info "unmounting $USB_DIRECTORY..." - umount "$USB_DIRECTORY" + sudo umount "$USB_DIRECTORY" if [[ -n "$ENCRYPTION" ]]; then usb_crypt_close @@ -384,6 +390,7 @@ usbs() { log_msg "found usb stick $USB_PATH" usb_setup + usb_mount usb_load "$i" usb_unmount usb_eject @@ -396,6 +403,7 @@ usbs() { log_msg "found usb stick $USB_PATH" usb_setup + usb_mount usb_load "$i" usb_unmount usb_eject