5 RAMFS_COPY_BIN
="" # extra programs for temporary ramfs root
6 RAMFS_COPY_DATA
="" # extra data files
18 -i) export INTERACTIVE
=1;;
19 -d) export DELAY
="$2"; shift;;
20 -v) export VERBOSE
="$(($VERBOSE + 1))";;
21 -q) export VERBOSE
="$(($VERBOSE - 1))";;
22 -n) export SAVE_CONFIG
=0;;
23 -c) export SAVE_OVERLAY
=1;;
24 -f) export CONF_IMAGE
="$2"; shift;;
25 -h|
--help) export HELP
=1; break;;
27 echo "Invalid option: $1"
35 export CONFFILES
=/tmp
/sysupgrade.conffiles
36 export CONF_TAR
=/tmp
/sysupgrade.tgz
41 [ -z "$ARGV" -o $HELP -gt 0 ] && {
43 Usage: $0 [options] <image file or URL>
46 -d <delay> add a delay before rebooting
47 -f <config> restore configuration from .tar.gz (file or url)
49 -c attempt to preserve all changed files in /etc/
50 -n do not save configuration over reflash
53 -h / --help display this help
61 ( find $
(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
62 /etc
/sysupgrade.conf
/lib
/upgrade
/keep.d
/* 2>/dev
/null
) \
64 opkg list-changed-conffiles
) |
sort -u > "$file"
70 find /overlay
/etc
/ -type f |
sed \
71 -e 's,^/overlay/,/,' \
72 -e '\,/META_[a-zA-Z0-9]*$,d' \
73 -e '\,/functions.sh$,d' \
74 -e '\,/[^/]*-opkg$,d' \
80 sysupgrade_image_check
="platform_check_image"
81 [ $SAVE_OVERLAY = 0 -o ! -d /overlay
/etc
] && \
82 sysupgrade_init_conffiles
="add_uci_conffiles" || \
83 sysupgrade_init_conffiles
="add_overlayfiles"
88 [ -z "$(rootfs_type)" ] && {
89 echo "Cannot save config while running from ramdisk."
90 ask_bool
0 "Abort" && exit
93 run_hooks
"$CONFFILES" $sysupgrade_init_conffiles
94 ask_bool
0 "Edit config file list" && vi
"$CONFFILES"
96 v
"Saving config files..."
97 [ "$VERBOSE" -gt 1 ] && TAR_V
="v" || TAR_V
=""
98 tar c
${TAR_V}zf
"$CONF_TAR" -T "$CONFFILES" 2>/dev
/null
101 type platform_check_image
>/dev
/null
2>/dev
/null ||
{
102 echo "Firmware upgrade is not implemented for this platform."
106 for check
in $sysupgrade_image_check; do
107 ( eval "$check \"\$ARGV\"" ) ||
{
108 echo "Image check '$check' failed."
113 if [ -n "$CONF_IMAGE" ]; then
114 case "$(get_magic_word $CONF_IMAGE cat)" in
118 echo "Invalid config file. Please use only .tar.gz files"
122 get_image
"$CONF_IMAGE" "cat" > "$CONF_TAR"
124 elif ask_bool
$SAVE_CONFIG "Keep config files over reflash"; then
130 run_hooks
"" $sysupgrade_pre_upgrade
132 if [ -n "$(rootfs_type)" ]; then
133 v
"Switching to ramdisk..."
134 run_ramfs
'. /etc/functions.sh; include /lib/upgrade; do_upgrade'