mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
busybox-initramfs: init: cosmetics
This commit is contained in:
parent
5450520500
commit
1f14eb6a37
@ -22,12 +22,12 @@
|
||||
# http://www.gnu.org/copyleft/gpl.html
|
||||
################################################################################
|
||||
|
||||
# mount all needed special filesystems
|
||||
# mount all needed special filesystems
|
||||
/bin/busybox mount -t devtmpfs devtmpfs /dev
|
||||
/bin/busybox mount -t proc proc /proc
|
||||
/bin/busybox mount -t sysfs sysfs /sys
|
||||
|
||||
# set needed variables
|
||||
# set needed variables
|
||||
MODULE_DIR=/lib/modules
|
||||
|
||||
UPDATE_DIR=/storage/.update
|
||||
@ -49,19 +49,19 @@
|
||||
INSTALLED_MEMORY=`cat /proc/meminfo | grep 'MemTotal:' | awk '{print $2}'`
|
||||
SYSTEM_TORAM_LIMIT=1024000
|
||||
|
||||
# load any configuration
|
||||
# load any configuration
|
||||
if [ -f "/etc/initramfs.conf" ]; then
|
||||
. /etc/initramfs.conf
|
||||
fi
|
||||
|
||||
# hide kernel log messages on console
|
||||
# hide kernel log messages on console
|
||||
echo '1 4 1 7' > /proc/sys/kernel/printk
|
||||
|
||||
# clear screen and hide cursor
|
||||
# clear screen and hide cursor
|
||||
clear
|
||||
echo 0 > /sys/devices/virtual/graphics/fbcon/cursor_blink
|
||||
|
||||
# parse command line arguments
|
||||
# parse command line arguments
|
||||
for arg in $(cat /proc/cmdline); do
|
||||
case $arg in
|
||||
BOOT_IMAGE=*)
|
||||
@ -137,20 +137,20 @@
|
||||
echo "### Starting debugging shell... type exit to quit ###"
|
||||
|
||||
# show cursor
|
||||
echo 0 > /sys/devices/virtual/graphics/fbcon/cursor_blink
|
||||
echo 0 > /sys/devices/virtual/graphics/fbcon/cursor_blink
|
||||
|
||||
sh </dev/tty1 >/dev/tty1 2>&1
|
||||
}
|
||||
|
||||
error() {
|
||||
# Display fatal error message
|
||||
# $1:action which caused error, $2:message
|
||||
# Display fatal error message
|
||||
# $1:action which caused error, $2:message
|
||||
echo "*** Error in $BOOT_STEP: $1: $2 ***"
|
||||
debug_shell
|
||||
}
|
||||
|
||||
break_after() {
|
||||
# Start debug shell after boot step $1
|
||||
# Start debug shell after boot step $1
|
||||
case $BREAK in
|
||||
all|*$1*)
|
||||
debug_shell
|
||||
@ -163,7 +163,7 @@
|
||||
# $1:target, $2:mountpoint, $3:mount options, [$4:fs type]
|
||||
|
||||
mount_common() {
|
||||
# Common mount handler, handles block devices and filesystem images
|
||||
# Common mount handler, handles block devices and filesystem images
|
||||
MOUNT_OPTIONS="-o $3"
|
||||
[ -n "$4" ] && MOUNT_OPTIONS="-t $4 $MOUNT_OPTIONS"
|
||||
|
||||
@ -179,7 +179,7 @@
|
||||
}
|
||||
|
||||
mount_cifs() {
|
||||
# Mount CIFS (Samba) share
|
||||
# Mount CIFS (Samba) share
|
||||
CIFS_SHARE="${1%%,*}"
|
||||
CIFS_OPTIONS="${1#*,}"
|
||||
[ "$CIFS_OPTIONS" = "$1" ] && CIFS_OPTIONS=
|
||||
@ -188,7 +188,7 @@
|
||||
}
|
||||
|
||||
get_iscsistart_options() {
|
||||
# Convert kernel commandline ISCSI= options to iscsistart options
|
||||
# Convert kernel commandline ISCSI= options to iscsistart options
|
||||
IFS_SAVE="$IFS"
|
||||
IFS=,
|
||||
|
||||
@ -230,7 +230,7 @@
|
||||
}
|
||||
|
||||
mount_iscsi() {
|
||||
# Mount iSCSI target
|
||||
# Mount iSCSI target
|
||||
ISCSI_DEV="${1##*,}"
|
||||
ISCSI_OPTIONS="${1%,*}"
|
||||
|
||||
@ -268,7 +268,7 @@
|
||||
}
|
||||
|
||||
mount_nfs() {
|
||||
# Mount NFS export
|
||||
# Mount NFS export
|
||||
NFS_EXPORT="${1%%,*}"
|
||||
NFS_OPTIONS="${1#*,}"
|
||||
|
||||
@ -278,8 +278,8 @@
|
||||
}
|
||||
|
||||
mount_part() {
|
||||
# Mount a local or network filesystem
|
||||
# $1:[TYPE=]target, $2:mountpoint, $3:mount options, [$4:fs type]
|
||||
# Mount a local or network filesystem
|
||||
# $1:[TYPE=]target, $2:mountpoint, $3:mount options, [$4:fs type]
|
||||
progress "mount filesystem $1 ..."
|
||||
|
||||
MOUNT_TARGET="${1#*=}"
|
||||
@ -313,13 +313,13 @@
|
||||
update() {
|
||||
if [ -f "$UPDATE_DIR/$2" -a -f "$3" ]; then
|
||||
echo "updating $1..."
|
||||
mount -o remount,rw /flash
|
||||
mv $UPDATE_DIR/$2 $3
|
||||
# loopback file needs writable /flash all the time
|
||||
if [ "${disk%%=*}" != "FILE" ]; then
|
||||
mount -o remount,ro /flash
|
||||
fi
|
||||
sync
|
||||
mount -o remount,rw /flash
|
||||
mv $UPDATE_DIR/$2 $3
|
||||
# loopback file needs writable /flash all the time
|
||||
if [ "${disk%%=*}" != "FILE" ]; then
|
||||
mount -o remount,ro /flash
|
||||
fi
|
||||
sync
|
||||
fi
|
||||
}
|
||||
|
||||
@ -331,8 +331,8 @@
|
||||
|
||||
if [ -f $SYSTEM_ROOT/usr/share/bootloader/update.sh ]; then
|
||||
echo "updating Bootloader..."
|
||||
sh $SYSTEM_ROOT/usr/share/bootloader/update.sh
|
||||
sync
|
||||
sh $SYSTEM_ROOT/usr/share/bootloader/update.sh
|
||||
sync
|
||||
fi
|
||||
|
||||
umount /sysroot
|
||||
@ -375,8 +375,8 @@
|
||||
# load uvesafb module if needed
|
||||
if [ -f "$MODULE_DIR/uvesafb.ko" -a ! -e /dev/fb0 ]; then
|
||||
progress "Loading kernel module uvesafb.ko"
|
||||
insmod "$MODULE_DIR/uvesafb.ko" || \
|
||||
progress "... Failed to load kernel module uvesafb, skipping"
|
||||
insmod "$MODULE_DIR/uvesafb.ko" || \
|
||||
progress "... Failed to load kernel module uvesafb, skipping"
|
||||
|
||||
# set framebuffer to a default resolution (1024x768-32)
|
||||
if [ ! "$SWITCH_FRAMEBUFFER" = "no" ]; then
|
||||
@ -402,7 +402,7 @@
|
||||
progress "Checking disks"
|
||||
|
||||
if [ -x /bin/fsck_hfs ]; then
|
||||
# deal with hfs partitions
|
||||
# deal with hfs partitions
|
||||
hfsdiskprep
|
||||
fi
|
||||
}
|
||||
@ -473,7 +473,7 @@
|
||||
mkdir -p /storage/$OVERLAY_DIR
|
||||
umount /storage
|
||||
|
||||
# split $disk into $target,$options so we can append $OVERLAY_DIR
|
||||
# split $disk into $target,$options so we can append $OVERLAY_DIR
|
||||
options="${disk#*,}"
|
||||
target="${disk%%,*}"
|
||||
if [ "$options" = "$disk" ]; then
|
||||
@ -491,9 +491,9 @@
|
||||
progress "Checking for updates"
|
||||
|
||||
# check for ATV1 mach-o-kernel
|
||||
if [ -f "/flash/com.apple.Boot.plist" -a -f "/flash/boot.efi" ]; then
|
||||
UPDATE_KERNEL="MACH_KERNEL"
|
||||
fi
|
||||
if [ -f "/flash/com.apple.Boot.plist" -a -f "/flash/boot.efi" ]; then
|
||||
UPDATE_KERNEL="MACH_KERNEL"
|
||||
fi
|
||||
|
||||
UPDATE_TAR=`ls -1 "$UPDATE_DIR"/*.tar 2>/dev/null | head -n 1`
|
||||
if [ -f "$UPDATE_DIR/$UPDATE_KERNEL" -a -f "$UPDATE_DIR/$UPDATE_SYSTEM" -o -f "$UPDATE_TAR" ] ; then
|
||||
@ -527,18 +527,20 @@
|
||||
fi
|
||||
|
||||
# check md5 sums if .nocheck doesn't exist
|
||||
if [ "$MD5_NOCHECK" -eq "0" -a -f "$UPDATE_DIR/${UPDATE_KERNEL}.md5" -a -f "$UPDATE_DIR/${UPDATE_SYSTEM}.md5" ] ; then
|
||||
sed -i 's#target#/storage/.update#g' "$UPDATE_DIR/${UPDATE_KERNEL}.md5"
|
||||
sed -i 's#target#/storage/.update#g' "$UPDATE_DIR/${UPDATE_SYSTEM}.md5"
|
||||
if [ "$MD5_NOCHECK" -eq "0" ] ; then
|
||||
if [ -f "$UPDATE_DIR/${UPDATE_KERNEL}.md5" -a -f "$UPDATE_DIR/${UPDATE_SYSTEM}.md5" ] ; then
|
||||
sed -i 's#target#/storage/.update#g' "$UPDATE_DIR/${UPDATE_KERNEL}.md5"
|
||||
sed -i 's#target#/storage/.update#g' "$UPDATE_DIR/${UPDATE_SYSTEM}.md5"
|
||||
|
||||
echo "Checking ${UPDATE_KERNEL}.md5..."
|
||||
md5sum -c "$UPDATE_DIR/${UPDATE_KERNEL}.md5" || MD5_FAILED="1"
|
||||
echo "Checking ${UPDATE_KERNEL}.md5..."
|
||||
md5sum -c "$UPDATE_DIR/${UPDATE_KERNEL}.md5" || MD5_FAILED="1"
|
||||
|
||||
echo "Checking ${UPDATE_SYSTEM}.md5..."
|
||||
md5sum -c "$UPDATE_DIR/${UPDATE_SYSTEM}.md5" || MD5_FAILED="1"
|
||||
else
|
||||
echo "missing ${UPDATE_KERNEL}.md5 or ${UPDATE_SYSTEM}.md5..."
|
||||
MD5_FAILED="1"
|
||||
echo "Checking ${UPDATE_SYSTEM}.md5..."
|
||||
md5sum -c "$UPDATE_DIR/${UPDATE_SYSTEM}.md5" || MD5_FAILED="1"
|
||||
else
|
||||
echo "missing ${UPDATE_KERNEL}.md5 or ${UPDATE_SYSTEM}.md5..."
|
||||
MD5_FAILED="1"
|
||||
fi
|
||||
fi
|
||||
|
||||
# get sizes
|
||||
@ -615,7 +617,7 @@
|
||||
error "check arguments" "boot argument can't be FILE type..."
|
||||
fi
|
||||
|
||||
# main boot sequence
|
||||
# main boot sequence
|
||||
for BOOT_STEP in \
|
||||
load_modules \
|
||||
check_disks \
|
||||
@ -630,20 +632,20 @@
|
||||
|
||||
BOOT_STEP=final
|
||||
|
||||
# move some special filesystems
|
||||
# move some special filesystems
|
||||
/bin/busybox mount --move /dev /sysroot/dev
|
||||
/bin/busybox mount --move /proc /sysroot/proc
|
||||
/bin/busybox mount --move /sys /sysroot/sys
|
||||
|
||||
# tell OE settings addon to disable updates
|
||||
# tell OE settings addon to disable updates
|
||||
if [ "$UPDATE_DISABLED" = "yes" ] ; then
|
||||
echo "" > /sysroot/dev/.update_disabled
|
||||
fi
|
||||
# swap can not be used over nfs.(see scripts/mount-swap)
|
||||
# swap can not be used over nfs.(see scripts/mount-swap)
|
||||
if [ "$STORAGE_NETBOOT" = "yes" ] ; then
|
||||
echo "" > /sysroot/dev/.storage_netboot
|
||||
fi
|
||||
# switch to new sysroot and start real init
|
||||
# switch to new sysroot and start real init
|
||||
exec /bin/busybox switch_root /sysroot /lib/systemd/systemd $INIT_ARGS
|
||||
|
||||
error "switch_root" "Error in initramfs. Could not switch to new root"
|
||||
|
Loading…
x
Reference in New Issue
Block a user