#!/usr/bin/webif-page -p /bin/sh ### # # FreeWLAN Addons - http://www.freewlan.info # # This Script is based on work from http://www.fonfan.de # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA # # http://www.gnu.org/copyleft/gpl.html # ### . /usr/lib/webif/webif.sh validate <>|max=10|$FORM_submit EOF if [ "$?" != "0" ]; then FORM_submit="" fi sel_backuprestore=1 . /usr/lib/webif/advanced.sh header "BackupRestore_Title#Fonera settings backup and restore" # file will be removed if another WebIf page is loaded (watch out webif.sh) if [ -f /etc/ethers ]; then taroptions="/etc/ethers" else taroptions="" fi [ -f /etc/dnsmasq.repeater ] && taroptions="$taroptions /etc/dnsmasq.repeater" [ -f /etc/wpa_supplicant.conf ] && taroptions="$taroptions /etc/wpa_supplicant.conf" [ -f /etc/debug ] && taroptions="$taroptions /etc/debug" [ -f /etc/chilli.allowed ] && taroptions="$taroptions /etc/chilli.allowed" [ -f /www/cgi-bin/webif/myoptions.sh ] && taroptions="$taroptions /www/cgi-bin/webif/myoptions.sh " settingsfile="`cat /etc/hostname`_$(date | awk -F" " '{print $6$2$3}')_`cat /etc/addon_version`_settings.fon.image" tar -czf /www/"$settingsfile" /etc/config /etc/passwd /etc/addon_version /etc/fon_version /etc/fon_revision /etc/hostname $taroptions > /dev/null 2> /dev/null display_form <> /tmp/restore.tar.gz mkdir /tmp/restore tar -xzf /tmp/restore.tar.gz -C /tmp/restore fonera_version=`cat /etc/addon_version` settings_version=`cat /tmp/restore/etc/addon_version` if [ $fonera_version != $settings_version ]; then echo "" echo "

@TR<>" echo "

@TR<>" echo "

@TR<>" rm -r /tmp/restore rm /tmp/restore.tar.gz footer exit else cp /tmp/restore/etc/passwd /etc/passwd- && mv /tmp/restore/etc/passwd /etc/passwd mv /tmp/restore/etc/config/* /etc/config mv /tmp/restore/etc/fon_version /fon_version mv /tmp/restore/etc/fon_revision /etc/fon_revision mv /tmp/restore/etc/hostname /etc/hostname [ -f /tmp/restore/etc/ethers ] && mv /tmp/restore/etc/ethers /etc/ethers [ -f /tmp/restore/etc/dnsmasq.repeater ] && mv /tmp/restore/etc/dnsmasq.repeater /etc/dnsmasq.repeater [ -f /tmp/restore/etc/wpa_supplicant.conf ] && mv /tmp/restore/etc/wpa_supplicant.conf /etc/wpa_supplicant.conf [ -f /tmp/restore/etc/debug ] && mv /tmp/restore/etc/debug /etc/debug [ -f /tmp/restore/etc/chilli.allowed ] && mv /tmp/restore/etc/chilli.allowed /etc/chilli.allowed [ -f /tmp/restore/www/cgi-bin/webif/myoptions.sh ] && mv /tmp/restore/www/cgi-bin/webif/myoptions.sh /www/cgi-bin/webif/myoptions.sh rm -r /tmp/restore echo "" echo "

@TR<>" echo "

REBOOTING" rm /tmp/restore.tar.gz footer sleep 2 display_form < function statusupdate() { document.getElementById("form_submit").style.display = "none"; document.getElementById("status_text").style.display = "none"; return true; } function printStatus() { document.write(''); } function backup() { location.href='/$settingsfile' } EOF display_form <>. end_row add_row add_download_button|@TR<>|backup end_row end_table add_form|restore|$SCRIPT_NAME$PATH_INFO|statusupdate start_table|0|10|5 add_row add_label_cell|@TR<>. end_row add_row add_fileinput_cell|settings end_row add_row call_js|printStatus add_input_submit_button|submit|@TR<>|statusupdate end_row end_table end_form EOF equal "$REQUEST_METHOD" "POST" && { equal "${CONTENT_TYPE%%;*}" "multipart/form-data" || ERR=1 BOUNDARY="${CONTENT_TYPE##*boundary=}" empty "$BOUNDARY" && ERR=1 empty "$ERR" || { echo "@TR<>" footer exit } display_form <>" footer exit } done display_form <