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 -f) export CONF_IMAGE="$2"; shift;;
23 -h|--help) export HELP=1; break;;
25 echo "Invalid option: $1"
33 export CONFFILES=/tmp/sysupgrade.conffiles
34 export CONF_TAR=/tmp/sysupgrade.tgz
39 [ -z "$ARGV" -o $HELP -gt 0 ] && {
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 -n do not save configuration over reflash
50 -h / --help display this help
58 ( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
59 /etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \
61 opkg list-changed-conffiles ) | sort -u > "$file"
66 sysupgrade_image_check="platform_check_image"
67 sysupgrade_init_conffiles="add_uci_conffiles"
72 [ -z "$(rootfs_type)" ] && {
73 echo "Cannot save config while running from ramdisk."
74 ask_bool 0 "Abort" && exit
77 run_hooks "$CONFFILES" $sysupgrade_init_conffiles
78 ask_bool 0 "Edit config file list" && vi "$CONFFILES"
80 v "Saving config files..."
81 [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
82 tar c${TAR_V}zf "$CONF_TAR" -T "$CONFFILES" 2>/dev/null
85 type platform_check_image >/dev/null 2>/dev/null || {
86 echo "Firmware upgrade is not implemented for this platform."
90 for check in $sysupgrade_image_check; do
91 ( eval "$check \"\$ARGV\"" ) || {
92 echo "Image check '$check' failed."
97 if [ -n "$CONF_IMAGE" ]; then
98 case "$(get_magic_word $CONF_IMAGE cat)" in
102 echo "Invalid config file. Please use only .tar.gz files"
106 get_image "$CONF_IMAGE" "cat" > "$CONF_TAR"
108 elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then
114 run_hooks "" $sysupgrade_pre_upgrade
116 if [ -n "$(rootfs_type)" ]; then
117 v "Switching to ramdisk..."
118 run_ramfs '. /etc/functions.sh; include /lib/upgrade; do_upgrade'