89_move_config 627 B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. # Copyright (C) 2012 OpenWrt.org
  3. move_config() {
  4. local rootfsdev
  5. local rootfstype
  6. rootfstype="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "rootfstype") { print $2 }' < /proc/cmdline)"
  7. case "$rootfstype" in
  8. squashfs|jffs2)
  9. rootfsdev="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "block2mtd.block2mtd") { print substr($2,1,index($2, ",")-1) }' < /proc/cmdline)";;
  10. ext4)
  11. rootfsdev="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "root") { print $2 }' < /proc/cmdline)";;
  12. esac
  13. mount -t ext4 -o rw,noatime "${rootfsdev%[0-9]}1" /mnt
  14. mv -f /mnt/sysupgrade.tgz /
  15. umount /mnt
  16. }
  17. boot_hook_add preinit_main move_config