1 #!/usr/bin/webif-page -p /bin/sh
2 .
/usr
/lib
/webif
/webif.sh
6 ps |
grep -vE 'Command|init|\[[kbmj]|httpd|haserl|bin/sh|awk|kill|ps|webif' |
awk '{ print $1 }' |
xargs kill -KILL
7 MEMFREE
="$(awk 'BEGIN{ mem = 0 } ($1 == "MemFree
:") || ($1 == "Cached
:") {mem += int($2)} END{print mem}' /proc/meminfo)"
8 empty
"$ERASE_FS" || MTD_OPT
="-e linux"
9 if [ $
(($MEMFREE)) -ge 4096 ]; then
10 bstrip
"$BOUNDARY" > /tmp
/firmware.bin
11 mtd
$MTD_OPT -q -r write /tmp
/firmware.bin linux
13 # Not enough memory for storing the firmware on tmpfs
14 bstrip
"$BOUNDARY" | mtd
$MTD_OPT -q -q -r write - linux
23 LINE
="${LINE%%[^0-9A-Za-z]}"
24 equal
"$LINE" "$BOUNDARY" && read LINE
25 empty
"$NAME$LINE" && exit
28 NAME
="${LINE##*; name=\"}"
32 empty
"$LINE" && return
38 header
"System" "Firmware Upgrade" "@TR<<Firmware Upgrade>>"
40 equal
"$REQUEST_METHOD" "GET" && {
42 <script type="text/javascript">
44 function statusupdate() {
45 document.getElementById("form_submit").style.display = "none";
46 document.getElementById("status_text").style.display = "inline";
50 function printStatus() {
51 document.write('<div style="display: none; font-size: 14pt; font-weight: bold;" id="status_text" />@TR<<Upgrading...>> </div>');
54 <form method="POST" name="upgrade" action="$SCRIPT_NAME" enctype="multipart/form-data" onSubmit="statusupdate()">
55 <table style="width: 90%; text-align: left;" border="0" cellpadding="2" cellspacing="2" align="center">
58 <td>@TR<<Options>>:</td>
60 <input type="checkbox" name="erase_fs" value="1" />@TR<<Erase_JFFS2|Erase JFFS2 partition>>
64 <td>@TR<<Firmware_image|Firmware image to upload:>></td>
66 <input type="file" name="firmware" />
72 <script type="text/javascript">printStatus()</script>
73 <input id="form_submit" type="submit" name="submit" value="@TR<<Upgrade>>" onClick="statusupdate()" />
81 equal
"$REQUEST_METHOD" "POST" && {
82 equal
"${CONTENT_TYPE%%;*}" "multipart/form-data" || ERR
=1
83 BOUNDARY
="${CONTENT_TYPE##*boundary=}"
84 empty
"$BOUNDARY" && ERR
=1
87 echo "Wrong data format"
92 <div style="margin: auto; text-align: left">
101 bstrip
"$BOUNDARY" > /dev
/null
103 firmware
) do_upgrade
;;
113 ##WEBIF:name:System:400:Firmware Upgrade