5 RAMFS_COPY_BIN
="" # extra programs for temporary ramfs root
6 RAMFS_COPY_DATA
="" # extra data files
19 -i) export INTERACTIVE
=1;;
20 -d) export DELAY
="$2"; shift;;
21 -v) export VERBOSE
="$(($VERBOSE + 1))";;
22 -q) export VERBOSE
="$(($VERBOSE - 1))";;
23 -n) export SAVE_CONFIG
=0;;
24 -c) export SAVE_OVERLAY
=1;;
25 -b|
--create-backup) export CONF_BACKUP
="$2"; shift;;
26 -f) export CONF_IMAGE
="$2"; shift;;
27 -h|
--help) export HELP
=1; break;;
29 echo "Invalid option: $1"
37 export CONFFILES
=/tmp
/sysupgrade.conffiles
38 export CONF_TAR
=/tmp
/sysupgrade.tgz
43 [ -z "$ARGV" -a -z "$CONF_BACKUP" -o $HELP -gt 0 ] && {
45 Usage: $0 [options] <image file or URL>
48 -d <delay> add a delay before rebooting
49 -f <config> restore configuration from .tar.gz (file or url)
51 -c attempt to preserve all changed files in /etc/
52 -b / --create-backup <file>
53 create .tar.gz of files specified in sysupgrade.conf
54 then exit. Does not flash an image. If file is '-',
55 i.e. stdout, verbosity is set to 0 (i.e. quiet).
56 -n do not save configuration over reflash
59 -h / --help display this help
65 [ -n "$ARGV" -a -n "$CONF_BACKUP" ] && {
67 -b/--create-backup does not perform a firmware upgrade. Do not
68 specify both -b and a firmware image.
73 # prevent messages from clobbering the tarball when using stdout
74 [ "$CONF_BACKUP" = "-" ] && export VERBOSE
=0
78 ( find $
(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
79 /etc
/sysupgrade.conf
/lib
/upgrade
/keep.d
/* 2>/dev
/null
) \
81 opkg list-changed-conffiles
) |
sort -u > "$file"
87 find /overlay
/etc
/ -type f |
sed \
88 -e 's,^/overlay/,/,' \
89 -e '\,/META_[a-zA-Z0-9]*$,d' \
90 -e '\,/functions.sh$,d' \
91 -e '\,/[^/]*-opkg$,d' \
97 sysupgrade_image_check
="platform_check_image"
98 [ $SAVE_OVERLAY = 0 -o ! -d /overlay
/etc
] && \
99 sysupgrade_init_conffiles
="add_uci_conffiles" || \
100 sysupgrade_init_conffiles
="add_overlayfiles"
104 do_save_conffiles
() {
105 local conf_tar
="${1:-$CONF_TAR}"
107 [ -z "$(rootfs_type)" ] && {
108 echo "Cannot save config while running from ramdisk."
109 ask_bool
0 "Abort" && exit
112 run_hooks
"$CONFFILES" $sysupgrade_init_conffiles
113 ask_bool
0 "Edit config file list" && vi
"$CONFFILES"
115 v
"Saving config files..."
116 [ "$VERBOSE" -gt 1 ] && TAR_V
="v" || TAR_V
=""
117 tar c
${TAR_V}zf
"$conf_tar" -T "$CONFFILES" 2>/dev
/null
120 if [ -n "$CONF_BACKUP" ]; then
121 do_save_conffiles
"$CONF_BACKUP"
125 type platform_check_image
>/dev
/null
2>/dev
/null ||
{
126 echo "Firmware upgrade is not implemented for this platform."
130 for check
in $sysupgrade_image_check; do
131 ( eval "$check \"\$ARGV\"" ) ||
{
132 echo "Image check '$check' failed."
137 if [ -n "$CONF_IMAGE" ]; then
138 case "$(get_magic_word $CONF_IMAGE cat)" in
142 echo "Invalid config file. Please use only .tar.gz files"
146 get_image
"$CONF_IMAGE" "cat" > "$CONF_TAR"
148 elif ask_bool
$SAVE_CONFIG "Keep config files over reflash"; then
155 run_hooks
"" $sysupgrade_pre_upgrade
161 if [ -n "$(rootfs_type)" ]; then
162 v
"Switching to ramdisk..."
163 run_ramfs
'. /etc/functions.sh; include /lib/upgrade; do_upgrade'