5 RAMFS_COPY_BIN
="" # extra programs for temporary ramfs root
6 RAMFS_COPY_DATA
="" # extra data files
20 -i) export INTERACTIVE
=1;;
21 -d) export DELAY
="$2"; shift;;
22 -v) export VERBOSE
="$(($VERBOSE + 1))";;
23 -q) export VERBOSE
="$(($VERBOSE - 1))";;
24 -n) export SAVE_CONFIG
=0;;
25 -c) export SAVE_OVERLAY
=1;;
26 -b|
--create-backup) export CONF_BACKUP
="$2"; shift;;
27 -f) export CONF_IMAGE
="$2"; shift;;
28 -F|
--force) export FORCE
=1; shift;;
29 -h|
--help) export HELP
=1; break;;
31 echo "Invalid option: $1"
39 export CONFFILES
=/tmp
/sysupgrade.conffiles
40 export CONF_TAR
=/tmp
/sysupgrade.tgz
45 [ -z "$ARGV" -a -z "$CONF_BACKUP" -o $HELP -gt 0 ] && {
47 Usage: $0 [options] <image file or URL>
50 -d <delay> add a delay before rebooting
51 -f <config> restore configuration from .tar.gz (file or url)
53 -c attempt to preserve all changed files in /etc/
54 -b / --create-backup <file>
55 create .tar.gz of files specified in sysupgrade.conf
56 then exit. Does not flash an image. If file is '-',
57 i.e. stdout, verbosity is set to 0 (i.e. quiet).
58 -n do not save configuration over reflash
60 Flash image even if image checks fail, this is dangerous!
63 -h / --help display this help
69 [ -n "$ARGV" -a -n "$CONF_BACKUP" ] && {
71 -b/--create-backup does not perform a firmware upgrade. Do not
72 specify both -b and a firmware image.
77 # prevent messages from clobbering the tarball when using stdout
78 [ "$CONF_BACKUP" = "-" ] && export VERBOSE
=0
82 ( find $
(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
83 /etc
/sysupgrade.conf
/lib
/upgrade
/keep.d
/* 2>/dev
/null
) \
85 opkg list-changed-conffiles
) |
sort -u > "$file"
91 find /overlay
/etc
/ -type f |
sed \
92 -e 's,^/overlay/,/,' \
93 -e '\,/META_[a-zA-Z0-9]*$,d' \
94 -e '\,/functions.sh$,d' \
95 -e '\,/[^/]*-opkg$,d' \
101 sysupgrade_image_check
="platform_check_image"
102 [ $SAVE_OVERLAY = 0 -o ! -d /overlay
/etc
] && \
103 sysupgrade_init_conffiles
="add_uci_conffiles" || \
104 sysupgrade_init_conffiles
="add_overlayfiles"
108 do_save_conffiles
() {
109 local conf_tar
="${1:-$CONF_TAR}"
111 [ -z "$(rootfs_type)" ] && {
112 echo "Cannot save config while running from ramdisk."
113 ask_bool
0 "Abort" && exit
116 run_hooks
"$CONFFILES" $sysupgrade_init_conffiles
117 ask_bool
0 "Edit config file list" && vi
"$CONFFILES"
119 v
"Saving config files..."
120 [ "$VERBOSE" -gt 1 ] && TAR_V
="v" || TAR_V
=""
121 tar c
${TAR_V}zf
"$conf_tar" -T "$CONFFILES" 2>/dev
/null
124 if [ -n "$CONF_BACKUP" ]; then
125 do_save_conffiles
"$CONF_BACKUP"
129 type platform_check_image
>/dev
/null
2>/dev
/null ||
{
130 echo "Firmware upgrade is not implemented for this platform."
134 for check
in $sysupgrade_image_check; do
135 ( eval "$check \"\$ARGV\"" ) ||
{
136 if [ $FORCE -eq 1 ]; then
137 echo "Image check '$check' failed but --force given - will update anyway!"
140 echo "Image check '$check' failed."
146 if [ -n "$CONF_IMAGE" ]; then
147 case "$(get_magic_word $CONF_IMAGE cat)" in
151 echo "Invalid config file. Please use only .tar.gz files"
155 get_image
"$CONF_IMAGE" "cat" > "$CONF_TAR"
157 elif ask_bool
$SAVE_CONFIG "Keep config files over reflash"; then
164 run_hooks
"" $sysupgrade_pre_upgrade
170 if [ -n "$(rootfs_type)" ]; then
171 v
"Switching to ramdisk..."
172 run_ramfs
'. /etc/functions.sh; include /lib/upgrade; do_upgrade'