mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 05:06:43 +00:00
Merge pull request #3302 from antonlacon/init-changes
busybox/init: cleanup
This commit is contained in:
commit
fca5752af1
@ -6,191 +6,75 @@
|
|||||||
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
||||||
# Copyright (C) 2016-present Team LibreELEC (https://libreelec.tv)
|
# Copyright (C) 2016-present Team LibreELEC (https://libreelec.tv)
|
||||||
|
|
||||||
# create directories
|
# create directories
|
||||||
/usr/bin/busybox mkdir -p /dev
|
/usr/bin/busybox mkdir -p /dev
|
||||||
/usr/bin/busybox mkdir -p /proc
|
/usr/bin/busybox mkdir -p /proc
|
||||||
/usr/bin/busybox mkdir -p /sys
|
/usr/bin/busybox mkdir -p /sys
|
||||||
/usr/bin/busybox mkdir -p /tmp
|
/usr/bin/busybox mkdir -p /tmp
|
||||||
/usr/bin/busybox mkdir -p /flash
|
/usr/bin/busybox mkdir -p /flash
|
||||||
/usr/bin/busybox mkdir -p /sysroot
|
/usr/bin/busybox mkdir -p /sysroot
|
||||||
/usr/bin/busybox mkdir -p /storage
|
/usr/bin/busybox mkdir -p /storage
|
||||||
|
|
||||||
# mount all needed special filesystems
|
# mount all needed special filesystems
|
||||||
/usr/bin/busybox mount -t devtmpfs devtmpfs /dev
|
/usr/bin/busybox mount -t devtmpfs devtmpfs /dev
|
||||||
/usr/bin/busybox mount -t proc proc /proc
|
/usr/bin/busybox mount -t proc proc /proc
|
||||||
/usr/bin/busybox mount -t sysfs sysfs /sys
|
/usr/bin/busybox mount -t sysfs sysfs /sys
|
||||||
|
|
||||||
# common functions
|
# set needed variables
|
||||||
. /functions
|
MODULE_DIR=/usr/lib/modules
|
||||||
|
|
||||||
# set needed variables
|
UPDATE_ROOT=/storage/.update
|
||||||
MODULE_DIR=/usr/lib/modules
|
UPDATE_DIR="$UPDATE_ROOT"
|
||||||
|
|
||||||
UPDATE_ROOT=/storage/.update
|
UPDATE_KERNEL="KERNEL"
|
||||||
UPDATE_DIR="$UPDATE_ROOT"
|
UPDATE_SYSTEM="SYSTEM"
|
||||||
|
IMAGE_KERNEL="@KERNEL_NAME@"
|
||||||
|
IMAGE_SYSTEM="SYSTEM"
|
||||||
|
|
||||||
UPDATE_KERNEL="KERNEL"
|
BOOT_STEP="start"
|
||||||
UPDATE_SYSTEM="SYSTEM"
|
MD5_FAILED="0"
|
||||||
IMAGE_KERNEL="@KERNEL_NAME@"
|
RUN_FSCK="yes"
|
||||||
IMAGE_SYSTEM="SYSTEM"
|
RUN_FSCK_DISKS=""
|
||||||
|
SYSLINUX_DEFAULT=""
|
||||||
|
GRUB_DEFAULT=""
|
||||||
|
|
||||||
BOOT_STEP="start"
|
NBD_DEVS="0"
|
||||||
MD5_FAILED="0"
|
FLASH_FREE_MIN="5"
|
||||||
RUN_FSCK="yes"
|
|
||||||
RUN_FSCK_DISKS=""
|
|
||||||
SYSLINUX_DEFAULT=""
|
|
||||||
GRUB_DEFAULT=""
|
|
||||||
|
|
||||||
NBD_DEVS="0"
|
INSTALLED_MEMORY=$(cat /proc/meminfo | grep 'MemTotal:' | awk '{print $2}')
|
||||||
FLASH_FREE_MIN="5"
|
SYSTEM_TORAM_LIMIT=1024000
|
||||||
|
|
||||||
INSTALLED_MEMORY=$(cat /proc/meminfo | grep 'MemTotal:' | awk '{print $2}')
|
LIVE="no"
|
||||||
SYSTEM_TORAM_LIMIT=1024000
|
|
||||||
|
|
||||||
LIVE="no"
|
BREAK_TRIPPED="no"
|
||||||
|
|
||||||
BREAK_TRIPPED="no"
|
# Get a serial number if present (eg. RPi) otherwise use MAC address from eth0
|
||||||
|
MACHINE_UID="$(cat /proc/cpuinfo | awk '/^Serial/{s=$3; gsub ("^0*","",s); print s}')"
|
||||||
|
[ -z "$MACHINE_UID" ] && MACHINE_UID="$(cat /sys/class/net/eth0/address 2>/dev/null | tr -d :)"
|
||||||
|
|
||||||
# Get a serial number if present (eg. RPi) otherwise use MAC address from eth0
|
# common functions
|
||||||
MACHINE_UID="$(cat /proc/cpuinfo | awk '/^Serial/{s=$3; gsub ("^0*","",s); print s}')"
|
. /functions
|
||||||
[ -z "$MACHINE_UID" ] && MACHINE_UID="$(cat /sys/class/net/eth0/address 2>/dev/null | tr -d :)"
|
|
||||||
|
|
||||||
# hide kernel log messages on console
|
# script functions
|
||||||
echo '1 4 1 7' > /proc/sys/kernel/printk
|
progress() {
|
||||||
|
|
||||||
# set ondemand up_threshold
|
|
||||||
if [ -e /sys/devices/system/cpu/cpufreq/ondemand/up_threshold ] ; then
|
|
||||||
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
|
|
||||||
fi
|
|
||||||
|
|
||||||
# run platform_init script if exists
|
|
||||||
if [ -f "./platform_init" ]; then
|
|
||||||
./platform_init
|
|
||||||
fi
|
|
||||||
|
|
||||||
# clear screen and hide cursor
|
|
||||||
clear
|
|
||||||
hidecursor
|
|
||||||
|
|
||||||
# parse command line arguments
|
|
||||||
for arg in $(cat /proc/cmdline); do
|
|
||||||
case $arg in
|
|
||||||
BOOT_IMAGE=*)
|
|
||||||
IMAGE_KERNEL="${arg#*=}"
|
|
||||||
[ "${IMAGE_KERNEL:0:1}" = "/" ] && IMAGE_KERNEL="${IMAGE_KERNEL:1}"
|
|
||||||
;;
|
|
||||||
SYSTEM_IMAGE=*)
|
|
||||||
IMAGE_SYSTEM="${arg#*=}"
|
|
||||||
[ "${IMAGE_SYSTEM:0:1}" = "/" ] && IMAGE_SYSTEM="${IMAGE_SYSTEM:1}"
|
|
||||||
;;
|
|
||||||
boot=*)
|
|
||||||
boot="${arg#*=}"
|
|
||||||
case $boot in
|
|
||||||
ISCSI=*|NBD=*|NFS=*)
|
|
||||||
UPDATE_DISABLED=yes
|
|
||||||
FLASH_NETBOOT=yes
|
|
||||||
;;
|
|
||||||
/dev/*|LABEL=*|UUID=*)
|
|
||||||
RUN_FSCK_DISKS="$RUN_FSCK_DISKS $boot"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
disk=*)
|
|
||||||
disk="${arg#*=}"
|
|
||||||
case $disk in
|
|
||||||
ISCSI=*|NBD=*|NFS=*)
|
|
||||||
STORAGE_NETBOOT=yes
|
|
||||||
;;
|
|
||||||
/dev/*|LABEL=*|UUID=*)
|
|
||||||
RUN_FSCK_DISKS="$RUN_FSCK_DISKS $disk"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
wol_mac=*)
|
|
||||||
wol_mac="${arg#*=}"
|
|
||||||
;;
|
|
||||||
wol_wait=*)
|
|
||||||
wol_wait="${arg#*=}"
|
|
||||||
;;
|
|
||||||
textmode)
|
|
||||||
INIT_UNIT="--unit=textmode.target"
|
|
||||||
;;
|
|
||||||
installer)
|
|
||||||
INIT_UNIT="--unit=installer.target"
|
|
||||||
SYSLINUX_DEFAULT="installer"
|
|
||||||
;;
|
|
||||||
debugging)
|
|
||||||
DEBUG=yes
|
|
||||||
;;
|
|
||||||
progress)
|
|
||||||
PROGRESS=yes
|
|
||||||
INIT_ARGS="$INIT_ARGS --show-status=1"
|
|
||||||
;;
|
|
||||||
nofsck)
|
|
||||||
RUN_FSCK=no
|
|
||||||
;;
|
|
||||||
nosplash)
|
|
||||||
SPLASH=no
|
|
||||||
;;
|
|
||||||
noram)
|
|
||||||
SYSTEM_TORAM=no
|
|
||||||
;;
|
|
||||||
ramlimit=*)
|
|
||||||
SYSTEM_TORAM_LIMIT="${arg#*=}"
|
|
||||||
;;
|
|
||||||
live)
|
|
||||||
LIVE=yes
|
|
||||||
SYSLINUX_DEFAULT="live"
|
|
||||||
;;
|
|
||||||
portable)
|
|
||||||
SYSLINUX_DEFAULT="run"
|
|
||||||
;;
|
|
||||||
grub_live)
|
|
||||||
LIVE=yes
|
|
||||||
GRUB_DEFAULT="Live"
|
|
||||||
;;
|
|
||||||
grub_portable)
|
|
||||||
GRUB_DEFAULT="Run"
|
|
||||||
;;
|
|
||||||
overlay)
|
|
||||||
OVERLAY=yes
|
|
||||||
;;
|
|
||||||
setfbres=*)
|
|
||||||
SWITCH_FRAMEBUFFER="${arg#*=}"
|
|
||||||
SWITCH_FRAMEBUFFER="${SWITCH_FRAMEBUFFER//,/ }"
|
|
||||||
;;
|
|
||||||
break=*)
|
|
||||||
BREAK="${arg#*=}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if test "$DEBUG" = "yes"; then
|
|
||||||
exec 3>&1
|
|
||||||
else
|
|
||||||
exec 3>/dev/null
|
|
||||||
fi
|
|
||||||
SILENT_OUT=3
|
|
||||||
|
|
||||||
progress() {
|
|
||||||
if test "$PROGRESS" = "yes"; then
|
if test "$PROGRESS" = "yes"; then
|
||||||
echo "### $1 ###" >&2
|
echo "### $1 ###" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_msg() {
|
debug_msg() {
|
||||||
echo "$1" >&$SILENT_OUT
|
echo "$1" >&$SILENT_OUT
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_shell() {
|
debug_shell() {
|
||||||
echo "### Starting debugging shell for boot step: $BOOT_STEP... type exit to quit ###"
|
echo "### Starting debugging shell for boot step: $BOOT_STEP... type exit to quit ###"
|
||||||
|
|
||||||
showcursor
|
showcursor
|
||||||
|
|
||||||
setsid cttyhack sh
|
setsid cttyhack sh
|
||||||
}
|
}
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
# Display fatal error message
|
# Display fatal error message
|
||||||
# $1:action which caused error, $2:message
|
# $1:action which caused error, $2:message
|
||||||
# Send debug_shell output to stderr, in case caller is redirecting/consuming stdout
|
# Send debug_shell output to stderr, in case caller is redirecting/consuming stdout
|
||||||
@ -198,9 +82,9 @@
|
|||||||
echo "*** Error in $BOOT_STEP: $1: $2 ***" >&2
|
echo "*** Error in $BOOT_STEP: $1: $2 ***" >&2
|
||||||
debug_shell >&2
|
debug_shell >&2
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
break_after() {
|
break_after() {
|
||||||
# Start debug shell after boot step $1, and all subsequent steps
|
# Start debug shell after boot step $1, and all subsequent steps
|
||||||
if [ $BREAK_TRIPPED == yes ]; then
|
if [ $BREAK_TRIPPED == yes ]; then
|
||||||
debug_shell
|
debug_shell
|
||||||
@ -212,12 +96,12 @@
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Mount handlers
|
# Mount handlers
|
||||||
# All handlers take the following parameters:
|
# All handlers take the following parameters:
|
||||||
# $1:target, $2:mountpoint, $3:mount options, [$4:fs type]
|
# $1:target, $2:mountpoint, $3:mount options, [$4:fs type]
|
||||||
mount_common() {
|
mount_common() {
|
||||||
# Common mount handler, handles block devices and filesystem images
|
# Common mount handler, handles block devices and filesystem images
|
||||||
MOUNT_OPTIONS="-o $3"
|
MOUNT_OPTIONS="-o $3"
|
||||||
[ -n "$4" ] && MOUNT_OPTIONS="-t $4 $MOUNT_OPTIONS"
|
[ -n "$4" ] && MOUNT_OPTIONS="-t $4 $MOUNT_OPTIONS"
|
||||||
@ -232,9 +116,9 @@
|
|||||||
done
|
done
|
||||||
[ "$ERR_ENV" -eq "0" ] && return 0
|
[ "$ERR_ENV" -eq "0" ] && return 0
|
||||||
error "mount_common" "Could not mount $1"
|
error "mount_common" "Could not mount $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_iscsistart_options() {
|
get_iscsistart_options() {
|
||||||
# Convert kernel commandline ISCSI= options to iscsistart options
|
# Convert kernel commandline ISCSI= options to iscsistart options
|
||||||
IFS_SAVE="$IFS"
|
IFS_SAVE="$IFS"
|
||||||
IFS=,
|
IFS=,
|
||||||
@ -274,9 +158,9 @@
|
|||||||
done
|
done
|
||||||
|
|
||||||
IFS="$IFS_SAVE"
|
IFS="$IFS_SAVE"
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_iscsi() {
|
mount_iscsi() {
|
||||||
# Mount iSCSI target
|
# Mount iSCSI target
|
||||||
ISCSI_DEV="${1##*,}"
|
ISCSI_DEV="${1##*,}"
|
||||||
ISCSI_OPTIONS="${1%,*}"
|
ISCSI_OPTIONS="${1%,*}"
|
||||||
@ -287,34 +171,30 @@
|
|||||||
|
|
||||||
if [ "$ISCSI_OPTIONS" = "auto" ]; then
|
if [ "$ISCSI_OPTIONS" = "auto" ]; then
|
||||||
progress "Network configuration based on iBFT"
|
progress "Network configuration based on iBFT"
|
||||||
/usr/sbin/iscsistart -N >&$SILENT_OUT 2>&1 || \
|
/usr/sbin/iscsistart -N >&$SILENT_OUT 2>&1 || error "iscsistart" "Unable to configure network"
|
||||||
error "iscsistart" "Unable to configure network"
|
|
||||||
progress "iSCSI auto connect based on iBFT"
|
progress "iSCSI auto connect based on iBFT"
|
||||||
/usr/sbin/iscsistart -b >&$SILENT_OUT 2>&1 || \
|
/usr/sbin/iscsistart -b >&$SILENT_OUT 2>&1 || error "iscsistart" "Unable to auto connect"
|
||||||
error "iscsistart" "Unable to auto connect"
|
|
||||||
else
|
else
|
||||||
/usr/sbin/iscsistart $(get_iscsistart_options "$ISCSI_OPTIONS") >&$SILENT_OUT 2>&1 || \
|
/usr/sbin/iscsistart $(get_iscsistart_options "$ISCSI_OPTIONS") >&$SILENT_OUT 2>&1 || error "iscsistart" "Unable to connect to ISCSI target"
|
||||||
error "iscsistart" "Unable to connect to ISCSI target"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mount_common "$ISCSI_DEV" "$2" "$3" "$4"
|
mount_common "$ISCSI_DEV" "$2" "$3" "$4"
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_nbd() {
|
mount_nbd() {
|
||||||
# Mount NBD device
|
# Mount NBD device
|
||||||
NBD_SERVER="${1%%:*}"
|
NBD_SERVER="${1%%:*}"
|
||||||
NBD_PORT="${1#*:}"
|
NBD_PORT="${1#*:}"
|
||||||
NBD_DEV="/dev/nbd$NBD_DEVS"
|
NBD_DEV="/dev/nbd$NBD_DEVS"
|
||||||
|
|
||||||
nbd-client $NBD_SERVER $NBD_PORT $NBD_DEV >&$SILENT_OUT 2>&1 || \
|
nbd-client $NBD_SERVER $NBD_PORT $NBD_DEV >&$SILENT_OUT 2>&1 || error "nbd-client" "Could not connect to NBD server $1"
|
||||||
error "nbd-client" "Could not connect to NBD server $1"
|
|
||||||
|
|
||||||
mount_common "$NBD_DEV" "$2" "$3" "$4"
|
mount_common "$NBD_DEV" "$2" "$3" "$4"
|
||||||
|
|
||||||
NBD_DEVS=$(( NBD_DEVS + 1 ))
|
NBD_DEVS=$(( NBD_DEVS + 1 ))
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_nfs() {
|
mount_nfs() {
|
||||||
# Mount NFS export
|
# Mount NFS export
|
||||||
NFS_EXPORT="${1%%,*}"
|
NFS_EXPORT="${1%%,*}"
|
||||||
NFS_OPTIONS="${1#*,}"
|
NFS_OPTIONS="${1#*,}"
|
||||||
@ -322,13 +202,13 @@
|
|||||||
[ "$NFS_OPTIONS" = "$1" ] && NFS_OPTIONS=
|
[ "$NFS_OPTIONS" = "$1" ] && NFS_OPTIONS=
|
||||||
|
|
||||||
mount_common "$NFS_EXPORT" "$2" "$3,nolock,soft,timeo=3,retrans=2,rsize=32768,wsize=32768,$NFS_OPTIONS" "nfs"
|
mount_common "$NFS_EXPORT" "$2" "$3,nolock,soft,timeo=3,retrans=2,rsize=32768,wsize=32768,$NFS_OPTIONS" "nfs"
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_ubifs() {
|
mount_ubifs() {
|
||||||
mount_common "$1" "$2" "$3" "ubifs"
|
mount_common "$1" "$2" "$3" "ubifs"
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_part() {
|
mount_part() {
|
||||||
# Mount a local or network filesystem
|
# Mount a local or network filesystem
|
||||||
# $1:[TYPE=]target, $2:mountpoint, $3:mount options, [$4:fs type]
|
# $1:[TYPE=]target, $2:mountpoint, $3:mount options, [$4:fs type]
|
||||||
progress "mount filesystem $1 ..."
|
progress "mount filesystem $1 ..."
|
||||||
@ -362,10 +242,10 @@
|
|||||||
MOUNT_TARGET="${MOUNT_TARGET//@UID@/$MACHINE_UID}"
|
MOUNT_TARGET="${MOUNT_TARGET//@UID@/$MACHINE_UID}"
|
||||||
|
|
||||||
$MOUNT_CMD "$MOUNT_TARGET" "$2" "$3" "$4"
|
$MOUNT_CMD "$MOUNT_TARGET" "$2" "$3" "$4"
|
||||||
}
|
}
|
||||||
|
|
||||||
# mount the specified SYSTEM file and output arch from /etc/os-release
|
# mount the specified SYSTEM file and output arch from /etc/os-release
|
||||||
get_project_arch() {
|
get_project_arch() {
|
||||||
mount_part "$1" "/sysroot" "ro,loop" || return
|
mount_part "$1" "/sysroot" "ro,loop" || return
|
||||||
|
|
||||||
if [ -f /sysroot/etc/os-release ]; then
|
if [ -f /sysroot/etc/os-release ]; then
|
||||||
@ -374,13 +254,13 @@
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
umount /sysroot
|
umount /sysroot
|
||||||
}
|
}
|
||||||
|
|
||||||
# If the project/arch of current matches the upgrade, then it is considered compatible.
|
# If the project/arch of current matches the upgrade, then it is considered compatible.
|
||||||
# Otherwise, mount the upgrade SYSTEM partition and, if canupdate.sh is available,
|
# Otherwise, mount the upgrade SYSTEM partition and, if canupdate.sh is available,
|
||||||
# call the script to determine if the current upgrade file can be applied on to the
|
# call the script to determine if the current upgrade file can be applied on to the
|
||||||
# current system - 0 means it is compatible, non-zero that it is not compatible.
|
# current system - 0 means it is compatible, non-zero that it is not compatible.
|
||||||
is_compatible() {
|
is_compatible() {
|
||||||
local result=1
|
local result=1
|
||||||
|
|
||||||
if [ "${2}" = "${3}" ]; then
|
if [ "${2}" = "${3}" ]; then
|
||||||
@ -396,10 +276,10 @@
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
return ${result}
|
return ${result}
|
||||||
}
|
}
|
||||||
|
|
||||||
# determine if the new SYSTEM file is compatible with the current SYSTEM file
|
# determine if the new SYSTEM file is compatible with the current SYSTEM file
|
||||||
check_is_compatible() {
|
check_is_compatible() {
|
||||||
local update_filename="${1}"
|
local update_filename="${1}"
|
||||||
local old_system="${2}"
|
local old_system="${2}"
|
||||||
local new_system="${3}"
|
local new_system="${3}"
|
||||||
@ -425,9 +305,9 @@
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
update_file() {
|
update_file() {
|
||||||
if [ -f "$UPDATE_DIR/$2" -a -f "$3" ]; then
|
if [ -f "$UPDATE_DIR/$2" -a -f "$3" ]; then
|
||||||
mount -o remount,rw /flash
|
mount -o remount,rw /flash
|
||||||
|
|
||||||
@ -445,9 +325,9 @@
|
|||||||
fi
|
fi
|
||||||
sync
|
sync
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
update_partition() {
|
update_partition() {
|
||||||
local result
|
local result
|
||||||
|
|
||||||
if [ -f "$UPDATE_DIR/$2" -a -b "$3" ]; then
|
if [ -f "$UPDATE_DIR/$2" -a -b "$3" ]; then
|
||||||
@ -456,9 +336,9 @@
|
|||||||
StopProgress "done"
|
StopProgress "done"
|
||||||
echo "${result}"
|
echo "${result}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
update_bootloader() {
|
update_bootloader() {
|
||||||
local result
|
local result
|
||||||
|
|
||||||
export BOOT_ROOT="/flash"
|
export BOOT_ROOT="/flash"
|
||||||
@ -475,20 +355,19 @@
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
umount /sysroot
|
umount /sysroot
|
||||||
}
|
}
|
||||||
|
|
||||||
load_modules() {
|
load_modules() {
|
||||||
progress "Loading kernel modules"
|
progress "Loading kernel modules"
|
||||||
|
|
||||||
[ ! -f "/etc/modules" ] && return
|
[ ! -f "/etc/modules" ] && return
|
||||||
for module in $(cat /etc/modules); do
|
for module in $(cat /etc/modules); do
|
||||||
progress "Loading kernel module $module"
|
progress "Loading kernel module $module"
|
||||||
insmod "$MODULE_DIR/$module.ko" || \
|
insmod "$MODULE_DIR/$module.ko" || progress "... Failed to load kernel module $module, skipping"
|
||||||
progress "... Failed to load kernel module $module, skipping"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
load_splash() {
|
load_splash() {
|
||||||
local set_default_res=no
|
local set_default_res=no
|
||||||
local vres
|
local vres
|
||||||
|
|
||||||
@ -498,9 +377,7 @@
|
|||||||
# load uvesafb module if needed
|
# load uvesafb module if needed
|
||||||
if [ -f "$MODULE_DIR/uvesafb.ko" -a ! -e /dev/fb0 ]; then
|
if [ -f "$MODULE_DIR/uvesafb.ko" -a ! -e /dev/fb0 ]; then
|
||||||
progress "Loading kernel module uvesafb.ko"
|
progress "Loading kernel module uvesafb.ko"
|
||||||
insmod "$MODULE_DIR/uvesafb.ko" && \
|
insmod "$MODULE_DIR/uvesafb.ko" && set_default_res=yes || progress "... Failed to load kernel module uvesafb, skipping"
|
||||||
set_default_res=yes || \
|
|
||||||
progress "... Failed to load kernel module uvesafb, skipping"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e /dev/fb0 ]; then
|
if [ -e /dev/fb0 ]; then
|
||||||
@ -557,9 +434,9 @@
|
|||||||
debug_msg "Framebuffer splash image: $SPLASHIMAGE"
|
debug_msg "Framebuffer splash image: $SPLASHIMAGE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
do_reboot() {
|
do_reboot() {
|
||||||
echo "System reboots now..."
|
echo "System reboots now..."
|
||||||
|
|
||||||
# syncing filesystem
|
# syncing filesystem
|
||||||
@ -576,9 +453,9 @@
|
|||||||
|
|
||||||
usleep 2000000
|
usleep 2000000
|
||||||
/usr/bin/busybox reboot
|
/usr/bin/busybox reboot
|
||||||
}
|
}
|
||||||
|
|
||||||
force_fsck() {
|
force_fsck() {
|
||||||
echo "Filesystem corruption has been detected!"
|
echo "Filesystem corruption has been detected!"
|
||||||
echo "To prevent an automatic repair attempt continuing,"
|
echo "To prevent an automatic repair attempt continuing,"
|
||||||
echo "press any key or power off your system within the next 120 seconds"
|
echo "press any key or power off your system within the next 120 seconds"
|
||||||
@ -586,12 +463,12 @@
|
|||||||
read -t120 -n1
|
read -t120 -n1
|
||||||
# The exit status is 0 if input is available
|
# The exit status is 0 if input is available
|
||||||
# The exit status is greater than 128 if the timeout is exceeded
|
# The exit status is greater than 128 if the timeout is exceeded
|
||||||
if [ "$?" -ne "0" -o "$?" -gt "128" ] ; then
|
if [ $? -ne 0 -o $? -gt 128 ]; then
|
||||||
echo "Repairing filesystem..."
|
echo "Repairing filesystem..."
|
||||||
echo ""
|
echo ""
|
||||||
/usr/sbin/fsck -T -M -y $RUN_FSCK_DISKS
|
/usr/sbin/fsck -T -M -y $RUN_FSCK_DISKS
|
||||||
FSCK_RET="$?"
|
FSCK_RET=$?
|
||||||
if [ "$(( $FSCK_RET & 8 ))" = 8 ] ; then
|
if [ $(( $FSCK_RET & 8 )) -eq 8 ]; then
|
||||||
# fubar
|
# fubar
|
||||||
echo "Forced fsck failed. Your system is broken beyond repair"
|
echo "Forced fsck failed. Your system is broken beyond repair"
|
||||||
echo "Please re-install @DISTRONAME@"
|
echo "Please re-install @DISTRONAME@"
|
||||||
@ -608,33 +485,33 @@
|
|||||||
sync
|
sync
|
||||||
poweroff
|
poweroff
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_disks() {
|
check_disks() {
|
||||||
if [ "$RUN_FSCK" = "yes" -a -n "$RUN_FSCK_DISKS" ]; then
|
if [ "$RUN_FSCK" = "yes" -a -n "$RUN_FSCK_DISKS" ]; then
|
||||||
progress "Checking disk(s): $RUN_FSCK_DISKS"
|
progress "Checking disk(s): $RUN_FSCK_DISKS"
|
||||||
/usr/sbin/fsck -T -M -p -a $RUN_FSCK_DISKS > /dev/null 2>&1
|
/usr/sbin/fsck -T -M -p -a $RUN_FSCK_DISKS > /dev/null 2>&1
|
||||||
FSCK_RET="$?"
|
FSCK_RET=$?
|
||||||
|
|
||||||
# FSCK_RET is the bit-wise OR of the exit codes for each filesystem that is checked.
|
# FSCK_RET is the bit-wise OR of the exit codes for each filesystem that is checked.
|
||||||
if [ "$(( $FSCK_RET & 4 ))" = 4 ] ; then
|
if [ $(( $FSCK_RET & 4 )) -eq 4 ]; then
|
||||||
# errors left
|
# errors left
|
||||||
force_fsck
|
force_fsck
|
||||||
elif [ "$(( $FSCK_RET & 2 ))" = 2 ] ; then
|
elif [ $(( $FSCK_RET & 2 )) -eq 2 ]; then
|
||||||
# reboot needed
|
# reboot needed
|
||||||
echo "Filesystem repaired, reboot needed..."
|
echo "Filesystem repaired, reboot needed..."
|
||||||
do_reboot
|
do_reboot
|
||||||
elif [ "$(( $FSCK_RET & 1 ))" = 1 ] ; then
|
elif [ $(( $FSCK_RET & 1 )) -eq 1 ]; then
|
||||||
# filesystem errors corrected
|
# filesystem errors corrected
|
||||||
progress "Filesystem errors corrected , continuing..."
|
progress "Filesystem errors corrected , continuing..."
|
||||||
elif [ "$(( $FSCK_RET & 0 ))" = 0 ] ; then
|
elif [ $(( $FSCK_RET & 0 )) -eq 0 ]; then
|
||||||
# no errors found
|
# no errors found
|
||||||
progress "No filesystem errors found, continuing..."
|
progress "No filesystem errors found, continuing..."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
wakeonlan() {
|
wakeonlan() {
|
||||||
if [ "$STORAGE_NETBOOT" = "yes" ]; then
|
if [ "$STORAGE_NETBOOT" = "yes" ]; then
|
||||||
wol_ip=${disk%:*}
|
wol_ip=${disk%:*}
|
||||||
wol_ip=${wol_ip#*=}
|
wol_ip=${wol_ip#*=}
|
||||||
@ -653,21 +530,21 @@
|
|||||||
StartProgress countdown "WOL magic packet sent to $wol_ip, waiting $wol_wait seconds... " $wol_wait "done"
|
StartProgress countdown "WOL magic packet sent to $wol_ip, waiting $wol_wait seconds... " $wol_wait "done"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_flash() {
|
mount_flash() {
|
||||||
progress "Mounting flash"
|
progress "Mounting flash"
|
||||||
|
|
||||||
wakeonlan
|
wakeonlan
|
||||||
|
|
||||||
mount_part "$boot" "/flash" "ro,noatime"
|
mount_part "$boot" "/flash" "ro,noatime"
|
||||||
|
|
||||||
if [ -f /flash/post-flash.sh ] ; then
|
if [ -f /flash/post-flash.sh ]; then
|
||||||
. /flash/post-flash.sh
|
. /flash/post-flash.sh
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_storage() {
|
mount_storage() {
|
||||||
progress "Mounting storage"
|
progress "Mounting storage"
|
||||||
|
|
||||||
if [ "$LIVE" = "yes" ]; then
|
if [ "$LIVE" = "yes" ]; then
|
||||||
@ -696,7 +573,7 @@
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /flash/mount-storage.sh ] ; then
|
if [ -f /flash/mount-storage.sh ]; then
|
||||||
. /flash/mount-storage.sh
|
. /flash/mount-storage.sh
|
||||||
else
|
else
|
||||||
mount_part "$disk" "/storage" "rw,noatime"
|
mount_part "$disk" "/storage" "rw,noatime"
|
||||||
@ -705,10 +582,10 @@
|
|||||||
# /storage should always be writable
|
# /storage should always be writable
|
||||||
mount -t tmpfs none /storage
|
mount -t tmpfs none /storage
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make last bootloader label (installer, live, run etc.) as the new default
|
# Make last bootloader label (installer, live, run etc.) as the new default
|
||||||
update_bootmenu() {
|
update_bootmenu() {
|
||||||
local crnt_default
|
local crnt_default
|
||||||
|
|
||||||
if [ -n "$SYSLINUX_DEFAULT" -a -f /flash/syslinux.cfg ]; then
|
if [ -n "$SYSLINUX_DEFAULT" -a -f /flash/syslinux.cfg ]; then
|
||||||
@ -738,9 +615,9 @@
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_out_of_space() {
|
check_out_of_space() {
|
||||||
if [ "$(df /storage | awk '/[0-9]%/{print $4}')" -eq "0" ]; then
|
if [ "$(df /storage | awk '/[0-9]%/{print $4}')" -eq "0" ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "The $1 is corrupt, or there is not enough"
|
echo "The $1 is corrupt, or there is not enough"
|
||||||
@ -756,9 +633,9 @@
|
|||||||
echo ""
|
echo ""
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
do_cleanup() {
|
do_cleanup() {
|
||||||
StartProgress spinner "Cleaning up... "
|
StartProgress spinner "Cleaning up... "
|
||||||
|
|
||||||
if [ -d $UPDATE_ROOT/.tmp/mnt ]; then
|
if [ -d $UPDATE_ROOT/.tmp/mnt ]; then
|
||||||
@ -781,9 +658,9 @@
|
|||||||
sync
|
sync
|
||||||
|
|
||||||
StopProgress "done"
|
StopProgress "done"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_update() {
|
check_update() {
|
||||||
progress "Checking for updates"
|
progress "Checking for updates"
|
||||||
UPDATE_TAR=$(ls -1 "$UPDATE_DIR"/*.tar 2>/dev/null | head -n 1)
|
UPDATE_TAR=$(ls -1 "$UPDATE_DIR"/*.tar 2>/dev/null | head -n 1)
|
||||||
UPDATE_IMG_GZ=$(ls -1 "$UPDATE_DIR"/*.img.gz 2>/dev/null | head -n 1)
|
UPDATE_IMG_GZ=$(ls -1 "$UPDATE_DIR"/*.img.gz 2>/dev/null | head -n 1)
|
||||||
@ -794,7 +671,7 @@
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$UPDATE_DISABLED" = "yes" ] ; then
|
if [ "$UPDATE_DISABLED" = "yes" ]; then
|
||||||
echo "Updating is not supported on netboot"
|
echo "Updating is not supported on netboot"
|
||||||
do_cleanup
|
do_cleanup
|
||||||
StartProgress countdown "Normal startup in 10s... " 10 "NOW"
|
StartProgress countdown "Normal startup in 10s... " 10 "NOW"
|
||||||
@ -817,7 +694,7 @@
|
|||||||
echo "Please do not reboot or turn off your @DISTRONAME@ device!"
|
echo "Please do not reboot or turn off your @DISTRONAME@ device!"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
if [ -f "$UPDATE_TAR" ] ; then
|
if [ -f "$UPDATE_TAR" ]; then
|
||||||
TARRESULT="0"
|
TARRESULT="0"
|
||||||
|
|
||||||
echo "Found new .tar archive"
|
echo "Found new .tar archive"
|
||||||
@ -841,7 +718,7 @@
|
|||||||
StartProgress countdown "Normal startup in 30s... " 30 "NOW"
|
StartProgress countdown "Normal startup in 30s... " 30 "NOW"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
elif [ -f "$UPDATE_IMG_GZ" -o -f "$UPDATE_IMG" ] ; then
|
elif [ -f "$UPDATE_IMG_GZ" -o -f "$UPDATE_IMG" ]; then
|
||||||
mkdir -p $UPDATE_DIR/.tmp/mnt &>/dev/null
|
mkdir -p $UPDATE_DIR/.tmp/mnt &>/dev/null
|
||||||
IMG_FILE="$UPDATE_DIR/.tmp/update.img"
|
IMG_FILE="$UPDATE_DIR/.tmp/update.img"
|
||||||
GZRESULT="0"
|
GZRESULT="0"
|
||||||
@ -916,7 +793,7 @@
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$UPDATE_DIR/$UPDATE_KERNEL" -o ! -f "$UPDATE_DIR/$UPDATE_SYSTEM" ] ; then
|
if [ ! -f "$UPDATE_DIR/$UPDATE_KERNEL" -o ! -f "$UPDATE_DIR/$UPDATE_SYSTEM" ]; then
|
||||||
echo "Missing (source) ${UPDATE_KERNEL} or ${UPDATE_SYSTEM}!"
|
echo "Missing (source) ${UPDATE_KERNEL} or ${UPDATE_SYSTEM}!"
|
||||||
do_cleanup
|
do_cleanup
|
||||||
StartProgress countdown "Normal startup in 30s... " 30 "NOW"
|
StartProgress countdown "Normal startup in 30s... " 30 "NOW"
|
||||||
@ -925,9 +802,9 @@
|
|||||||
|
|
||||||
# check md5 sums if .nocheck doesn't exist
|
# check md5 sums if .nocheck doesn't exist
|
||||||
if [ ! -f "$UPDATE_ROOT/.nocheck" ]; then
|
if [ ! -f "$UPDATE_ROOT/.nocheck" ]; then
|
||||||
if [ -f "$UPDATE_DIR/${UPDATE_KERNEL}.md5" -a -f "$UPDATE_DIR/${UPDATE_SYSTEM}.md5" ] ; then
|
if [ -f "$UPDATE_DIR/${UPDATE_KERNEL}.md5" -a -f "$UPDATE_DIR/${UPDATE_SYSTEM}.md5" ]; then
|
||||||
# *.md5 size-check
|
# *.md5 size-check
|
||||||
if [ ! -s "$UPDATE_DIR/${UPDATE_KERNEL}.md5" -o ! -s "$UPDATE_DIR/${UPDATE_SYSTEM}.md5" ] ; then
|
if [ ! -s "$UPDATE_DIR/${UPDATE_KERNEL}.md5" -o ! -s "$UPDATE_DIR/${UPDATE_SYSTEM}.md5" ]; then
|
||||||
echo "Zero-sized .md5 file!"
|
echo "Zero-sized .md5 file!"
|
||||||
MD5_FAILED="1"
|
MD5_FAILED="1"
|
||||||
else
|
else
|
||||||
@ -1021,9 +898,9 @@
|
|||||||
update_bootloader
|
update_bootloader
|
||||||
do_cleanup
|
do_cleanup
|
||||||
do_reboot
|
do_reboot
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_sysroot() {
|
prepare_sysroot() {
|
||||||
progress "Preparing system"
|
progress "Preparing system"
|
||||||
|
|
||||||
if [ "$SYSTEM_TORAM" = "no" -o "$INSTALLED_MEMORY" -lt "$SYSTEM_TORAM_LIMIT" ]; then
|
if [ "$SYSTEM_TORAM" = "no" -o "$INSTALLED_MEMORY" -lt "$SYSTEM_TORAM_LIMIT" ]; then
|
||||||
@ -1046,20 +923,139 @@
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
[ -f "/sysroot/usr/lib/systemd/systemd" ] || error "final_check" "Could not find systemd!"
|
[ -f "/sysroot/usr/lib/systemd/systemd" ] || error "final_check" "Could not find systemd!"
|
||||||
}
|
}
|
||||||
|
|
||||||
# If the network is up (due to the use of the "ip" kernel parameter) and a DNS
|
# Do init tasks to bring up system
|
||||||
# server is known, allow the libc resolver to use it
|
|
||||||
grep '^\(nameserver\|domain\) ' /proc/net/pnp | grep -v '^nameserver 0\.0\.0\.0$' > /etc/resolv.conf
|
|
||||||
|
|
||||||
if [ "${boot%%=*}" = "FILE" ]; then
|
# hide kernel log messages on console
|
||||||
|
echo '1 4 1 7' > /proc/sys/kernel/printk
|
||||||
|
|
||||||
|
# set ondemand up_threshold
|
||||||
|
if [ -e /sys/devices/system/cpu/cpufreq/ondemand/up_threshold ]; then
|
||||||
|
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
|
||||||
|
fi
|
||||||
|
|
||||||
|
# run platform_init script if exists
|
||||||
|
if [ -f "./platform_init" ]; then
|
||||||
|
./platform_init
|
||||||
|
fi
|
||||||
|
|
||||||
|
# clear screen and hide cursor
|
||||||
|
clear
|
||||||
|
hidecursor
|
||||||
|
|
||||||
|
# parse command line arguments
|
||||||
|
for arg in $(cat /proc/cmdline); do
|
||||||
|
case $arg in
|
||||||
|
BOOT_IMAGE=*)
|
||||||
|
IMAGE_KERNEL="${arg#*=}"
|
||||||
|
[ "${IMAGE_KERNEL:0:1}" = "/" ] && IMAGE_KERNEL="${IMAGE_KERNEL:1}"
|
||||||
|
;;
|
||||||
|
SYSTEM_IMAGE=*)
|
||||||
|
IMAGE_SYSTEM="${arg#*=}"
|
||||||
|
[ "${IMAGE_SYSTEM:0:1}" = "/" ] && IMAGE_SYSTEM="${IMAGE_SYSTEM:1}"
|
||||||
|
;;
|
||||||
|
boot=*)
|
||||||
|
boot="${arg#*=}"
|
||||||
|
case $boot in
|
||||||
|
ISCSI=*|NBD=*|NFS=*)
|
||||||
|
UPDATE_DISABLED=yes
|
||||||
|
FLASH_NETBOOT=yes
|
||||||
|
;;
|
||||||
|
/dev/*|LABEL=*|UUID=*)
|
||||||
|
RUN_FSCK_DISKS="$RUN_FSCK_DISKS $boot"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
disk=*)
|
||||||
|
disk="${arg#*=}"
|
||||||
|
case $disk in
|
||||||
|
ISCSI=*|NBD=*|NFS=*)
|
||||||
|
STORAGE_NETBOOT=yes
|
||||||
|
;;
|
||||||
|
/dev/*|LABEL=*|UUID=*)
|
||||||
|
RUN_FSCK_DISKS="$RUN_FSCK_DISKS $disk"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
wol_mac=*)
|
||||||
|
wol_mac="${arg#*=}"
|
||||||
|
;;
|
||||||
|
wol_wait=*)
|
||||||
|
wol_wait="${arg#*=}"
|
||||||
|
;;
|
||||||
|
textmode)
|
||||||
|
INIT_UNIT="--unit=textmode.target"
|
||||||
|
;;
|
||||||
|
installer)
|
||||||
|
INIT_UNIT="--unit=installer.target"
|
||||||
|
SYSLINUX_DEFAULT="installer"
|
||||||
|
;;
|
||||||
|
debugging)
|
||||||
|
DEBUG=yes
|
||||||
|
;;
|
||||||
|
progress)
|
||||||
|
PROGRESS=yes
|
||||||
|
INIT_ARGS="$INIT_ARGS --show-status=1"
|
||||||
|
;;
|
||||||
|
nofsck)
|
||||||
|
RUN_FSCK=no
|
||||||
|
;;
|
||||||
|
nosplash)
|
||||||
|
SPLASH=no
|
||||||
|
;;
|
||||||
|
noram)
|
||||||
|
SYSTEM_TORAM=no
|
||||||
|
;;
|
||||||
|
ramlimit=*)
|
||||||
|
SYSTEM_TORAM_LIMIT="${arg#*=}"
|
||||||
|
;;
|
||||||
|
live)
|
||||||
|
LIVE=yes
|
||||||
|
SYSLINUX_DEFAULT="live"
|
||||||
|
;;
|
||||||
|
portable)
|
||||||
|
SYSLINUX_DEFAULT="run"
|
||||||
|
;;
|
||||||
|
grub_live)
|
||||||
|
LIVE=yes
|
||||||
|
GRUB_DEFAULT="Live"
|
||||||
|
;;
|
||||||
|
grub_portable)
|
||||||
|
GRUB_DEFAULT="Run"
|
||||||
|
;;
|
||||||
|
overlay)
|
||||||
|
OVERLAY=yes
|
||||||
|
;;
|
||||||
|
setfbres=*)
|
||||||
|
SWITCH_FRAMEBUFFER="${arg#*=}"
|
||||||
|
SWITCH_FRAMEBUFFER="${SWITCH_FRAMEBUFFER//,/ }"
|
||||||
|
;;
|
||||||
|
break=*)
|
||||||
|
BREAK="${arg#*=}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if test "$DEBUG" = "yes"; then
|
||||||
|
exec 3>&1
|
||||||
|
else
|
||||||
|
exec 3>/dev/null
|
||||||
|
fi
|
||||||
|
SILENT_OUT=3
|
||||||
|
|
||||||
|
# If the network is up (due to the use of the "ip" kernel parameter) and a DNS
|
||||||
|
# server is known, allow the libc resolver to use it
|
||||||
|
grep '^\(nameserver\|domain\) ' /proc/net/pnp | grep -v '^nameserver 0\.0\.0\.0$' > /etc/resolv.conf
|
||||||
|
|
||||||
|
if [ "${boot%%=*}" = "FILE" ]; then
|
||||||
error "check arguments" "boot argument can't be FILE type..."
|
error "check arguments" "boot argument can't be FILE type..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
debug_msg "Unique identifier for this client: ${MACHINE_UID:-NOT AVAILABLE}"
|
debug_msg "Unique identifier for this client: ${MACHINE_UID:-NOT AVAILABLE}"
|
||||||
|
|
||||||
# main boot sequence
|
# main boot sequence
|
||||||
for BOOT_STEP in \
|
for BOOT_STEP in \
|
||||||
load_modules \
|
load_modules \
|
||||||
check_disks \
|
check_disks \
|
||||||
mount_flash \
|
mount_flash \
|
||||||
@ -1070,58 +1066,58 @@
|
|||||||
prepare_sysroot; do
|
prepare_sysroot; do
|
||||||
$BOOT_STEP
|
$BOOT_STEP
|
||||||
[ -n "$DEBUG" ] && break_after $BOOT_STEP
|
[ -n "$DEBUG" ] && break_after $BOOT_STEP
|
||||||
done
|
done
|
||||||
|
|
||||||
BOOT_STEP=final
|
BOOT_STEP=final
|
||||||
|
|
||||||
# log if booting from usb / removable storage
|
# log if booting from usb / removable storage
|
||||||
STORAGE=$(cat /proc/mounts | grep " /sysroot/storage " | awk '{print $1}' | awk -F '/' '{print $3}')
|
STORAGE=$(cat /proc/mounts | grep " /sysroot/storage " | awk '{print $1}' | awk -F '/' '{print $3}')
|
||||||
FLASH=$(cat /proc/mounts | grep " /sysroot/flash " | awk '{print $1}' | awk -F '/' '{print $3}')
|
FLASH=$(cat /proc/mounts | grep " /sysroot/flash " | awk '{print $1}' | awk -F '/' '{print $3}')
|
||||||
for i in $STORAGE $FLASH ; do
|
for i in $STORAGE $FLASH ; do
|
||||||
if [ -n "$i" ] ; then
|
if [ -n "$i" ]; then
|
||||||
removable="/sys/class/block/*/$i/../removable"
|
removable="/sys/class/block/*/$i/../removable"
|
||||||
if [ -e $removable ] ; then
|
if [ -e $removable ]; then
|
||||||
if [ "$(cat $removable 2>/dev/null)" = "1" ] ; then
|
if [ "$(cat $removable 2>/dev/null)" = "1" ]; then
|
||||||
echo "### BIG FAT WARNING" > /dev/kmsg
|
echo "### BIG FAT WARNING" > /dev/kmsg
|
||||||
echo "### $i is removable. suspend/resume may not work" > /dev/kmsg
|
echo "### $i is removable. suspend/resume may not work" > /dev/kmsg
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# move some special filesystems
|
# move some special filesystems
|
||||||
/usr/bin/busybox mount --move /dev /sysroot/dev
|
/usr/bin/busybox mount --move /dev /sysroot/dev
|
||||||
/usr/bin/busybox mount --move /proc /sysroot/proc
|
/usr/bin/busybox mount --move /proc /sysroot/proc
|
||||||
/usr/bin/busybox mount --move /sys /sysroot/sys
|
/usr/bin/busybox mount --move /sys /sysroot/sys
|
||||||
/usr/bin/busybox rm -fr /tmp
|
/usr/bin/busybox rm -fr /tmp
|
||||||
|
|
||||||
# tell OE settings addon to disable updates
|
# tell OE settings addon to disable updates
|
||||||
if [ "$UPDATE_DISABLED" = "yes" ] ; then
|
if [ "$UPDATE_DISABLED" = "yes" ]; then
|
||||||
echo "" > /sysroot/dev/.update_disabled
|
echo "" > /sysroot/dev/.update_disabled
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$FLASH_NETBOOT" = "yes" ] ; then
|
if [ "$FLASH_NETBOOT" = "yes" ]; then
|
||||||
echo "" > /sysroot/dev/.flash_netboot
|
echo "" > /sysroot/dev/.flash_netboot
|
||||||
fi
|
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
|
if [ "$STORAGE_NETBOOT" = "yes" ]; then
|
||||||
echo "" > /sysroot/dev/.storage_netboot
|
echo "" > /sysroot/dev/.storage_netboot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /sysroot/storage/.please_resize_me ] ; then
|
if [ -f /sysroot/storage/.please_resize_me ]; then
|
||||||
INIT_UNIT="--unit=fs-resize.target"
|
INIT_UNIT="--unit=fs-resize.target"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BACKUP_FILE=$(ls -1 /sysroot/storage/.restore/??????????????.tar 2>/dev/null | head -n 1)
|
BACKUP_FILE=$(ls -1 /sysroot/storage/.restore/??????????????.tar 2>/dev/null | head -n 1)
|
||||||
if [ -f "$BACKUP_FILE" ] ; then
|
if [ -f "$BACKUP_FILE" ]; then
|
||||||
INIT_UNIT="--unit=backup-restore.target"
|
INIT_UNIT="--unit=backup-restore.target"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /sysroot/storage/.cache/reset_oe -o -f /sysroot/storage/.cache/reset_xbmc ] ; then
|
if [ -f /sysroot/storage/.cache/reset_oe -o -f /sysroot/storage/.cache/reset_xbmc ]; then
|
||||||
INIT_UNIT="--unit=factory-reset.target"
|
INIT_UNIT="--unit=factory-reset.target"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# switch to new sysroot and start real init
|
# switch to new sysroot and start real init
|
||||||
exec /usr/bin/busybox switch_root /sysroot /usr/lib/systemd/systemd $INIT_ARGS $INIT_UNIT
|
exec /usr/bin/busybox switch_root /sysroot /usr/lib/systemd/systemd $INIT_ARGS $INIT_UNIT
|
||||||
|
|
||||||
error "switch_root" "Error in initramfs. Could not switch to new root"
|
error "switch_root" "Error in initramfs. Could not switch to new root"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user