1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter.git synced 2025-03-09 15:40:20 +00:00

Update RUTX config/tools for 6.1 kernel

This commit is contained in:
Ycarus (Yannick Chabanois) 2023-10-03 11:26:29 +02:00
parent 0fd066f6ce
commit facff1658d
7 changed files with 8 additions and 748 deletions

View file

@ -53,6 +53,8 @@ ensure_correct_art
case "$FIRMWARE" in
"ath10k/pre-cal-ahb-a000000.wifi.bin")
case "$board" in
teltonika,rutx50|\
teltonika,rutx12|\
teltonika,rutx)
ath10kcal_extract "0:ART" 4096 12064
;;
@ -60,6 +62,8 @@ case "$FIRMWARE" in
;;
"ath10k/pre-cal-ahb-a800000.wifi.bin")
case "$board" in
teltonika,rutx50|\
teltonika,rutx12|\
teltonika,rutx)
ath10kcal_extract "0:ART" 20480 12064
;;

View file

@ -12,6 +12,8 @@ PHYNBR=${DEVPATH##*/phy}
board=$(board_name)
case "$board" in
teltonika,rutx12|\
teltonika,rutx50|\
teltonika,rutx)
mac_addr=$(mtd_get_mac_binary 0:CONFIG 0)
if [ "$mac_addr" != "ff:ff:ff:ff:ff:ff" ]; then

View file

@ -13,7 +13,7 @@ PIDCOUNT=1
start_service() {
. /lib/functions
[ "$(board_name)" != "teltonika,rutx" ] && return 0
[ "$(board_name)" != "teltonika,rutx" ] && [ "$(board_name)" != "teltonika,rutx50" ] && [ "$(board_name)" != "teltonika,rutx12" ] && return 0
local pid_file="/var/run/${NAME}.${PIDCOUNT}.pid"
procd_open_instance

View file

@ -25,7 +25,7 @@ start() {
local board=$(board_name)
case "$board" in
teltonika,rutx | ap-dk01.1-c1 | ap-dk01.1-c2 | ap-dk04.1-c1 | ap-dk04.1-c2 | ap-dk04.1-c3 | \
teltonika,rutx | teltonika,rutx50 | teltonika,rutx12 | ap-dk01.1-c1 | ap-dk01.1-c2 | ap-dk04.1-c1 | ap-dk04.1-c2 | ap-dk04.1-c3 | \
ap-dk04.1-c4 | ap-dk04.1-c5 | ap-dk05.1-c1 | ap-dk06.1-c1 | ap-dk07.1-c1 | ap-dk07.1-c2 | ap-dk07.1-c3)
ipq40xx_power_auto ;;
esac

View file

@ -1,383 +0,0 @@
find_mmc_part() {
local DEVNAME PARTNAME
if grep -q "$1" /proc/mtd; then
echo "" && return 0
fi
for DEVNAME in /sys/block/mmcblk0/mmcblk*p*; do
PARTNAME=$(grep PARTNAME ${DEVNAME}/uevent | cut -f2 -d'=')
[ "$PARTNAME" = "$1" ] && echo "/dev/$(basename $DEVNAME)" && return 0
done
}
get_full_section_name() {
local img=$1
local sec=$2
dumpimage -l ${img} | grep "^ Image.*(${sec})" | \
sed 's,^ Image.*(\(.*\)),\1,'
}
image_contains() {
local img=$1
local sec=$2
dumpimage -l ${img} | grep -q "^ Image.*(${sec}.*)" || return 1
}
print_sections() {
local img=$1
dumpimage -l ${img} | awk '/^ Image.*(.*)/ { print gensub(/Image .* \((.*)\)/,"\\1", $0) }'
}
image_has_mandatory_section() {
local img=$1
local mandatory_sections=$2
for sec in ${mandatory_sections}; do
image_contains $img ${sec} || {\
return 1
}
done
}
image_demux() {
local img=$1
for sec in $(print_sections ${img}); do
local fullname=$(get_full_section_name ${img} ${sec})
local position=$(dumpimage -l ${img} | grep "(${fullname})" | awk '{print $2}')
dumpimage -i ${img} -o /tmp/${fullname}.bin -T "flat_dt" -p "${position}" ${fullname} > /dev/null || { \
echo "Error while extracting \"${sec}\" from ${img}"
return 1
}
done
return 0
}
image_is_FIT() {
if ! dumpimage -l $1 > /dev/null 2>&1; then
echo "$1 is not a valid FIT image"
return 1
fi
return 0
}
switch_layout() {
local layout=$1
local boot_layout=`find / -name boot_layout`
# Layout switching is only required as the boot images (up to u-boot)
# use 512 user data bytes per code word, whereas Linux uses 516 bytes.
# It's only applicable for NAND flash. So let's return if we don't have
# one.
[ -n "$boot_layout" ] || return
case "${layout}" in
boot|1) echo 1 > $boot_layout;;
linux|0) echo 0 > $boot_layout;;
*) echo "Unknown layout \"${layout}\"";;
esac
}
do_flash_mtd() {
local bin=$1
local mtdname=$2
local append=""
local mtdpart=$(grep "\"${mtdname}\"" /proc/mtd | awk -F: '{print $1}')
local pgsz=$(cat /sys/class/mtd/${mtdpart}/writesize)
[ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 -a "$2" == "rootfs" ] && append="-j $CONF_TAR"
dd if=/tmp/${bin}.bin bs=${pgsz} conv=sync | mtd $append -e "/dev/${mtdpart}" write - "/dev/${mtdpart}"
}
do_flash_emmc() {
local bin=$1
local emmcblock=$2
dd if=/dev/zero of=${emmcblock}
dd if=/tmp/${bin}.bin of=${emmcblock}
}
do_flash_partition() {
local bin=$1
local mtdname=$2
local emmcblock="$(find_mmc_part "$mtdname")"
if [ -e "$emmcblock" ]; then
do_flash_emmc $bin $emmcblock
else
do_flash_mtd $bin $mtdname
fi
}
do_flash_bootconfig() {
local bin=$1
local mtdname=$2
# Fail safe upgrade
if [ -f /proc/boot_info/getbinary_${bin} ]; then
cat /proc/boot_info/getbinary_${bin} > /tmp/${bin}.bin
do_flash_partition $bin $mtdname
fi
}
do_flash_failsafe_partition() {
local bin=$1
local mtdname=$2
local emmcblock
local primaryboot
# Fail safe upgrade
[ -f /proc/boot_info/$mtdname/upgradepartition ] && {
default_mtd=$mtdname
mtdname=$(cat /proc/boot_info/$mtdname/upgradepartition)
primaryboot=$(cat /proc/boot_info/$default_mtd/primaryboot)
if [ $primaryboot -eq 0 ]; then
echo 1 > /proc/boot_info/$default_mtd/primaryboot
else
echo 0 > /proc/boot_info/$default_mtd/primaryboot
fi
}
emmcblock="$(find_mmc_part "$mtdname")"
if [ -e "$emmcblock" ]; then
do_flash_emmc $bin $emmcblock
else
do_flash_mtd $bin $mtdname
fi
}
do_flash_ubi() {
local bin=$1
local mtdname=$2
local mtdpart
local primaryboot
mtdpart=$(grep "\"${mtdname}\"" /proc/mtd | awk -F: '{print $1}')
ubidetach -p /dev/${mtdpart}
# Fail safe upgrade
[ -f /proc/boot_info/$mtdname/upgradepartition ] && {
primaryboot=$(cat /proc/boot_info/$mtdname/primaryboot)
if [ $primaryboot -eq 0 ]; then
echo 1 > /proc/boot_info/$mtdname/primaryboot
else
echo 0 > /proc/boot_info/$mtdname/primaryboot
fi
mtdname=$(cat /proc/boot_info/$mtdname/upgradepartition)
}
mtdpart=$(grep "\"${mtdname}\"" /proc/mtd | awk -F: '{print $1}')
ubiformat /dev/${mtdpart} -y -f /tmp/${bin}.bin
}
do_flash_tz() {
local sec=$1
local mtdpart=$(grep "\"0:QSEE\"" /proc/mtd | awk -F: '{print $1}')
local emmcblock="$(find_mmc_part "0:QSEE")"
if [ -n "$mtdpart" -o -e "$emmcblock" ]; then
do_flash_failsafe_partition ${sec} "0:QSEE"
else
do_flash_failsafe_partition ${sec} "0:TZ"
fi
}
do_flash_ddr() {
local sec=$1
local mtdpart=$(grep "\"0:CDT\"" /proc/mtd | awk -F: '{print $1}')
local emmcblock="$(find_mmc_part "0:CDT")"
if [ -n "$mtdpart" -o -e "$emmcblock" ]; then
do_flash_failsafe_partition ${sec} "0:CDT"
else
do_flash_failsafe_partition ${sec} "0:DDRPARAMS"
fi
}
to_upper () {
echo $1 | awk '{print toupper($0)}'
}
flash_section() {
local sec=$1
local board=$(board_name)
case "${sec}" in
hlos*) switch_layout linux; do_flash_failsafe_partition ${sec} "0:HLOS";;
rootfs*) switch_layout linux; do_flash_failsafe_partition ${sec} "rootfs";;
fs*) switch_layout linux; do_flash_failsafe_partition ${sec} "rootfs";;
ubi*) switch_layout linux; do_flash_ubi ${sec} "rootfs";;
#sbl1*) switch_layout boot; do_flash_partition ${sec} "0:SBL1";;
#sbl2*) switch_layout boot; do_flash_failsafe_partition ${sec} "0:SBL2";;
#sbl3*) switch_layout boot; do_flash_failsafe_partition ${sec} "0:SBL3";;
#mibib*) switch_layout boot; do_flash_partition ${sec} "0:MIBIB";;
#dtb-$(to_upper $board)*) switch_layout boot; do_flash_partition ${sec} "0:DTB";;
u-boot*) switch_layout boot; do_flash_failsafe_partition ${sec} "0:APPSBL";;
#ddr-$(to_upper $board)*) switch_layout boot; do_flash_ddr ${sec};;
ddr-${board}-*) switch_layout boot; do_flash_failsafe_partition ${sec} "0:CDT";;
#ssd*) switch_layout boot; do_flash_partition ${sec} "0:SSD";;
tz*) switch_layout boot; do_flash_tz ${sec};;
#rpm*) switch_layout boot; do_flash_failsafe_partition ${sec} "0:RPM";;
*) echo "Section ${sec} ignored"; return 1;;
esac
echo "Flashed ${sec}"
}
erase_emmc_config() {
local emmcblock="$(find_mmc_part "rootfs_data")"
if [ -e "$emmcblock" ]; then
dd if=/dev/zero of=${emmcblock}
mkfs.ext4 "$emmcblock"
fi
}
platform_pre_upgrade() {
cp /sbin/upgraded /tmp
ubus call system nandupgrade "{\"path\": \"$1\" }"
}
platform_check_image_ipq() {
local board=$(board_name)
local mandatory_nand="ubi"
local mandatory_nor_emmc="hlos fs"
local mandatory_nor="hlos"
local mandatory_section_found=0
local optional="sbl2 u-boot ddr-${board} ssd tz rpm"
local ignored="mibib bootconfig sbl1"
image_is_FIT $1 || return 1
image_has_mandatory_section $1 ${mandatory_nand} && {\
mandatory_section_found=1
}
image_has_mandatory_section $1 ${mandatory_nor_emmc} && {\
mandatory_section_found=1
}
image_has_mandatory_section $1 ${mandatory_nor} && {\
mandatory_section_found=1
}
if [ $mandatory_section_found -eq 0 ]; then
echo "Error: mandatory section(s) missing from \"$1\". Abort..."
return 1
fi
for sec in ${optional}; do
image_contains $1 ${sec} || {\
echo "Warning: optional section \"${sec}\" missing from \"$1\". Continue..."
}
done
for sec in ${ignored}; do
image_contains $1 ${sec} && {\
echo "Warning: section \"${sec}\" will be ignored from \"$1\". Continue..."
}
done
image_demux $1 || {\
echo "Error: \"$1\" couldn't be extracted. Abort..."
return 1
}
[ -f /tmp/hlos_version ] && rm -f /tmp/*_version
dumpimage -c $1 2>/dev/null
return $?
}
platform_version_upgrade() {
local version_files="appsbl_version sbl_version tz_version hlos_version rpm_version"
local sys="/sys/devices/system/qfprom/qfprom0/"
local tmp="/tmp/"
for file in $version_files; do
[ -f "${tmp}${file}" ] && {
echo "Updating "${sys}${file}" with `cat "${tmp}${file}"`"
echo `cat "${tmp}${file}"` > "${sys}${file}"
rm -f "${tmp}${file}"
}
done
}
# The U-Boot loader of the OpenMesh devices requires image sizes and
# checksums to be provided in the U-Boot environment.
# The OpenMesh devices come with 2 main partitions - while one is active
# sysupgrade will flash the other. The boot order is changed to boot the
# newly flashed partition. If the new partition can't be booted due to
# upgrade failures the previously used partition is loaded.
platform_do_upgrade_ipq() {
local board=$(board_name)
# verify some things exist before erasing
if [ ! -e $1 ]; then
echo "Error: Can't find $1 after switching to ramfs, aborting upgrade!"
reboot
fi
for sec in $(print_sections $1); do
if [ ! -e /tmp/${sec}.bin ]; then
echo "Error: Cant' find ${sec} after switching to ramfs, aborting upgrade!"
reboot
fi
done
case "$board" in
teltonika,rutx)
for sec in $(print_sections $1); do
flash_section ${sec}
done
switch_layout linux
# update bootconfig to register that fw upgrade has been done
do_flash_bootconfig bootconfig "0:BOOTCONFIG"
do_flash_bootconfig bootconfig1 "0:BOOTCONFIG1"
platform_version_upgrade
erase_emmc_config
return 0;
;;
esac
echo "Upgrade failed!"
return 1;
}
platform_copy_config_ipq() {
local emmcblock="$(find_mmc_part "rootfs_data")"
mkdir -p /tmp/overlay
if [ -e "$emmcblock" ]; then
mount -t ext4 "$emmcblock" /tmp/overlay
cp /tmp/sysupgrade.tgz /tmp/overlay/
sync
umount /tmp/overlay
else
local mtdname=rootfs
local mtdpart
[ -f /proc/boot_info/$mtdname/upgradepartition ] && {
mtdname=$(cat /proc/boot_info/$mtdname/upgradepartition)
}
mtdpart=$(grep "\"${mtdname}\"" /proc/mtd | awk -F: '{print $1}')
ubiattach -p /dev/${mtdpart}
mount -t ubifs ubi0:rootfs_data /tmp/overlay
cp /tmp/sysupgrade.tgz /tmp/overlay/
sync
umount /tmp/overlay
fi
}

View file

@ -1,216 +0,0 @@
PART_NAME=firmware
REQUIRE_IMAGE_METADATA=1
RAMFS_COPY_BIN='fw_printenv fw_setenv'
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
platform_check_image() {
case "$(board_name)" in
asus,rt-ac42u |\
asus,rt-ac58u)
local ubidev=$(nand_find_ubi $CI_UBIPART)
local asus_root=$(nand_find_volume $ubidev jffs2)
[ -n "$asus_root" ] || return 0
cat << EOF
jffs2 partition is still present.
There's probably no space left
to install the filesystem.
You need to delete the jffs2 partition first:
# ubirmvol /dev/ubi0 --name=jffs2
Once this is done. Retry.
EOF
return 1
;;
teltonika,rutx)
platform_check_image_ipq "$1"
;;
zte,mf286d)
CI_UBIPART="rootfs"
local mtdnum="$( find_mtd_index $CI_UBIPART )"
[ ! "$mtdnum" ] && return 1
ubiattach -m "$mtdnum" || true
local ubidev="$( nand_find_ubi $CI_UBIPART )"
local ubi_rootfs=$(nand_find_volume $ubidev ubi_rootfs)
local ubi_rootfs_data=$(nand_find_volume $ubidev ubi_rootfs_data)
[ -n "$ubi_rootfs" ] || [ -n "$ubi_rootfs_data" ] || return 0
cat << EOF
ubi_rootfs partition is still present.
You need to delete the stock partition first:
# ubirmvol /dev/ubi0 -N ubi_rootfs
Please also delete ubi_rootfs_data, if exist:
# ubirmvol /dev/ubi0 -N ubi_rootfs_data
Once this is done. Retry.
EOF
return 1
;;
esac
return 0;
}
askey_do_upgrade() {
local tar_file="$1"
local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
board_dir=${board_dir%/}
tar Oxf $tar_file ${board_dir}/root | mtd write - rootfs
nand_do_upgrade "$1"
}
zyxel_do_upgrade() {
local tar_file="$1"
local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
board_dir=${board_dir%/}
tar Oxf $tar_file ${board_dir}/kernel | mtd write - kernel
if [ -n "$UPGRADE_BACKUP" ]; then
tar Oxf $tar_file ${board_dir}/root | mtd -j "$UPGRADE_BACKUP" write - rootfs
else
tar Oxf $tar_file ${board_dir}/root | mtd write - rootfs
fi
}
platform_do_upgrade_mikrotik_nand() {
local fw_mtd=$(find_mtd_part kernel)
fw_mtd="${fw_mtd/block/}"
[ -n "$fw_mtd" ] || return
local board_dir=$(tar tf "$1" | grep -m 1 '^sysupgrade-.*/$')
board_dir=${board_dir%/}
[ -n "$board_dir" ] || return
local kernel_len=$(tar xf "$1" ${board_dir}/kernel -O | wc -c)
[ -n "$kernel_len" ] || return
tar xf "$1" ${board_dir}/kernel -O | ubiformat "$fw_mtd" -y -S $kernel_len -f -
CI_KERNPART="none"
nand_do_upgrade "$1"
}
platform_do_upgrade() {
case "$(board_name)" in
8dev,jalapeno |\
aruba,ap-303 |\
aruba,ap-303h |\
aruba,ap-365 |\
avm,fritzbox-7530 |\
avm,fritzrepeater-1200 |\
avm,fritzrepeater-3000 |\
buffalo,wtr-m2133hp |\
cilab,meshpoint-one |\
edgecore,ecw5211 |\
edgecore,oap100 |\
engenius,eap2200 |\
glinet,gl-ap1300 |\
luma,wrtq-329acn |\
mobipromo,cm520-79f |\
netgear,wac510 |\
p2w,r619ac-64m |\
p2w,r619ac-128m |\
qxwlan,e2600ac-c2)
nand_do_upgrade "$1"
;;
glinet,gl-b2200)
CI_KERNPART="0:HLOS"
CI_ROOTPART="rootfs"
CI_DATAPART="rootfs_data"
emmc_do_upgrade "$1"
;;
alfa-network,ap120c-ac)
part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
if [ "$part" = "rootfs1" ]; then
fw_setenv active 2 || exit 1
CI_UBIPART="rootfs2"
else
fw_setenv active 1 || exit 1
CI_UBIPART="rootfs1"
fi
nand_do_upgrade "$1"
;;
asus,map-ac2200)
CI_KERNPART="linux"
nand_do_upgrade "$1"
;;
asus,rt-ac42u |\
asus,rt-ac58u)
CI_KERNPART="linux"
nand_do_upgrade "$1"
;;
cellc,rtl30vw)
CI_UBIPART="ubifs"
askey_do_upgrade "$1"
;;
compex,wpj419)
nand_do_upgrade "$1"
;;
linksys,ea6350v3 |\
linksys,ea8300 |\
linksys,mr8300)
platform_do_upgrade_linksys "$1"
;;
meraki,mr33)
CI_KERNPART="part.safe"
nand_do_upgrade "$1"
;;
mikrotik,cap-ac|\
mikrotik,hap-ac2|\
mikrotik,lhgg-60ad|\
mikrotik,sxtsq-5-ac)
[ "$(rootfs_type)" = "tmpfs" ] && mtd erase firmware
default_do_upgrade "$1"
;;
mikrotik,hap-ac3)
platform_do_upgrade_mikrotik_nand "$1"
;;
netgear,rbr50 |\
netgear,rbs50 |\
netgear,srr60 |\
netgear,srs60)
platform_do_upgrade_netgear_orbi_upgrade "$1"
;;
openmesh,a42 |\
openmesh,a62 |\
plasmacloud,pa1200 |\
plasmacloud,pa2200)
PART_NAME="inactive"
platform_do_upgrade_dualboot_datachk "$1"
;;
teltonika,rutx)
platform_do_upgrade_ipq "$1"
;;
zte,mf286d)
CI_UBIPART="rootfs"
nand_do_upgrade "$1"
;;
zyxel,nbg6617)
zyxel_do_upgrade "$1"
;;
*)
default_do_upgrade "$1"
;;
esac
}
platform_copy_config() {
case "$(board_name)" in
glinet,gl-b2200)
emmc_copy_config
;;
teltonika,rutx)
platform_copy_config_ipq
;;
esac
return 0;
}

View file

@ -1,147 +0,0 @@
#!/bin/sh
. /lib/functions.sh
. /lib/functions/system.sh
export IMAGE="$1"
COMMAND="$2"
export INTERACTIVE=0
export VERBOSE=1
export CONFFILES=/tmp/sysupgrade.conffiles
RAMFS_COPY_BIN= # extra programs for temporary ramfs root
RAMFS_COPY_DATA= # extra data files
include /lib/upgrade
supivot() { # <new_root> <old_root>
/bin/mount | grep "on $1 type" 2>&- 1>&- || /bin/mount -o bind $1 $1
mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \
/bin/mount -o noatime,move /proc $1/proc && \
pivot_root $1 $1$2 || {
/bin/umount -l $1 $1
return 1
}
/bin/mount -o noatime,move $2/sys /sys
/bin/mount -o noatime,move $2/dev /dev
/bin/mount -o noatime,move $2/tmp /tmp
/bin/mount -o noatime,move $2/overlay /overlay 2>&-
return 0
}
switch_to_ramfs() {
for binary in \
/bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \
pivot_root mount_root reboot sync kill sleep \
md5sum hexdump cat zcat bzcat dd tar \
ls basename find cp mv rm mkdir rmdir mknod touch chmod \
'[' printf wc grep awk sed cut \
mtd partx losetup mkfs.ext4 nandwrite flash_erase \
ubiupdatevol ubiattach ubiblock ubiformat \
ubidetach ubirsvol ubirmvol ubimkvol \
snapshot snapshot_tool date jshn dtbtool dtc mkbootimg \
ubinize-image.sh sysupgrade-tar.sh which ubinize mktemp \
dumpimage ledman fwtool \
$RAMFS_COPY_BIN
do
local file="$(command -v "$binary" 2>/dev/null)"
[ -n "$file" ] && install_bin "$file"
done
install_file /etc/resolv.conf \
/lib/*.sh \
/lib/functions/*.sh \
/lib/upgrade/*.sh \
/lib/upgrade/do_stage2 \
/usr/share/libubox/jshn.sh \
/etc/board.json \
$RAMFS_COPY_DATA
[ -L "/lib64" ] && ln -s /lib $RAM_ROOT/lib64
supivot $RAM_ROOT /mnt || {
v "Failed to switch over to ramfs. Please reboot."
exit 1
}
/bin/mount -o remount,ro /mnt
/bin/umount -l /mnt
grep /overlay /proc/mounts > /dev/null && {
/bin/mount -o noatime,remount,ro /overlay
/bin/umount -l /overlay
}
}
kill_remaining() { # [ <signal> [ <loop> ] ]
local loop_limit=10
local sig="${1:-TERM}"
local loop="${2:-0}"
local run=true
local stat
local proc_ppid=$(cut -d' ' -f4 /proc/$$/stat)
vn "Sending $sig to remaining processes ..."
while $run; do
run=false
for stat in /proc/[0-9]*/stat; do
[ -f "$stat" ] || continue
local pid name state ppid rest
read pid name state ppid rest < $stat
name="${name#(}"; name="${name%)}"
# Skip PID1, our parent, ourself and our children
[ $pid -ne 1 -a $pid -ne $proc_ppid -a $pid -ne $$ -a $ppid -ne $$ ] || continue
local cmdline
read cmdline < /proc/$pid/cmdline
# Skip kernel threads
[ -n "$cmdline" ] || continue
_vn " $name"
kill -$sig $pid 2>/dev/null
[ $loop -eq 1 ] && run=true
done
let loop_limit--
[ $loop_limit -eq 0 ] && {
_v
v "Failed to kill all processes."
exit 1
}
done
_v
}
[ -n "$(pgrep telnetd)" ] && {
killall -9 telnetd
}
[ -n "$(pgrep dropbear)" ] && {
killall -9 dropbear
}
killall -9 ash
kill_remaining TERM
sleep 3
kill_remaining KILL 1
sleep 1
echo 3 > /proc/sys/vm/drop_caches
if [ -n "$(rootfs_type)" ]; then
v "Switching to ramdisk..."
switch_to_ramfs
fi
# Exec new shell from ramfs
exec /bin/busybox ash -c "$COMMAND"