mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-06-15 16:15:29 +08:00
base-files: stage2: add 'tail' to sysupgrade environment
This commit is contained in:
parent
1175c829e6
commit
864e344469
@ -58,7 +58,7 @@ emmc_copy_config() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
emmc_do_upgrade() {
|
emmc_do_upgrade() {
|
||||||
local file_type=$(identify $1)
|
local file_type=$(identify_magic_long "$(get_magic_long "$1")")
|
||||||
|
|
||||||
case "$file_type" in
|
case "$file_type" in
|
||||||
"fit") emmc_upgrade_fit $1;;
|
"fit") emmc_upgrade_fit $1;;
|
||||||
|
@ -111,7 +111,7 @@ nand_remove_ubiblock() {
|
|||||||
|
|
||||||
local ubiblk="ubiblock${ubivol:3}"
|
local ubiblk="ubiblock${ubivol:3}"
|
||||||
if [ -e "/dev/$ubiblk" ]; then
|
if [ -e "/dev/$ubiblk" ]; then
|
||||||
umount "/dev/$ubiblk" 2>/dev/null && echo "unmounted /dev/$ubiblk" || :
|
umount "/dev/$ubiblk" && echo "unmounted /dev/$ubiblk" || :
|
||||||
if ! ubiblock -r "/dev/$ubivol"; then
|
if ! ubiblock -r "/dev/$ubivol"; then
|
||||||
echo "cannot remove $ubiblk"
|
echo "cannot remove $ubiblk"
|
||||||
return 1
|
return 1
|
||||||
|
@ -39,9 +39,9 @@ switch_to_ramfs() {
|
|||||||
for binary in \
|
for binary in \
|
||||||
/bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \
|
/bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \
|
||||||
pivot_root mount_root reboot sync kill sleep \
|
pivot_root mount_root reboot sync kill sleep \
|
||||||
md5sum hexdump cat zcat bzcat dd tar \
|
md5sum hexdump cat zcat dd tar gzip \
|
||||||
ls basename find cp mv rm mkdir rmdir mknod touch chmod \
|
ls basename find cp mv rm mkdir rmdir mknod touch chmod \
|
||||||
'[' printf wc grep awk sed cut \
|
'[' printf wc grep awk sed cut sort tail \
|
||||||
mtd partx losetup mkfs.ext4 nandwrite flash_erase \
|
mtd partx losetup mkfs.ext4 nandwrite flash_erase \
|
||||||
ubiupdatevol ubiattach ubiblock ubiformat \
|
ubiupdatevol ubiattach ubiblock ubiformat \
|
||||||
ubidetach ubirsvol ubirmvol ubimkvol \
|
ubidetach ubirsvol ubirmvol ubimkvol \
|
||||||
@ -53,7 +53,12 @@ switch_to_ramfs() {
|
|||||||
local file="$(command -v "$binary" 2>/dev/null)"
|
local file="$(command -v "$binary" 2>/dev/null)"
|
||||||
[ -n "$file" ] && install_bin "$file"
|
[ -n "$file" ] && install_bin "$file"
|
||||||
done
|
done
|
||||||
install_file /etc/resolv.conf /lib/*.sh /lib/functions/*.sh /lib/upgrade/*.sh /lib/upgrade/do_stage2 /usr/share/libubox/jshn.sh $RAMFS_COPY_DATA
|
install_file /etc/resolv.conf /lib/*.sh /lib/functions/*.sh \
|
||||||
|
/lib/upgrade/*.sh /lib/upgrade/do_stage2 \
|
||||||
|
/usr/share/libubox/jshn.sh /usr/sbin/fw_setenv \
|
||||||
|
/etc/fw_env.config $RAMFS_COPY_DATA
|
||||||
|
|
||||||
|
mkdir -p $RAM_ROOT/var/lock
|
||||||
|
|
||||||
[ -L "/lib64" ] && ln -s /lib $RAM_ROOT/lib64
|
[ -L "/lib64" ] && ln -s /lib $RAM_ROOT/lib64
|
||||||
|
|
||||||
@ -65,6 +70,10 @@ switch_to_ramfs() {
|
|||||||
/bin/mount -o remount,ro /mnt
|
/bin/mount -o remount,ro /mnt
|
||||||
/bin/umount -l /mnt
|
/bin/umount -l /mnt
|
||||||
|
|
||||||
|
grep -e "^/dev/dm-.*" -e "^/dev/loop.*" /proc/mounts | while read bdev mp _r; do
|
||||||
|
umount $mp
|
||||||
|
done
|
||||||
|
|
||||||
[ "$RAMFS_COPY_LOSETUP" ] && losetup -D
|
[ "$RAMFS_COPY_LOSETUP" ] && losetup -D
|
||||||
[ "$RAMFS_COPY_LVM" ] && {
|
[ "$RAMFS_COPY_LVM" ] && {
|
||||||
mkdir -p /tmp/lvm/cache
|
mkdir -p /tmp/lvm/cache
|
||||||
@ -94,12 +103,15 @@ kill_remaining() { # [ <signal> [ <loop> ] ]
|
|||||||
[ -f "$stat" ] || continue
|
[ -f "$stat" ] || continue
|
||||||
|
|
||||||
local pid name state ppid rest
|
local pid name state ppid rest
|
||||||
read pid name state ppid rest < $stat
|
read pid rest < $stat
|
||||||
name="${name#(}"; name="${name%)}"
|
name="${rest#\(}" ; rest="${name##*\) }" ; name="${name%\)*}"
|
||||||
|
set -- $rest ; state="$1" ; ppid="$2"
|
||||||
|
|
||||||
# Skip PID1, our parent, ourself and our children
|
# Skip PID1, our parent, ourself and our children
|
||||||
[ $pid -ne 1 -a $pid -ne $proc_ppid -a $pid -ne $$ -a $ppid -ne $$ ] || continue
|
[ $pid -ne 1 -a $pid -ne $proc_ppid -a $pid -ne $$ -a $ppid -ne $$ ] || continue
|
||||||
|
|
||||||
|
[ -f "/proc/$pid/cmdline" ] || continue
|
||||||
|
|
||||||
local cmdline
|
local cmdline
|
||||||
read cmdline < /proc/$pid/cmdline
|
read cmdline < /proc/$pid/cmdline
|
||||||
|
|
||||||
@ -109,7 +121,7 @@ kill_remaining() { # [ <signal> [ <loop> ] ]
|
|||||||
v "Sending signal $sig to $name ($pid)"
|
v "Sending signal $sig to $name ($pid)"
|
||||||
kill -$sig $pid 2>/dev/null
|
kill -$sig $pid 2>/dev/null
|
||||||
|
|
||||||
[ $loop -eq 1 ] && run=true
|
[ $loop -eq 1 ] && sleep 2 && run=true
|
||||||
done
|
done
|
||||||
|
|
||||||
let loop_limit--
|
let loop_limit--
|
||||||
@ -122,15 +134,31 @@ kill_remaining() { # [ <signal> [ <loop> ] ]
|
|||||||
|
|
||||||
indicate_upgrade
|
indicate_upgrade
|
||||||
|
|
||||||
killall -9 telnetd
|
while read -r a b c; do
|
||||||
killall -9 dropbear
|
case "$a" in
|
||||||
killall -9 ash
|
MemT*) mem="$b" ;; esac
|
||||||
|
done < /proc/meminfo
|
||||||
|
|
||||||
|
[ "$mem" -gt 32768 ] && \
|
||||||
|
skip_services="dnsmasq log network"
|
||||||
|
for service in /etc/init.d/*; do
|
||||||
|
service=${service##*/}
|
||||||
|
|
||||||
|
case " $skip_services " in
|
||||||
|
*" $service "*) continue ;; esac
|
||||||
|
|
||||||
|
ubus call service delete '{ "name": "'"$service"'" }' 2>/dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
killall -9 telnetd 2>/dev/null
|
||||||
|
killall -9 dropbear 2>/dev/null
|
||||||
|
killall -9 ash 2>/dev/null
|
||||||
|
|
||||||
kill_remaining TERM
|
kill_remaining TERM
|
||||||
sleep 3
|
sleep 4
|
||||||
kill_remaining KILL 1
|
kill_remaining KILL 1
|
||||||
|
|
||||||
sleep 1
|
sleep 6
|
||||||
|
|
||||||
echo 3 > /proc/sys/vm/drop_caches
|
echo 3 > /proc/sys/vm/drop_caches
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user