Skip to content

Commit

Permalink
fixup indentation
Browse files Browse the repository at this point in the history
Tabs and spaces were used throughout the code, use tabs only
  • Loading branch information
BoukeHaarsma23 committed Jul 31, 2024
1 parent 3a98281 commit 1a3a261
Show file tree
Hide file tree
Showing 11 changed files with 542 additions and 542 deletions.
126 changes: 63 additions & 63 deletions __frzr
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@
source "${BASH_SOURCE%/*}/__frzr-envars"

frzr_status() {
# Output frzr status tracker using the JSON format
cat <<EOF
# Output frzr status tracker using the JSON format
cat <<EOF
{
"Signals": {
"Task MSG": "$TASK_MSG",
"Task Tracker": "$TASK_TRACKER",
"Task Error": "$TASK_ERROR",
"Task Error MSG": "$TASK_ERROR_MSG",
"Task Warning": "$TASK_WARNING",
"Task Warning MSG": "$TASK_WARNING_MSG",
"Task Progress": "$TASK_PROGRESS",
},
"Globals": {
"Target": "$TARGET",
"Local Install": "$LOCAL_INSTALL",
"Repair Install": "$REPAIR_INSTALL",
"Show UI": "$SHOW_UI",
"EFI Path": "$EFI_MOUNT_PATH",
"Mount Path": "$MOUNT_PATH",
"SUBVOL": "$SUBVOL",
"Deploy Path": "$DEPLOY_PATH",
"Frzr Check Update": "$FRZR_CHECK_UPDATE",
"Frzr Params": "$FRZR_PARAMS",
"File Name": "$FILE_NAME",
"IMG Name": "$IMG_NAME",
"Base URL": "$BASE_URL",
"Repo": "$REPO",
"Release URL": "$RELEASES_URL",
"Expected Checksum": "$EXPECTED_CHECKSUM",
"Actual Checksum": "$ACTUAL_CHECKSUM",
"Channel": "$CHANNEL",
"State Machine State": "$STATE"
}
"Signals": {
"Task MSG": "$TASK_MSG",
"Task Tracker": "$TASK_TRACKER",
"Task Error": "$TASK_ERROR",
"Task Error MSG": "$TASK_ERROR_MSG",
"Task Warning": "$TASK_WARNING",
"Task Warning MSG": "$TASK_WARNING_MSG",
"Task Progress": "$TASK_PROGRESS",
},
"Globals": {
"Target": "$TARGET",
"Local Install": "$LOCAL_INSTALL",
"Repair Install": "$REPAIR_INSTALL",
"Show UI": "$SHOW_UI",
"EFI Path": "$EFI_MOUNT_PATH",
"Mount Path": "$MOUNT_PATH",
"SUBVOL": "$SUBVOL",
"Deploy Path": "$DEPLOY_PATH",
"Frzr Check Update": "$FRZR_CHECK_UPDATE",
"Frzr Params": "$FRZR_PARAMS",
"File Name": "$FILE_NAME",
"IMG Name": "$IMG_NAME",
"Base URL": "$BASE_URL",
"Repo": "$REPO",
"Release URL": "$RELEASES_URL",
"Expected Checksum": "$EXPECTED_CHECKSUM",
"Actual Checksum": "$ACTUAL_CHECKSUM",
"Channel": "$CHANNEL",
"State Machine State": "$STATE"
}
}
EOF
}
Expand All @@ -61,20 +61,20 @@ send_data(){
}

frzr_check_bootenv() {
if [ -d /tmp/frzr_root ]; then
UPGRADE=0
else
UPGRADE=1
fi
if [ -d /tmp/frzr_root ]; then
UPGRADE=0
else
UPGRADE=1
fi
}

# Perform required mounts to have a working chroot environment
# $1 the rootfs to be chrooted
# stdout OK, an error otherwise
frzr_mount_chroot() {
local CHROOT_PATH=$1
if mount -t proc /proc "${CHROOT_PATH}/proc"; then
local CHROOT_PATH=$1
if mount -t proc /proc "${CHROOT_PATH}/proc"; then
if mount -t sysfs /sys "${CHROOT_PATH}/sys"; then
if mount --rbind /dev "${CHROOT_PATH}/dev"; then
echo "OK"
Expand All @@ -91,20 +91,20 @@ frzr_mount_chroot() {

frzr_exec_chroot() {
local CHROOT_PATH=$1
local CHROOT_CMD=$2
local CHROOT_CMD=$2

chroot ${CHROOT_PATH} /bin/bash <<EOF
${CHROOT_CMD}
${CHROOT_CMD}
EOF
}

frzr_umount_chroot() {
local CHROOT_PATH=$1
local CHROOT_PATH=$1

umount -l "${CHROOT_PATH}/proc"
umount -l "${CHROOT_PATH}/sys"
mount --make-rslave "${CHROOT_PATH}/dev"
umount -l "${CHROOT_PATH}/dev"
umount -l "${CHROOT_PATH}/proc"
umount -l "${CHROOT_PATH}/sys"
mount --make-rslave "${CHROOT_PATH}/dev"
umount -l "${CHROOT_PATH}/dev"
}

# Get the UUID of the desk containing the given directory
Expand Down Expand Up @@ -309,29 +309,29 @@ install_image() {
if [ -d "${deploy_path}" ]; then
if [[ "${IMG_FILE##*.}" == "img" ]]; then
if btrfs receive --quiet "${DEPLOY_PATH}" < "${IMG_FILE}"; then
echo "OK"
else
echo "ERROR: Could not install raw image '${IMG_FILE}' to '${DEPLOY_PATH}'"
fi
echo "OK"
else
echo "ERROR: Could not install raw image '${IMG_FILE}' to '${DEPLOY_PATH}'"
fi
elif [[ "${IMG_FILE##*.}" == "zst" ]]; then
if zstd -d -c "${IMG_FILE}" | btrfs receive --quiet "${DEPLOY_PATH}"; then
echo "OK"
else
echo "ERROR: Could not install zstd image '${IMG_FILE}' to '${DEPLOY_PATH}'"
fi
echo "OK"
else
echo "ERROR: Could not install zstd image '${IMG_FILE}' to '${DEPLOY_PATH}'"
fi
elif [[ "${IMG_FILE##*.}" == "xz" ]]; then
if [[ "${IMG_FILE}" == *".tar.xz" ]]; then
if tar xfO ${IMG_FILE} | btrfs receive --quiet "${DEPLOY_PATH}"; then
echo "OK"
else
echo "ERROR: Could not install tar.xz image '${IMG_FILE}' to '${DEPLOY_PATH}'"
fi
echo "OK"
else
echo "ERROR: Could not install tar.xz image '${IMG_FILE}' to '${DEPLOY_PATH}'"
fi
else
if xz -dc "${IMG_FILE}" | btrfs receive --quiet "${DEPLOY_PATH}"; then
echo "OK"
else
echo "ERROR: Could not install xz image '${IMG_FILE}' to '${DEPLOY_PATH}'"
fi
echo "OK"
else
echo "ERROR: Could not install xz image '${IMG_FILE}' to '${DEPLOY_PATH}'"
fi
fi
else
echo "ERROR: Unsupported file format for file '${IMG_FILE}'"
Expand Down
92 changes: 46 additions & 46 deletions __frzr-bootloader
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
source "${BASH_SOURCE%/*}/__frzr" "$@"

frzr_bootloader() {
NAME=${1}
NAME=${1}

# by default the deployment is the running one
DEPLOY_PATH="/"
SUBVOL="/"
# by default the deployment is the running one
DEPLOY_PATH="/"
SUBVOL="/"

local RUNNING=true
RUNNING=true
RUNNING=true
STATE="BEGIN"
while $RUNNING; do
case "$STATE" in
Expand Down Expand Up @@ -57,7 +57,7 @@ frzr_bootloader() {
fi

# Make sure the EFI partition is mounted during the deployment procedure
TASK_MSG="Checking for EFI partition"
TASK_MSG="Checking for EFI partition"
send_data
if mount | grep -Fq "on ${EFI_MOUNT_PATH}"; then
local MOUNTED_EFI_MOUNT_PATH="no"
Expand All @@ -79,44 +79,44 @@ frzr_bootloader() {
STATE="CHECK"
;;

"CHECK")
if [ -z "$NAME" ]; then
if [ -e "/build_info" ]; then
NAME=$(cat "/build_info" | head -1)
fi
"CHECK")
if [ -z "$NAME" ]; then
if [ -e "/build_info" ]; then
NAME=$(cat "/build_info" | head -1)
fi

if [ -z "$NAME" ]; then
TASK_ERROR_MSG="Could not fetch deployment name"
STATE="FAIL"
if [ -z "$NAME" ]; then
TASK_ERROR_MSG="Could not fetch deployment name"
STATE="FAIL"
send_data
continue
fi
else
DEPLOY_PATH="${MOUNT_PATH}/deployments"
SUBVOL="${DEPLOY_PATH}/${NAME}"
continue
fi
else
DEPLOY_PATH="${MOUNT_PATH}/deployments"
SUBVOL="${DEPLOY_PATH}/${NAME}"

# Make sure DEPLOY_PATH exists
mkdir -p "${DEPLOY_PATH}"
if [ ! -d "${DEPLOY_PATH}" ]; then
TASK_ERROR=1
TASK_ERROR_MSG="Could not create ${DEPLOY_PATH} to to store deployments"
STATE="FAIL"
# Make sure DEPLOY_PATH exists
mkdir -p "${DEPLOY_PATH}"
if [ ! -d "${DEPLOY_PATH}" ]; then
TASK_ERROR=1
TASK_ERROR_MSG="Could not create ${DEPLOY_PATH} to to store deployments"
STATE="FAIL"
send_data
continue
fi
# Make sure SUBVOL exists
if [ ! -d "${SUBVOL}" ]; then
TASK_ERROR=1
TASK_ERROR_MSG="Could not find deployment '${NAME}', '${SUBVOL}' was searched"
STATE="FAIL"
continue
fi
# Make sure SUBVOL exists
if [ ! -d "${SUBVOL}" ]; then
TASK_ERROR=1
TASK_ERROR_MSG="Could not find deployment '${NAME}', '${SUBVOL}' was searched"
STATE="FAIL"
send_data
continue
fi
fi
continue
fi
fi

STATE="BOOTLOADER"
;;
STATE="BOOTLOADER"
;;

"BOOTLOADER")

Expand All @@ -135,10 +135,10 @@ frzr_bootloader() {
fi

STATE="CONFIGURE"
;;
;;

"CONFIGURE")
# Get the rootfs UUID: this will be used in generating the systemd-boot entry
# Get the rootfs UUID: this will be used in generating the systemd-boot entry
TASK_MSG="Finding deployment partition UUID"
local rootfs_uuid=$(get_uuid "${SUBVOL}")
if echo "$rootfs_uuid" | grep -Fq "ERROR"; then
Expand All @@ -157,8 +157,8 @@ frzr_bootloader() {
STATE="FAIL"
send_data
continue
elif [ "${rootfs_subvolid}" = "5" ]; then
TASK_ERROR_MSG="Could not identify the correct subvolid of the running deployment"
elif [ "${rootfs_subvolid}" = "5" ]; then
TASK_ERROR_MSG="Could not identify the correct subvolid of the running deployment"
STATE="FAIL"
send_data
continue
Expand Down Expand Up @@ -195,7 +195,7 @@ frzr_bootloader() {
continue
fi

# This is used to update the EFI partition: setting up systemd-boot (or whatever else bootlader might be supported) to boot the new deployment
# This is used to update the EFI partition: setting up systemd-boot (or whatever else bootlader might be supported) to boot the new deployment
local efi_update_result=$(prepare_efi_partition "${NAME}" "${EFI_MOUNT_PATH}" "${SUBVOL}/boot" "${additional_arguments}" "${rootfs_uuid}" "${rootfs_subvolid}")
if echo "${efi_update_result}" | grep -q 'ERROR'; then
# bootloader configuration could not be updated
Expand All @@ -206,9 +206,9 @@ frzr_bootloader() {
continue
fi

STATE="SUCCESS"
;;
STATE="SUCCESS"
;;
"SUCCESS")
# This state should only be used if the unlock completed without errors
#TASK_STATE="SUCCESS"
Expand Down
Loading

0 comments on commit 1a3a261

Please sign in to comment.