Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root@router:~# cat /lib/upgrade/common.sh
- #!/bin/sh
- RAM_ROOT=/tmp/root
- ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
- libs() { ldd $* | awk '{print $3}'; }
- install_file() { # <file> [ <file> ... ]
- for file in "$@"; do
- dest="$RAM_ROOT/$file"
- [ -f $file -a ! -f $dest ] && {
- dir="$(dirname $dest)"
- mkdir -p "$dir"
- cp $file $dest
- }
- done
- }
- install_bin() { # <file> [ <symlink> ... ]
- src=$1
- files=$1
- [ -x "$src" ] && files="$src $(libs $src)"
- install_file $files
- [ -e /lib/ld-linux.so.3 ] && {
- install_file /lib/ld-linux.so.3
- }
- shift
- for link in "$@"; do {
- dest="$RAM_ROOT/$link"
- dir="$(dirname $dest)"
- mkdir -p "$dir"
- [ -f "$dest" ] || ln -s $src $dest
- }; done
- }
- pivot() { # <new_root> <old_root>
- mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1
- mkdir -p $1$2 $1/proc $1/dev $1/tmp $1/overlay && \
- mount -o move /proc $1/proc && \
- pivot_root $1 $1$2 || {
- umount $1 $1
- return 1
- }
- mount -o move $2/dev /dev
- mount -o move $2/tmp /tmp
- mount -o move $2/overlay /overlay 2>&-
- return 0
- }
- run_ramfs() { # <command> [...]
- install_bin /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount /sbin/pivot_root /usr/bin/wget /sbin/reboot /bin/sync /bin/dd /bin/grep /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" /bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump /bin/sleep /bin/zcat /usr/bin/bzcat
- install_bin /sbin/mtd
- for file in $RAMFS_COPY_BIN; do
- install_bin $file
- done
- install_file /etc/resolv.conf /etc/functions.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA
- pivot $RAM_ROOT /mnt || {
- echo "Failed to switch over to ramfs. Please reboot."
- exit 1
- }
- mount -o remount,ro /mnt
- umount -l /mnt
- grep /overlay /proc/mounts > /dev/null && {
- mount -o remount,ro /overlay
- umount -l /overlay
- }
- # spawn a new shell from ramdisk to reduce the probability of cache issues
- exec /bin/busybox ash -c "$*"
- }
- run_hooks() {
- local arg="$1"; shift
- for func in "$@"; do
- eval "$func $arg"
- done
- }
- ask_bool() {
- local default="$1"; shift;
- local answer="$default"
- [ "$INTERACTIVE" -eq 1 ] && {
- case "$default" in
- 0) echo -n "$* (y/N): ";;
- *) echo -n "$* (Y/n): ";;
- esac
- read answer
- case "$answer" in
- y*) answer=1;;
- n*) answer=0;;
- *) answer="$default";;
- esac
- }
- [ "$answer" -gt 0 ]
- }
- v() {
- [ "$VERBOSE" -ge 1 ] && echo "$@"
- }
- rootfs_type() {
- mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }'
- }
- get_image() { # <source> [ <command> ]
- local from="$1"
- local conc="$2"
- local cmd
- case "$from" in
- http://*|ftp://*) cmd="wget -O- -q";;
- *) cmd="cat";;
- esac
- if [ -z "$conc" ]; then
- local magic="$(eval $cmd $from | dd bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')"
- case "$magic" in
- 1f8b) conc="zcat";;
- 425a) conc="bzcat";;
- esac
- fi
- eval "$cmd $from ${conc:+| $conc}"
- }
- get_magic_word() {
- get_image "$@" | dd bs=2 count=1 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"'
- }
- get_magic_long() {
- get_image "$@" | dd bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
- }
- refresh_mtd_partitions() {
- mtd refresh rootfs
- }
- jffs2_copy_config() {
- if grep rootfs_data /proc/mtd >/dev/null; then
- # squashfs+jffs2
- mtd -e rootfs_data jffs2write "$CONF_TAR" rootfs_data
- else
- # jffs2
- mtd jffs2write "$CONF_TAR" rootfs
- fi
- }
- default_do_upgrade() {
- sync
- if [ "$SAVE_CONFIG" -eq 1 -a -z "$USE_REFRESH" ]; then
- get_image "$1" | mtd -j "$CONF_TAR" write - "${PART_NAME:-image}"
- else
- get_image "$1" | mtd write - "${PART_NAME:-image}"
- fi
- }
- do_upgrade() {
- v "Performing system upgrade..."
- if type 'platform_do_upgrade' >/dev/null 2>/dev/null; then
- platform_do_upgrade "$ARGV"
- else
- default_do_upgrade "$ARGV"
- fi
- [ "$SAVE_CONFIG" -eq 1 -a -n "$USE_REFRESH" ] && {
- v "Refreshing partitions"
- if type 'platform_refresh_partitions' >/dev/null 2>/dev/null; then
- platform_refresh_partitions
- else
- refresh_mtd_partitions
- fi
- if type 'platform_copy_config' >/dev/null 2>/dev/null; then
- platform_copy_config
- else
- jffs2_copy_config
- fi
- }
- v "Upgrade completed"
- [ -n "$DELAY" ] && sleep "$DELAY"
- ask_bool 1 "Reboot" && {
- v "Rebooting system..."
- reboot -f
- sleep 5
- echo b 2>/dev/null >/proc/sysrq-trigger
- }
- }
- root@router:~# cat /lib/upgrade/platform.sh
- #
- # Copyright (C) 2009 OpenWrt.org
- #
- . /lib/ar71xx.sh
- PART_NAME=firmware
- RAMFS_COPY_DATA=/lib/ar71xx.sh
- CI_BLKSZ=65536
- CI_LDADR=0x80060000
- platform_find_partitions() {
- local first dev size erasesize name
- while read dev size erasesize name; do
- name=${name#'"'}; name=${name%'"'}
- case "$name" in
- vmlinux.bin.l7|kernel|linux|rootfs)
- if [ -z "$first" ]; then
- first="$name"
- else
- echo "$erasesize:$first:$name"
- break
- fi
- ;;
- esac
- done < /proc/mtd
- }
- platform_find_kernelpart() {
- local part
- for part in "${1%:*}" "${1#*:}"; do
- case "$part" in
- vmlinux.bin.l7|kernel|linux)
- echo "$part"
- break
- ;;
- esac
- done
- }
- platform_do_upgrade_combined() {
- local partitions=$(platform_find_partitions)
- local kernelpart=$(platform_find_kernelpart "${partitions#*:}")
- local erase_size=$((0x${partitions%%:*})); partitions="${partitions#*:}"
- local kern_length=0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null)
- local kern_blocks=$(($kern_length / $CI_BLKSZ))
- local root_blocks=$((0x$(dd if="$1" bs=2 skip=5 count=4 2>/dev/null) / $CI_BLKSZ))
- if [ -n "$partitions" ] && [ -n "$kernelpart" ] && \
- [ ${kern_blocks:-0} -gt 0 ] && \
- [ ${root_blocks:-0} -gt ${kern_blocks:-0} ] && \
- [ ${erase_size:-0} -gt 0 ];
- then
- local append=""
- [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR"
- ( dd if="$1" bs=$CI_BLKSZ skip=1 count=$kern_blocks 2>/dev/null; \
- dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null ) | \
- mtd -r $append -F$kernelpart:$kern_length:$CI_LDADR,rootfs write - $partitions
- fi
- }
- platform_check_image() {
- local board=$(ar71xx_board_name)
- local magic="$(get_magic_word "$1")"
- local magic_long="$(get_magic_long "$1")"
- [ "$ARGC" -gt 1 ] && return 1
- case "$board" in
- ap121 | ap121-mini | ap96 | db120 | zcn-1523h-2 | zcn-1523h-5)
- [ "$magic" != "68737173" -a "$magic" != "19852003" ] && {
- echo "Invalid image type."
- return 1
- }
- return 0
- ;;
- ap81 | ap83 | dir-600-a1 | dir-615-c1 | dir-825-b1 | mzk-w04nu | mzk-w300nh | tew-632brp | wrt400n | bullet-m | nanostation-m | rocket-m | wzr-hp-g300nh | wzr-hp-ag300h | whr-hp-g300n | nbg460n_550n_550nh | unifi )
- [ "$magic" != "2705" ] && {
- echo "Invalid image type."
- return 1
- }
- return 0
- ;;
- tl-mr3220 | tl-mr3420 | tl-wa901nd | tl-wa901nd-v2 | tl-wr703n | tl-wr741nd | tl-wr841n-v1 | tl-wr941nd | tl-wr1043nd)
- [ "$magic" != "0100" ] && {
- echo "Invalid image type."
- return 1
- }
- return 0
- ;;
- wndr3700)
- [ "$magic_long" != "33373030" ] && {
- echo "Invalid image type."
- return 1
- }
- return 0
- ;;
- wndr3700v2)
- [ "$magic_long" != "33373031" ] && {
- echo "Invalid image type."
- return 1
- }
- return 0
- ;;
- wrt160nl)
- [ "$magic" != "4e4c" ] && {
- echo "Invalid image type."
- return 1
- }
- return 0
- ;;
- routerstation | routerstation-pro | ls-sr71 | pb42 | pb44 | eap7660d | ja76pf )
- [ "$magic" != "4349" ] && {
- echo "Invalid image. Use *-sysupgrade.bin files on this board"
- return 1
- }
- local md5_img=$(dd if="$1" bs=2 skip=9 count=16 2>/dev/null)
- local md5_chk=$(dd if="$1" bs=$CI_BLKSZ skip=1 2>/dev/null | md5sum -); md5_chk="${md5_chk%% *}"
- if [ -n "$md5_img" -a -n "$md5_chk" ] && [ "$md5_img" = "$md5_chk" ]; then
- return 0
- else
- echo "Invalid image. Contents do not match checksum (image:$md5_img calculated:$md5_chk)"
- return 1
- fi
- return 0
- ;;
- esac
- echo "Sysupgrade is not yet supported on $board."
- return 1
- }
- platform_do_upgrade() {
- local board=$(ar71xx_board_name)
- case "$board" in
- routerstation | routerstation-pro | ls-sr71 | eap7660d | ja76pf )
- platform_do_upgrade_combined "$ARGV"
- ;;
- *)
- default_do_upgrade "$ARGV"
- ;;
- esac
- }
- disable_watchdog() {
- killall watchdog
- ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
- echo 'Could not disable watchdog'
- return 1
- }
- }
- append sysupgrade_pre_upgrade disable_watchdog
- root@router:~# cat /etc/functions.sh
- #!/bin/sh
- # Copyright (C) 2006 OpenWrt.org
- # Copyright (C) 2006 Fokus Fraunhofer <[email protected]>
- debug () {
- ${DEBUG:-:} "$@"
- }
- mount() {
- busybox mount "$@"
- }
- # newline
- N="
- "
- _C=0
- NO_EXPORT=1
- LOAD_STATE=1
- LIST_SEP=" "
- hotplug_dev() {
- env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug-call net
- }
- append() {
- local var="$1"
- local value="$2"
- local sep="${3:- }"
- eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\""
- }
- list_contains() {
- local var="$1"
- local str="$2"
- local val
- eval "val=\" \${$var} \""
- [ "${val%% $str *}" != "$val" ]
- }
- list_remove() {
- local var="$1"
- local remove="$2"
- local val
- eval "val=\" \${$var} \""
- val1="${val%% $remove *}"
- [ "$val1" = "$val" ] && return
- val2="${val##* $remove }"
- [ "$val2" = "$val" ] && return
- val="${val1## } ${val2%% }"
- val="${val%% }"
- eval "export ${NO_EXPORT:+-n} -- \"$var=\$val\""
- }
- config_load() {
- [ -n "$IPKG_INSTROOT" ] && return 0
- uci_load "$@"
- }
- reset_cb() {
- config_cb() { return 0; }
- option_cb() { return 0; }
- list_cb() { return 0; }
- }
- reset_cb
- package() {
- return 0
- }
- config () {
- local cfgtype="$1"
- local name="$2"
- export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=$(($CONFIG_NUM_SECTIONS + 1))
- name="${name:-cfg$CONFIG_NUM_SECTIONS}"
- append CONFIG_SECTIONS "$name"
- [ -n "$NO_CALLBACK" ] || config_cb "$cfgtype" "$name"
- export ${NO_EXPORT:+-n} CONFIG_SECTION="$name"
- export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype"
- }
- option () {
- local varname="$1"; shift
- local value="$*"
- export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_${varname}=$value"
- [ -n "$NO_CALLBACK" ] || option_cb "$varname" "$*"
- }
- list() {
- local varname="$1"; shift
- local value="$*"
- local len
- config_get len "$CONFIG_SECTION" "${varname}_LENGTH" 0
- [ $len = 0 ] && append CONFIG_LIST_STATE "${CONFIG_SECTION}_${varname}"
- len=$(($len + 1))
- config_set "$CONFIG_SECTION" "${varname}_ITEM$len" "$value"
- config_set "$CONFIG_SECTION" "${varname}_LENGTH" "$len"
- append "CONFIG_${CONFIG_SECTION}_${varname}" "$value" "$LIST_SEP"
- list_cb "$varname" "$*"
- }
- config_rename() {
- local OLD="$1"
- local NEW="$2"
- local oldvar
- local newvar
- [ -n "$OLD" -a -n "$NEW" ] || return
- for oldvar in `set | grep ^CONFIG_${OLD}_ | \
- sed -e 's/\(.*\)=.*$/\1/'` ; do
- newvar="CONFIG_${NEW}_${oldvar##CONFIG_${OLD}_}"
- eval "export ${NO_EXPORT:+-n} \"$newvar=\${$oldvar}\""
- unset "$oldvar"
- done
- export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$(echo " $CONFIG_SECTIONS " | sed -e "s, $OLD , $NEW ,")"
- [ "$CONFIG_SECTION" = "$OLD" ] && export ${NO_EXPORT:+-n} CONFIG_SECTION="$NEW"
- }
- config_unset() {
- config_set "$1" "$2" ""
- }
- config_clear() {
- local SECTION="$1"
- local oldvar
- list_remove CONFIG_SECTIONS "$SECTION"
- export ${NO_EXPORT:+-n} CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}"
- for oldvar in `set | grep ^CONFIG_${SECTION:+${SECTION}_} | \
- sed -e 's/\(.*\)=.*$/\1/'` ; do
- unset $oldvar
- done
- }
- # config_get <variable> <section> <option> [<default>]
- # config_get <section> <option>
- config_get() {
- case "$3" in
- "") eval echo "\${CONFIG_${1}_${2}:-\${4}}";;
- *) eval export ${NO_EXPORT:+-n} -- "${1}=\${CONFIG_${2}_${3}:-\${4}}";;
- esac
- }
- # config_get_bool <variable> <section> <option> [<default>]
- config_get_bool() {
- local _tmp
- config_get _tmp "$2" "$3" "$4"
- case "$_tmp" in
- 1|on|true|enabled) _tmp=1;;
- 0|off|false|disabled) _tmp=0;;
- *) _tmp="$4";;
- esac
- export ${NO_EXPORT:+-n} "$1=$_tmp"
- }
- config_set() {
- local section="$1"
- local option="$2"
- local value="$3"
- local old_section="$CONFIG_SECTION"
- CONFIG_SECTION="$section"
- option "$option" "$value"
- CONFIG_SECTION="$old_section"
- }
- config_foreach() {
- local function="$1"
- [ "$#" -ge 1 ] && shift
- local type="$1"
- [ "$#" -ge 1 ] && shift
- local section cfgtype
- [ -z "$CONFIG_SECTIONS" ] && return 0
- for section in ${CONFIG_SECTIONS}; do
- config_get cfgtype "$section" TYPE
- [ -n "$type" -a "x$cfgtype" != "x$type" ] && continue
- eval "$function \"\$section\" \"\$@\""
- done
- }
- config_list_foreach() {
- [ "$#" -ge 3 ] || return 0
- local section="$1"; shift
- local option="$1"; shift
- local function="$1"; shift
- local val
- local len
- local c=1
- config_get len "${section}" "${option}_LENGTH"
- [ -z "$len" ] && return 0
- while [ $c -le "$len" ]; do
- config_get val "${section}" "${option}_ITEM$c"
- eval "$function \"\$val\" \"$@\""
- c="$(($c + 1))"
- done
- }
- load_modules() {
- [ -d /etc/modules.d ] && {
- cd /etc/modules.d
- sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
- }
- }
- include() {
- local file
- for file in $(ls $1/*.sh 2>/dev/null); do
- . $file
- done
- }
- find_mtd_part() {
- local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
- local PREFIX=/dev/mtdblock
- PART="${PART##mtd}"
- [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
- echo "${PART:+$PREFIX$PART}"
- }
- strtok() { # <string> { <variable> [<separator>] ... }
- local tmp
- local val="$1"
- local count=0
- shift
- while [ $# -gt 1 ]; do
- tmp="${val%%$2*}"
- [ "$tmp" = "$val" ] && break
- val="${val#$tmp$2}"
- export ${NO_EXPORT:+-n} "$1=$tmp"; count=$((count+1))
- shift 2
- done
- if [ $# -gt 0 -a -n "$val" ]; then
- export ${NO_EXPORT:+-n} "$1=$val"; count=$((count+1))
- fi
- return $count
- }
- jffs2_mark_erase() {
- local part="$(find_mtd_part "$1")"
- [ -z "$part" ] && {
- echo Partition not found.
- return 1
- }
- echo -e "\xde\xad\xc0\xde" | mtd -qq write - "$1"
- }
- uci_apply_defaults() {
- cd /etc/uci-defaults || return 0
- files="$(ls)"
- [ -z "$files" ] && return 0
- mkdir -p /tmp/.uci
- for file in $files; do
- ( . "./$(basename $file)" ) && rm -f "$file"
- done
- uci commit
- }
- service_kill() {
- local name="${1}"
- local pid="${2:-$(pidof "$name")}"
- local grace="${3:-5}"
- [ -f "$pid" ] && pid="$(head -n1 "$pid" 2>/dev/null)"
- for pid in $pid; do
- [ -d "/proc/$pid" ] || continue
- local try=0
- kill -TERM $pid 2>/dev/null && \
- while grep -qs "$name" "/proc/$pid/cmdline" && [ $((try++)) -lt $grace ]; do sleep 1; done
- kill -KILL $pid 2>/dev/null && \
- while grep -qs "$name" "/proc/$pid/cmdline"; do sleep 1; done
- done
- }
- pi_include() {
- if [ -f "/tmp/overlay/$1" ]; then
- . "/tmp/overlay/$1"
- elif [ -f "$1" ]; then
- . "$1"
- elif [ -d "/tmp/overlay/$1" ]; then
- if [ -n "$(ls /tmp/overlay/$1/*.sh 2>/dev/null)" ]; then
- for src_script in /tmp/overlay/$1/*.sh; do
- . "$src_script"
- done
- fi
- elif [ -d "$1" ]; then
- if [ -n "$(ls $1/*.sh 2>/dev/null)" ]; then
- for src_script in $1/*.sh; do
- . "$src_script"
- done
- fi
- else
- echo "WARNING: $1 not found"
- return 1
- fi
- return 0
- }
- [ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh
- root@router:~# cat /sbin/sysupgrade
- #!/bin/sh
- . /etc/functions.sh
- # initialize defaults
- RAMFS_COPY_BIN="" # extra programs for temporary ramfs root
- RAMFS_COPY_DATA="" # extra data files
- export INTERACTIVE=0
- export VERBOSE=1
- export SAVE_CONFIG=1
- export SAVE_OVERLAY=0
- export DELAY=
- export CONF_IMAGE=
- export HELP=0
- # parse options
- while [ -n "$1" ]; do
- case "$1" in
- -i) export INTERACTIVE=1;;
- -d) export DELAY="$2"; shift;;
- -v) export VERBOSE="$(($VERBOSE + 1))";;
- -q) export VERBOSE="$(($VERBOSE - 1))";;
- -n) export SAVE_CONFIG=0;;
- -c) export SAVE_OVERLAY=1;;
- -f) export CONF_IMAGE="$2"; shift;;
- -h|--help) export HELP=1; break;;
- -*)
- echo "Invalid option: $1"
- exit 1
- ;;
- *) break;;
- esac
- shift;
- done
- export CONFFILES=/tmp/sysupgrade.conffiles
- export CONF_TAR=/tmp/sysupgrade.tgz
- export ARGV="$*"
- export ARGC="$#"
- [ -z "$ARGV" -o $HELP -gt 0 ] && {
- cat <<EOF
- Usage: $0 [options] <image file or URL>
- Options:
- -d <delay> add a delay before rebooting
- -f <config> restore configuration from .tar.gz (file or url)
- -i interactive mode
- -c attempt to preserve all changed files in /etc/
- -n do not save configuration over reflash
- -q less verbose
- -v more verbose
- -h / --help display this help
- EOF
- exit 1
- }
- add_uci_conffiles() {
- local file="$1"
- ( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
- /etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \
- -type f 2>/dev/null;
- opkg list-changed-conffiles ) | sort -u > "$file"
- return 0
- }
- add_overlayfiles() {
- local file="$1"
- find /overlay/etc/ -type f | sed \
- -e 's,^/overlay/,/,' \
- -e '\,/META_[a-zA-Z0-9]*$,d' \
- -e '\,/functions.sh$,d' \
- -e '\,/[^/]*-opkg$,d' \
- > "$file"
- return 0
- }
- # hooks
- sysupgrade_image_check="platform_check_image"
- [ $SAVE_OVERLAY = 0 -o ! -d /overlay/etc ] && \
- sysupgrade_init_conffiles="add_uci_conffiles" || \
- sysupgrade_init_conffiles="add_overlayfiles"
- include /lib/upgrade
- do_save_conffiles() {
- [ -z "$(rootfs_type)" ] && {
- echo "Cannot save config while running from ramdisk."
- ask_bool 0 "Abort" && exit
- return 0
- }
- run_hooks "$CONFFILES" $sysupgrade_init_conffiles
- ask_bool 0 "Edit config file list" && vi "$CONFFILES"
- v "Saving config files..."
- [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
- tar c${TAR_V}zf "$CONF_TAR" -T "$CONFFILES" 2>/dev/null
- }
- type platform_check_image >/dev/null 2>/dev/null || {
- echo "Firmware upgrade is not implemented for this platform."
- exit 1
- }
- for check in $sysupgrade_image_check; do
- ( eval "$check \"\$ARGV\"" ) || {
- echo "Image check '$check' failed."
- exit 1
- }
- done
- if [ -n "$CONF_IMAGE" ]; then
- case "$(get_magic_word $CONF_IMAGE cat)" in
- # .gz files
- 1f8b) ;;
- *)
- echo "Invalid config file. Please use only .tar.gz files"
- exit 1
- ;;
- esac
- get_image "$CONF_IMAGE" "cat" > "$CONF_TAR"
- export SAVE_CONFIG=1
- elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then
- do_save_conffiles
- export SAVE_CONFIG=1
- else
- export SAVE_CONFIG=0
- fi
- run_hooks "" $sysupgrade_pre_upgrade
- if [ -n "$(rootfs_type)" ]; then
- v "Switching to ramdisk..."
- run_ramfs '. /etc/functions.sh; include /lib/upgrade; do_upgrade'
- else
- do_upgrade
- fi
Advertisement
Add Comment
Please, Sign In to add comment