[no ci] Overlay: script formatting

pull/1268/head
Viktor 2024-01-20 05:34:36 +01:00
parent af7d7371c5
commit 81070ca72a
3 changed files with 47 additions and 47 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
case "$1" in case "$1" in
start) start)
system_fb system_fb
;; ;;
esac esac

View File

@ -1,8 +1,8 @@
#!/bin/sh #!/bin/sh
on_exit() { on_exit() {
mountpoint -q /proc && umount /proc mountpoint -q /proc && umount /proc
exec /sbin/init $* exec /sbin/init $*
} }
trap on_exit 0 trap on_exit 0
@ -11,43 +11,43 @@ mount -t proc proc /proc || exit
grep -q overlay /proc/filesystems || exit grep -q overlay /proc/filesystems || exit
if ! grep -q 'root=.*nfs\|mmcblk\|ram' /proc/cmdline; then if ! grep -q 'root=.*nfs\|mmcblk\|ram' /proc/cmdline; then
if grep -q ubifs /proc/cmdline; then if grep -q ubifs /proc/cmdline; then
mount -t ubifs ubi0:rootfs_data /overlay mount -t ubifs ubi0:rootfs_data /overlay
else else
mtdblkdev=$(awk -F ':' '/rootfs_data/ {print $1}' /proc/mtd | sed 's/mtd/mtdblock/') mtdblkdev=$(awk -F ':' '/rootfs_data/ {print $1}' /proc/mtd | sed 's/mtd/mtdblock/')
mtdchrdev=$(grep 'rootfs_data' /proc/mtd | cut -d: -f1) mtdchrdev=$(grep 'rootfs_data' /proc/mtd | cut -d: -f1)
mount -t jffs2 /dev/${mtdblkdev} /overlay mount -t jffs2 /dev/${mtdblkdev} /overlay
if [ $? -ne 0 ] || { dmesg | grep "jffs2.*: Magic bitmask.*not found" >/dev/null 2>&1; }; then if [ $? -ne 0 ] || { dmesg | grep "jffs2.*: Magic bitmask.*not found" >/dev/null 2>&1; }; then
echo "jffs2 health check error, format required!" echo "jffs2 health check error, format required!"
flash_eraseall -j /dev/${mtdchrdev} flash_eraseall -j /dev/${mtdchrdev}
echo "Done! Remounting..." echo "Done! Remounting..."
mount -t jffs2 /dev/${mtdblkdev} /overlay || mount -t tmpfs tmpfs /overlay || exit mount -t jffs2 /dev/${mtdblkdev} /overlay || mount -t tmpfs tmpfs /overlay || exit
if ! cat /proc/mounts | grep ${mtdblkdev}; then if ! cat /proc/mounts | grep ${mtdblkdev}; then
echo "--------------------------------" echo "--------------------------------"
echo "Crash - your flash in the trash!" echo "Crash - your flash in the trash!"
echo "--------------------------------" echo "--------------------------------"
fi fi
fi fi
fi fi
if grep -q overlayfs /proc/filesystems; then if grep -q overlayfs /proc/filesystems; then
mount -t overlayfs overlayfs -o lowerdir=/,upperdir=/overlay,ro /mnt || { mount -t overlayfs overlayfs -o lowerdir=/,upperdir=/overlay,ro /mnt || {
umount /overlay umount /overlay
exit exit
} }
else else
overlay_rootdir=/overlay/root overlay_rootdir=/overlay/root
overlay_workdir=/overlay/work overlay_workdir=/overlay/work
mkdir -p ${overlay_rootdir} ${overlay_workdir} mkdir -p ${overlay_rootdir} ${overlay_workdir}
mount -t overlay overlay -o lowerdir=/,upperdir=${overlay_rootdir},workdir=${overlay_workdir} /mnt || { mount -t overlay overlay -o lowerdir=/,upperdir=${overlay_rootdir},workdir=${overlay_workdir} /mnt || {
umount /overlay umount /overlay
exit exit
} }
fi fi
pivot_root /mnt /mnt/rom pivot_root /mnt /mnt/rom
mount -o noatime,move /rom/proc /proc mount -o noatime,move /rom/proc /proc
mount -o noatime,move /rom/dev /dev mount -o noatime,move /rom/dev /dev
mount -o noatime,move /rom/overlay /overlay mount -o noatime,move /rom/overlay /overlay
fi fi

View File

@ -3,8 +3,8 @@
# Get the timezone from the u-boot environment variable # Get the timezone from the u-boot environment variable
timezone=$(fw_printenv -n timezone 2>/dev/null) timezone=$(fw_printenv -n timezone 2>/dev/null)
if [ -z "$timezone" ]; then if [ -z "$timezone" ]; then
echo "Timezone env variable not found, using system default." echo "Timezone env variable not found, using system default."
exit 1 exit 1
fi fi
echo "User defined timezone: $timezone" echo "User defined timezone: $timezone"
@ -14,15 +14,15 @@ current_timezone=$(cat /etc/timezone 2>/dev/null)
current_tz_value=$(cat /etc/TZ 2>/dev/null) current_tz_value=$(cat /etc/TZ 2>/dev/null)
if [ "$timezone" = "$current_timezone" ] && [ "$timezone" = "$current_tz_value" ]; then if [ "$timezone" = "$current_timezone" ] && [ "$timezone" = "$current_tz_value" ]; then
echo "Timezone settings are already up to date." echo "Timezone settings are already up to date."
exit 0 exit 0
fi fi
# Search for the timezone in the file # Search for the timezone in the file
matching_line=$(zcat /var/www/a/tz.js.gz | grep -i -F "$timezone") matching_line=$(zcat /var/www/a/tz.js.gz | grep -i -F "$timezone")
if [ -z "$matching_line" ]; then if [ -z "$matching_line" ]; then
echo "Timezone not found in system file." echo "Timezone not found in system file."
exit 1 exit 1
fi fi
# Extract the value associated with the timezone # Extract the value associated with the timezone
@ -37,5 +37,5 @@ echo $timezone > /etc/timezone
export TZ=$value export TZ=$value
if tty -s; then if tty -s; then
echo "timezone.sh: You are running from a shell, please restart or log out to update timezone environment variables." echo "timezone.sh: You are running from a shell, please restart or log out to update timezone environment variables."
fi fi