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 -b|
--create-backup) export CONF_BACKUP
="$2"; shift;;
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" -a -z "$CONF_BACKUP" -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 -b / --create-backup <file>
50 create .tar.gz of files specified in sysupgrade.conf
51 then exit. Does not flash an image. If file is '-',
52 i.e. stdout, verbosity is set to 0 (i.e. quiet).
53 -n do not save configuration over reflash
56 -h / --help display this help
62 [ -n "$ARGV" -a -n "$CONF_BACKUP" ] && {
64 -b/--create-backup does not perform a firmware upgrade. Do not
65 specify both -b and a firmware image.
70 # prevent messages from clobbering the tarball when using stdout
71 [ "$CONF_BACKUP" = "-" ] && export VERBOSE
=0
75 ( find $
(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
76 /etc
/sysupgrade.conf
/lib
/upgrade
/keep.d
/* 2>/dev
/null
) \
78 opkg list-changed-conffiles
) |
sort -u > "$file"
83 sysupgrade_image_check
="platform_check_image"
84 sysupgrade_init_conffiles
="add_uci_conffiles"
89 local conf_tar
="${1:-$CONF_TAR}"
91 [ -z "$(rootfs_type)" ] && {
92 echo "Cannot save config while running from ramdisk."
93 ask_bool
0 "Abort" && exit
96 run_hooks
"$CONFFILES" $sysupgrade_init_conffiles
97 ask_bool
0 "Edit config file list" && vi
"$CONFFILES"
99 v
"Saving config files..."
100 [ "$VERBOSE" -gt 1 ] && TAR_V
="v" || TAR_V
=""
101 tar c
${TAR_V}zf
"$conf_tar" -T "$CONFFILES" 2>/dev
/null
104 if [ -n "$CONF_BACKUP" ]; then
105 do_save_conffiles
"$CONF_BACKUP"
109 type platform_check_image
>/dev
/null
2>/dev
/null ||
{
110 echo "Firmware upgrade is not implemented for this platform."
114 for check
in $sysupgrade_image_check; do
115 ( eval "$check \"\$ARGV\"" ) ||
{
116 echo "Image check '$check' failed."
121 if [ -n "$CONF_IMAGE" ]; then
122 case "$(get_magic_word $CONF_IMAGE cat)" in
126 echo "Invalid config file. Please use only .tar.gz files"
130 get_image
"$CONF_IMAGE" "cat" > "$CONF_TAR"
132 elif ask_bool
$SAVE_CONFIG "Keep config files over reflash"; then
138 run_hooks
"" $sysupgrade_pre_upgrade
140 if [ -n "$(rootfs_type)" ]; then
141 v
"Switching to ramdisk..."
142 run_ramfs
'. /etc/functions.sh; include /lib/upgrade; do_upgrade'