mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 13:16:41 +00:00
busybox/init: remove leading indent
Signed-off-by: Ian Leonard <antonlacon@gmail.com>
This commit is contained in:
parent
e738c7bf75
commit
7ebd79ae67
@ -6,74 +6,74 @@
|
|||||||
# 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
|
# common functions
|
||||||
. /functions
|
. /functions
|
||||||
|
|
||||||
# set needed variables
|
# set needed variables
|
||||||
MODULE_DIR=/usr/lib/modules
|
MODULE_DIR=/usr/lib/modules
|
||||||
|
|
||||||
UPDATE_ROOT=/storage/.update
|
UPDATE_ROOT=/storage/.update
|
||||||
UPDATE_DIR="$UPDATE_ROOT"
|
UPDATE_DIR="$UPDATE_ROOT"
|
||||||
|
|
||||||
UPDATE_KERNEL="KERNEL"
|
UPDATE_KERNEL="KERNEL"
|
||||||
UPDATE_SYSTEM="SYSTEM"
|
UPDATE_SYSTEM="SYSTEM"
|
||||||
IMAGE_KERNEL="@KERNEL_NAME@"
|
IMAGE_KERNEL="@KERNEL_NAME@"
|
||||||
IMAGE_SYSTEM="SYSTEM"
|
IMAGE_SYSTEM="SYSTEM"
|
||||||
|
|
||||||
BOOT_STEP="start"
|
BOOT_STEP="start"
|
||||||
MD5_FAILED="0"
|
MD5_FAILED="0"
|
||||||
RUN_FSCK="yes"
|
RUN_FSCK="yes"
|
||||||
RUN_FSCK_DISKS=""
|
RUN_FSCK_DISKS=""
|
||||||
SYSLINUX_DEFAULT=""
|
SYSLINUX_DEFAULT=""
|
||||||
GRUB_DEFAULT=""
|
GRUB_DEFAULT=""
|
||||||
|
|
||||||
NBD_DEVS="0"
|
NBD_DEVS="0"
|
||||||
FLASH_FREE_MIN="5"
|
FLASH_FREE_MIN="5"
|
||||||
|
|
||||||
INSTALLED_MEMORY=$(cat /proc/meminfo | grep 'MemTotal:' | awk '{print $2}')
|
INSTALLED_MEMORY=$(cat /proc/meminfo | grep 'MemTotal:' | awk '{print $2}')
|
||||||
SYSTEM_TORAM_LIMIT=1024000
|
SYSTEM_TORAM_LIMIT=1024000
|
||||||
|
|
||||||
LIVE="no"
|
LIVE="no"
|
||||||
|
|
||||||
BREAK_TRIPPED="no"
|
BREAK_TRIPPED="no"
|
||||||
|
|
||||||
# Get a serial number if present (eg. RPi) otherwise use MAC address from eth0
|
# 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}')"
|
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 :)"
|
[ -z "$MACHINE_UID" ] && MACHINE_UID="$(cat /sys/class/net/eth0/address 2>/dev/null | tr -d :)"
|
||||||
|
|
||||||
# hide kernel log messages on console
|
# hide kernel log messages on console
|
||||||
echo '1 4 1 7' > /proc/sys/kernel/printk
|
echo '1 4 1 7' > /proc/sys/kernel/printk
|
||||||
|
|
||||||
# set ondemand up_threshold
|
# set ondemand up_threshold
|
||||||
if [ -e /sys/devices/system/cpu/cpufreq/ondemand/up_threshold ] ; then
|
if [ -e /sys/devices/system/cpu/cpufreq/ondemand/up_threshold ] ; then
|
||||||
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
|
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# run platform_init script if exists
|
# run platform_init script if exists
|
||||||
if [ -f "./platform_init" ]; then
|
if [ -f "./platform_init" ]; then
|
||||||
./platform_init
|
./platform_init
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# clear screen and hide cursor
|
# clear screen and hide cursor
|
||||||
clear
|
clear
|
||||||
hidecursor
|
hidecursor
|
||||||
|
|
||||||
# parse command line arguments
|
# parse command line arguments
|
||||||
for arg in $(cat /proc/cmdline); do
|
for arg in $(cat /proc/cmdline); do
|
||||||
case $arg in
|
case $arg in
|
||||||
BOOT_IMAGE=*)
|
BOOT_IMAGE=*)
|
||||||
IMAGE_KERNEL="${arg#*=}"
|
IMAGE_KERNEL="${arg#*=}"
|
||||||
@ -163,34 +163,34 @@
|
|||||||
BREAK="${arg#*=}"
|
BREAK="${arg#*=}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if test "$DEBUG" = "yes"; then
|
if test "$DEBUG" = "yes"; then
|
||||||
exec 3>&1
|
exec 3>&1
|
||||||
else
|
else
|
||||||
exec 3>/dev/null
|
exec 3>/dev/null
|
||||||
fi
|
fi
|
||||||
SILENT_OUT=3
|
SILENT_OUT=3
|
||||||
|
|
||||||
progress() {
|
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 +198,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 +212,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 +232,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 +274,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%,*}"
|
||||||
@ -298,10 +298,10 @@
|
|||||||
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"
|
||||||
@ -312,9 +312,9 @@
|
|||||||
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 +322,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 +362,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 +374,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 +396,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 +425,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 +445,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 +456,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,9 +475,9 @@
|
|||||||
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
|
||||||
@ -486,9 +486,9 @@
|
|||||||
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
|
||||||
|
|
||||||
@ -557,9 +557,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 +576,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"
|
||||||
@ -608,9 +608,9 @@
|
|||||||
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
|
||||||
@ -632,9 +632,9 @@
|
|||||||
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,9 +653,9 @@
|
|||||||
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
|
||||||
@ -665,9 +665,9 @@
|
|||||||
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
|
||||||
@ -705,10 +705,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 +738,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 +756,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 +781,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)
|
||||||
@ -1021,9 +1021,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 +1046,20 @@
|
|||||||
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
|
# 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
|
# 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
|
grep '^\(nameserver\|domain\) ' /proc/net/pnp | grep -v '^nameserver 0\.0\.0\.0$' > /etc/resolv.conf
|
||||||
|
|
||||||
if [ "${boot%%=*}" = "FILE" ]; then
|
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,14 +1070,14 @@
|
|||||||
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
|
||||||
@ -1087,41 +1087,41 @@
|
|||||||
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