0bffbab994befdd9ec7b81f24b9a2cdf2e6ec1b3
[openwrt/openwrt.git] / target / linux / x86_64 / base-files / lib / preinit / 79_move_config
1 #!/bin/sh
2 # Copyright (C) 2012 OpenWrt.org
3
4 move_config() {
5 local rootfsdev
6 local rootfstype
7
8 rootfstype="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "rootfstype") { print $2 }' < /proc/cmdline)"
9 case "$rootfstype" in
10 squashfs|jffs2)
11 rootfsdev="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "block2mtd.block2mtd") { print substr($2,1,index($2, ",")-1) }' < /proc/cmdline)";;
12 ext4)
13 rootfsdev="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "root") { print $2 }' < /proc/cmdline)";;
14 esac
15
16 mount -t ext4 -o rw,noatime "${rootfsdev%[0-9]}1" /mnt
17 mv -f /mnt/sysupgrade.tgz /
18 umount /mnt
19 }
20
21 boot_hook_add preinit_mount_root move_config
22