Skip to content

Commit

Permalink
#837 Правка создания 4ого разщдела системного диска. Правка вывода в …
Browse files Browse the repository at this point in the history
…консоль.
  • Loading branch information
boffart committed Dec 24, 2024
1 parent 945c98c commit f1f5cf3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Core/System/RootFS/sbin/firmware_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fi
# Global variables
ENV_FILE=".env"
if [ -f "$ENV_FILE" ]; then
export $(cat "$ENV_FILE" | grep -v '^#' | xargs)
export $(xargs < "$ENV_FILE");
fi

# mountDiskPart: Mounts a disk partition by UUID.
Expand Down
9 changes: 7 additions & 2 deletions src/Core/System/RootFS/sbin/initial_storage_part_four
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ done
# If the partition was successfully created
if [ "$resultParted" = "0" ];then
if [ "$action" = "create" ]; then
/sbin/mkfs.ext4 -qF "${partitionFour}"
echo " - start mkfs.ext4 $partitionFour...";
/sbin/mkfs.ext4 -qF "$partitionFour"
echo " - result $?...";
sleep 5;
resize2fs ${partitionFour}
echo " - start resize2fs $partitionFour...";
resize2fs "$partitionFour"
echo " - result $?...";
sleep 5;
fi

Expand All @@ -137,6 +141,7 @@ if [ "$resultParted" = "0" ];then
if [ "$mountResult" != "0" ]; then
echo " - start check ${partitionFour}...";
/sbin/fsck.ext4 -p "$partitionFour";
echo " - result $?...";
mount -t "$type" "${partitionFour}" "$tmp_dir" 2> /dev/null > /dev/null;
mountResult=$?;
fi;
Expand Down
4 changes: 3 additions & 1 deletion src/Core/System/RootFS/sbin/pbx_firmware
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,12 @@ if [ -r "${img_file}" ]; then
fi
fi

part4Action='create';
if [ -n "$partitionFour" ]; then
export FS_BACKUP_PART4=fs-backup-part4.img;
echo " - Start backup fs $FS_BACKUP_PART4 super block for part4 ($partitionFour)"
dd if="$partitionFour" of="$FS_BACKUP_PART4" bs=1M count=1 >/dev/null 2>&1;
part4Action='update';
fi

echo " - Installing new image on $DISK"
Expand All @@ -178,7 +180,7 @@ if [ -r "${img_file}" ]; then
echo " - The execution of the dd command was finished...";

# Update the partition table
/sbin/initial_storage_part_four update "$DISK";
/sbin/initial_storage_part_four "$part4Action" "$DISK";
echo " - Check if it necessary to update 4-th storage partition. The result is ${?}...";
fi

Expand Down
17 changes: 8 additions & 9 deletions src/Core/System/RootFS/sbin/pbx_replace_fake_img.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,29 @@
#

ENV_FILE=".env"
# vars UUID_STORAGE, UPDATE_IMG_FILE in ENV_FILE
# vars STORAGE_UUID, UPDATE_IMG_FILE in ENV_FILE
if [ -f "$ENV_FILE" ]; then
export $(cat "$ENV_FILE" | grep -v '^#' | xargs)
export $(xargs < "$ENV_FILE");
fi
# Задание переменных
MOUNT_DIR="/mnt"
STORAGE_DIR="/storage/usbdisk1"
UPDATE_IMG_FILE_PATH="$UPDATE_IMG_FILE"
RAW_IMG_FILE="${UPDATE_IMG_FILE_PATH}_D.raw"
UUID_STORAGE="$STORAGE_UUID"
FIRMWARE_IMG_PATH="/mnt/firmware.img"
RAW_IMG_FILE="${UPDATE_IMG_FILE}_D.raw"

# Создание необходимых директорий
mkdir -p "$MOUNT_DIR" "$STORAGE_DIR"

echo " - mount storage for upgrade"
mount -rw UUID="$UUID_STORAGE" "$STORAGE_DIR" 2> /dev/null
mount -rw UUID="$STORAGE_UUID" "$STORAGE_DIR" 2> /dev/null
MOUNT_RESULT=$?
if [ "$MOUNT_RESULT" -ne 0 ]; then
echo " - Fail mount storage with UUID=$UUID_STORAGE to $STORAGE_DIR ..."
echo " - Fail mount storage with UUID=$STORAGE_UUID to $STORAGE_DIR ..."
exit 1
fi

echo " - unpack image file to raw format"
gunzip -c "$UPDATE_IMG_FILE_PATH" > "$RAW_IMG_FILE"
/bin/busybox gunzip -c "$UPDATE_IMG_FILE" > "$RAW_IMG_FILE"
loopName="$(losetup --show -f -o 524288 "$RAW_IMG_FILE")"

echo " - mount raw image file"
Expand All @@ -55,7 +53,8 @@ fi

if [ -f "$FIRMWARE_IMG_PATH" ]; then
echo " - replace fake image file";
cp "$FIRMWARE_IMG_PATH" "$UPDATE_IMG_FILE_PATH";
/bin/busybox md5sum "$FIRMWARE_IMG_PATH" "$UPDATE_IMG_FILE";
cp "$FIRMWARE_IMG_PATH" "$UPDATE_IMG_FILE";
else
echo " - FAIL replace fake image file";
fi
Expand Down

0 comments on commit f1f5cf3

Please sign in to comment.