5 RAMFS_COPY_BIN="" # extra programs for temporary ramfs root
6 RAMFS_COPY_DATA="" # extra data files
17 -i) export INTERACTIVE=1;;
18 -d) export DELAY="$2"; shift;;
19 -v) export VERBOSE="$(($VERBOSE + 1))";;
20 -q) export VERBOSE="$(($VERBOSE - 1))";;
21 -n) export SAVE_CONFIG=0;;
22 -c) export SAVE_OVERLAY=1;;
23 -f) export CONF_IMAGE="$2"; shift;;
25 echo "Invalid option: $1"
33 export CONFFILES=/tmp/sysupgrade.conffiles
34 export CONF_TAR=/tmp/sysupgrade.tgz
41 Usage: $0 [options] <image file or URL>
44 -d <delay> add a delay before rebooting
45 -f <config> restore configuration from .tar.gz (file or url)
47 -c attempt to preserve all changed files in /etc/
48 -n do not save configuration over reflash
58 find /etc/config /etc/passwd /etc/group /etc/dropbear \
59 /etc/firewall.user /etc/rc.local -type f > "$file"
65 find /overlay/etc/ -type f | sed \
66 -e 's,^/overlay/,/,' \
67 -e '\,/META_[a-zA-Z0-9]*$,d' \
68 -e '\,/functions.sh$,d' \
69 -e '\,/[^/]*-opkg$,d' \
75 sysupgrade_image_check="platform_check_image"
76 [ $SAVE_OVERLAY = 0 -o ! -d /overlay/etc ] && \
77 sysupgrade_init_conffiles="add_uci_conffiles" || \
78 sysupgrade_init_conffiles="add_overlayfiles"
83 [ -z "$(rootfs_type)" ] && {
84 echo "Cannot save config while running from ramdisk."
85 ask_bool 0 "Abort" && exit
88 run_hooks "$CONFFILES" $sysupgrade_init_conffiles
89 ask_bool 0 "Edit config file list" && vi "$CONFFILES"
91 v "Saving config files..."
92 [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
93 tar c${TAR_V}zf "$CONF_TAR" -T "$CONFFILES" 2>/dev/null
96 type platform_check_image >/dev/null 2>/dev/null || {
97 echo "Firmware upgrade is not implemented for this platform."
101 for check in $sysupgrade_image_check; do
102 ( eval "$check \"\$ARGV\"" ) || {
103 echo "Image check '$check' failed."
108 if [ -n "$CONF_IMAGE" ]; then
109 case "$(get_magic_word $CONF_IMAGE cat)" in
113 echo "Invalid config file. Please use only .tar.gz files"
117 get_image "$CONF_IMAGE" "cat" > "$CONF_TAR"
119 elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then
125 run_hooks "" $sysupgrade_pre_upgrade
127 if [ -n "$(rootfs_type)" ]; then
128 v "Switching to ramdisk..."
129 run_ramfs '. /etc/functions.sh; include /lib/upgrade; do_upgrade'