diff --git a/scripts/create-a-crypted-btrfs-device.sh b/scripts/create-a-crypted-btrfs-device.sh index 0cec6b8..715d08c 100755 --- a/scripts/create-a-crypted-btrfs-device.sh +++ b/scripts/create-a-crypted-btrfs-device.sh @@ -2,14 +2,15 @@ : ${DEVICE:?not set} : ${LABEL:?not set} -MOUNT_OPTIONS="${MOUNT_OPTIONS:-compress-force=zstd}" -[[ ${EUID} -eq 0 ]] || (echo "Please rerun this script with root privileges" && exit 1) -[[ -f "${DEVICE}" ]] || echo "${DEVICE} not found" +: "${MOUNT_OPTIONS:=compress-force=zstd}" -cryptsetup luksFormat "${DEVICE}" -cryptsetup luksOpen "${DEVICE}" "${LABEL}" -mkfs.btrfs --label "${LABEL}" "/dev/mapper/${LABEL}" -mount --types btrfs --options "${MOUNT_OPTIONS}" "/dev/mapper/${LABEL}" "/mnt/${LABEL}" +[[ $EUID -eq 0 ]] || (echo "Please rerun this script with root privileges" && exit 1) +[[ -f "$DEVICE" ]] || echo "${DEVICE} not found" + +cryptsetup luksFormat "$DEVICE" +cryptsetup luksOpen "$DEVICE" "$LABEL" +mkfs.btrfs --label "$LABEL" "/dev/mapper/${LABEL}" +mount --types btrfs --options "$MOUNT_OPTIONS" "/dev/mapper/${LABEL}" "/mnt/${LABEL}" umount "/mnt/${LABEL}" -cryptsetup luksClose "${DEVICE}" +cryptsetup luksClose "$DEVICE" diff --git a/scripts/decrypt-files-in-repo.sh b/scripts/decrypt-files-in-repo.sh index a8e6b07..0fdecc9 100755 --- a/scripts/decrypt-files-in-repo.sh +++ b/scripts/decrypt-files-in-repo.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -TOP_LEVEL="$(git rev-parse --show-toplevel)" +: "${TOP_LEVEL:=$(git rev-parse --show-toplevel)}" echo "Decrypting files…" diff --git a/scripts/opensuse/pi.config.sh b/scripts/opensuse/pi.config.sh deleted file mode 100755 index fca7b20..0000000 --- a/scripts/opensuse/pi.config.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env sh - -USER_FULL_NAME='Mek' -USER_NAME='mek' -USER_PASSWORD="${USER_PASSWORD:?'not set'}" -USER_TYPE='local' - -yast users add batchmode verbose type="${USER_TYPE}" username="${USER_NAME}" password="${USER_PASSWORD}" cn="${USER_FULL_NAME}" diff --git a/scripts/opensuse/pi.setup.sh b/scripts/opensuse/pi.setup.sh new file mode 100755 index 0000000..3eccace --- /dev/null +++ b/scripts/opensuse/pi.setup.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env sh + +: "${USER_FULL_NAME:='Mek'}" +: "${USER_NAME:='mek'}" +: "${USER_PASSWORD:?'not set'}" +: "${USER_TYPE:='local'}" + +yast users add batchmode verbose \ + type="$USER_TYPE" \ + username="$USER_NAME" \ + password="$USER_PASSWORD" \ + cn="$USER_FULL_NAME" diff --git a/scripts/raspberry pi os/docker.install.bash b/scripts/raspberry pi os/docker.install.bash index 9280f37..12c9313 100755 --- a/scripts/raspberry pi os/docker.install.bash +++ b/scripts/raspberry pi os/docker.install.bash @@ -3,7 +3,7 @@ set -e sudo curl -fsSL https://get.docker.com | sh - -sudo usermod -aG docker ${USER} +sudo usermod -aG docker $USER # logout && login to apply the new status diff --git a/scripts/reset-wifi-if-no-internet-connection.bash b/scripts/reset-wifi-if-no-internet-connection.bash index 08584a1..9eff64c 100755 --- a/scripts/reset-wifi-if-no-internet-connection.bash +++ b/scripts/reset-wifi-if-no-internet-connection.bash @@ -1,21 +1,21 @@ #!/usr/bin/env bash -interface="wlan0" +: "${INTERFACE:='wlan0'}" -max_retries=3 -timeout=1 +: ${MAX_RETRIES:=3} +: ${TIMEOUT:=1} -log_path="$(dirname $0)/$(basename $0).log" -log_prefix="$(date +'%Y-%m-%d %T')" +: "${LOG_PATH=$(dirname $0)/$(basename $0).log}" +: "${LOG_PREFIX=$(date +'%Y-%m-%d %T')}" i=0 -until [ $i -eq $max_retries ]; do +until [ $i -eq $MAX_RETRIES ]; do let "i++" - if nc -Nz -w $timeout www.google.com 443; then - echo "$log_prefix" "connection is OK" >> $log_path + if nc -Nz -w $TIMEOUT www.google.com 443; then + echo "$LOG_PREFIX" "connection is OK" >> $LOG_PATH break else - echo "$log_prefix" "no connection, resetting interface" >> $log_path - sudo ifconfig wlan0 down && sudo ifconfig wlan0 up + echo "$LOG_PREFIX" "no connection, resetting interface" >> $LOG_PATH + sudo ifconfig $INTERFACE down && sudo ifconfig $INTERFACE up fi done