Initial import

This commit is contained in:
Markus Birth 2014-08-12 00:27:35 +02:00
commit 8b236da7d7
16 changed files with 1322 additions and 0 deletions

73
.wifisd/access.sh Normal file
View File

@ -0,0 +1,73 @@
# https://www.pitt-pladdy.com/blog/_20140202-083815_0000_Transcend_Wi-Fi_SD_Hacks_CF_adaptor_telnet_custom_upload_/
# kill existing telnet & ftp daemons
killaccessdaemons() {
if [ -f /var/run/telnetd.pid ]; then
kill `cat /var/run/telnetd.pid`
rm /var/run/telnetd.pid
fi
if [ -f /var/run/ftpd.pid ]; then
kill `cat /var/run/ftpd.pid`
rm /var/run/ftpd.pid
fi
}
# start telnet & ftp daemons
startaccessdaemons() {
if [ ! -f /var/run/telnetd.pid ] || [ ! -d /proc/`cat /var/run/telnetd.pid` ]; then
telnetd -F -l /bin/bash &
echo $! >/var/run/telnetd.pid
fi
if [ ! -f /var/run/ftpd.pid ] || [ ! -d /proc/`cat /var/run/ftpd.pid` ]; then
# add -w to allow write access
tcpsvd -vE 0.0.0.0 21 ftpd /mnt/sd/ &
echo $! >/var/run/ftpd.pid
fi
}
# kill the autoupload process
killautoupload() {
if [ -f /var/run/autoupload.pid ]; then
kill `cat /var/run/autoupload.pid`
rm /var/run/autoupload.pid
fi
}
# start autoupload
startautoupload() {
if [ ! -f /var/run/autoupload.pid ] || [ ! -d /proc/`cat /var/run/autoupload.pid` ]; then
autoupload.pl
echo $! >/var/run/autoupload.pid
fi
}
# collect info about our surroundings
apssid=`busybox-extra head -n 1 /tmp/iwconfig_maln0.txt | busybox-extra sed 's/^.*ESSID:"\([^"]\+\)".*$/\1/'`
ping -c 1 $router >/dev/null 2>&1
routerMAC=`busybox-extra arp -n $router | busybox-extra awk '{print $4}'`
# check the situation and act accordingly
case "$1" in
deconfig)
killaccessdaemons
;;
bound)
echo "$apssid:$router:$routerMAC" >>/tmp/netid.log
case "$apssid:$router:$routerMAC" in
'SSID:11.22.33.44:ab:cd:ef:12:34:56'|'SECOND_SSID:11.22.33.44:fe:dc:ba:98:76:54')
# trusted network - run open access (telnetd / ftpd)
killautoupload
startaccessdaemons
;;
*)
# unknown - start auto-uploader TODO
killaccessdaemons
#startautoupload
;;
esac
;;
renew)
# do nothing - no change
;;
esac

151
.wifisd/autoupload.pl Normal file
View File

@ -0,0 +1,151 @@
#!/usr/bin/perl
# Custom Upload script for a Transcend Wi-Fi SD Card
# Copyright (C) Glen Pitt-Pladdy 2014
#
# 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.
#
#
# See: https://www.pitt-pladdy.com/blog/_20140202-083815_0000_Transcend_Wi-Fi_SD_Hacks_CF_adaptor_telnet_custom_upload_/
#
use strict;
use warnings;
# delay between itterations
my $LOOPDELAY = 5;
# path to mirror
my $PATH = '/mnt/sd/DCIM';
my $PATHLENGTH = length $PATH;
my $FINDCMD = "find $PATH -type f";
# curl command and URL to send to
my $CURL = 'curl --user-agent \'WiFISD Uploader\' --cacert /mnt/sd/.wifisd/ca/SomeRootCert.pem --user user:pass';
my $URL = 'https://upload.somedomain.com/tscardupload/';
# keep track of files already sent
my %DONEFILES;
# find files available to upload
sub findfiles {
my ( $files ) = @_;
open my $find, '-|', $FINDCMD or die "FATAL - can't run find: $!\n";
while ( defined ( my $line = <$find> ) ) {
chomp $line;
substr ( $line, 0, $PATHLENGTH, '' );
$line =~ s/^\/+//;
push @$files, $line;
}
close $find;
}
# verify file is uploaded
sub checkfile {
my ( $file ) = @_;
my $fileesc = $file;
$fileesc =~ s/\\/\\\\/g;
$fileesc =~ s/`/\\`/g;
$fileesc =~ s/\$/\\\$/g;
$fileesc =~ s/"/\\"/g;
my $fullpath = "$PATH/$file";
open my $curl, '-|', "$CURL --silent --form time=".(stat $fullpath)[9]." --form size=".(-s $fullpath)." --form verifypath=\"$fileesc\" $URL"
or return 0;
my $result = <$curl>;
if ( ! defined($result) ) { return 0; }
chomp $result;
close $curl;
if ( $result eq 'OK' ) {
return 1;
}
return 0;
}
# upload a file
sub upload {
my ( $file ) = @_;
my $fullpath = "$PATH/$file";
my $fullpathesc = $fullpath;
$fullpathesc =~ s/\\/\\\\/g;
$fullpathesc =~ s/`/\\`/g;
$fullpathesc =~ s/\$/\\\$/g;
$fullpathesc =~ s/"/\\"/g;
my $fileesc = $file;
$fileesc =~ s/\\/\\\\/g;
$fileesc =~ s/`/\\`/g;
$fileesc =~ s/\$/\\\$/g;
$fileesc =~ s/"/\\"/g;
my $start = time();
system ( "$CURL --form time=".(stat $fullpath)[9]." --form size=".(-s $fullpath)." --form filepath=\"$fileesc\" --form uploadfile=\"\@$fullpathesc;type=application/octet-stream\" $URL" );
my $elapsed = time() - $start;
if ( $elapsed == 0 ) { return; }
my $rate = (-s $fullpath) / $elapsed;
print "$rate B/s\n";
}
# signal handler - exit cleanly
my $run = 1;
sub exitclean {
warn "got signal - exiting\n";
$run = 0;
}
# signal handler - doesn't seem to work TODO
$SIG{'TERM'} = 'exitclean';
$SIG{'QUIT'} = 'exitclean';
$SIG{'INT'} = 'exitclean';
$SIG{'HUP'} = 'exitclean';
# wait for crypto lib available
while ( ! -f '/mnt/mtd/libcrypto.so.0.9.8.bz2' ) { sleep 1; }
# do initial scan of all files
my @files;
system ( 'sh /usr/bin/refresh_sd' );
findfiles ( \@files );
foreach my $file (@files) {
if ( checkfile ( $file ) ) {
$DONEFILES{$file} = 1;
}
}
# loop checking files
while ( $run ) {
# get file list
undef @files;
system ( 'sh /usr/bin/refresh_sd' );
findfiles ( \@files );
foreach my $file (@files) {
if ( $DONEFILES{$file} ) { next; }
upload ( $file );
if ( checkfile ( $file ) ) {
$DONEFILES{$file} = 1;
}
}
# clean removed files
foreach my $file (keys %DONEFILES) {
if ( ! -f "$PATH/$file" ) {
delete $DONEFILES{$file};
}
}
# delay before next try
sleep $LOOPDELAY;
}

BIN
.wifisd/busybox-armv5l Normal file

Binary file not shown.

View File

@ -0,0 +1,429 @@
#!/usr/bin/perl
# license: GPL V2
# (c)2014 rudi, forum.chdk-treff.de
use URI::Escape;
my $unzip = "/usr/bin/unzip";
my $srcfolder = "/tmp/";
my $mainhtml = "/chdk.html";
my $form;
my $qsChdkZip; #querystring filename
my $qsChdkZipSize; #querystring filesize
my $qsChdkFileCount = 0; #querystring file count
my $qsTime = 0; #time for set server time
my $chdkZip; #full path filename
my $chdkFileCount = 0; #checkZipContent file count
my $chdkUPsize = 0; #unpacked size of chdk files
my $fullChdk = 0; #zip type
my $updTime = 0; #time need update
my $langDE = ($ENV{'HTTP_ACCEPT_LANGUAGE'} =~ /^de/)?1:0; #user language german from HTTP_ACCEPT_LANGUAGE
my $htmlTitle = (!$langDE)?"install CHDK":"CHDK einrichten";
my $htmlCheckErr;
sub isSvrTime {
my (undef, $min, $hour, $day, $mon, $year) = localtime();
$year = $year+1900;
$mon = $mon+1;
$mon = ($mon > 9)?$mon:"0".$mon;
$day = ($day > 9)?$day:"0".$day;
$hour = ($hour > 9)?$hour:"0".$hour;
$min = ($min > 9)?$min:"0".$min;
my $svrTime = "$year$mon$day$hour$min";
$updTime = ($qsTime > $svrTime)?1:0;
}
sub setSvrTime {
if ($updTime) { `date -s $qsTime`; }
}
sub checkZipContent {
my $fn;
my $us = 0;
my @res = `unzip -l $chdkZip`;
my $res = 0;
my $fDiskboot = 0;
my $dModules = 0;
foreach $line (@res) {
if ($line =~ /(\d+) \d\d-\d\d-\d\d \d\d:\d\d ([\w+\/]*[\w\-]+\.\w\w\w)/) {
$fn = $2;
$us +=$1;
if ($fn =~ /^CHDK\//) {
#dir exist
if ($fn =~ /^CHDK\/MODULES\//) { $dModules += 1; } else { $fullChdk = 1; }
} else {
#not chdk dir => root dir
if ($fn =~ /\//) { $res = 0; last; } # '/' in line
if ($fn =~ /^DISKBOOT.BIN$/) { $fDiskboot += 1; }
}
$res += 1;
}
}
if ($res == 0 || $fDiskboot != 1 || $dModules == 0) { return 1; }
$chdkFileCount = $res;
$chdkUPsize = $us;
return 0;
}
sub deleteFile {
my $err = system("rm $chdkZip");
if ($err == 0) {
my @text = ("uploaded file deleted", "hochgeladene Datei gelöscht");
print "<li>$text[$langDE]</li>\n";
} else {
my @text = ("Can't delete uploaded file!", "Hochgeledene Datei konnte nicht gelöscht werden!");
print "<li>$text[$langDE]</li>\n";
}
return ($err)?1:0;
}
sub refreshSD {
my $duration = shift @_;
my @text = (
["synchronize files, need approximate %d seconds time ...", "synchronisiere Dateien, dauert etwa %d Sekunden ..."],
["... completed", "... abgeschlossen"],
["synchronize failed!", "Synchronisation fehlgeschlagen!"]
);
if ($duration > 1) { printf "<li>$text[0][$langDE]</li>\n", $duration+1; } #add time for sync
my $err = system("sync") ||
system("sleep $duration") ||
system("sync") ||
system("mount -o remount /mnt/sd");
if ($duration > 1) { print "<li>$text[1][$langDE]</li>\n"; }
if ($err) { print "<li class=\"error\" style=\"margin: 0px;\">$text[2][$langDE]</li>\n"; }
return ($err)?1:0;
}
sub checkChdkZip {
if ($abort != 0) {
$htmlCheckErr = (!$langDE)?"Installation canceled!":"Einrichtung abgebrochen!";
return 1;
}
if (length($chdkZip) == 0) {
$htmlCheckErr = (!$langDE)?"Missing file name!":"Dateiname fehlt!";
return 1;
}
if ($chdkZip !~ /.zip$/) {
$htmlCheckErr = (!$langDE)?"ZIP file required!":"ZIP-Datei erwartet!";
return 1;
}
if (checkZipContent != 0) {
$htmlCheckErr = (!$langDE)?"CHDK ZIP file required!":"CHDK-ZIP-Datei erwartet!";
return 1;
}
return 0;
}
sub processInstall {
my @text = (
["Extract and copy CHDK files, please wait ...", "CHDK-Dateien werden entpackt und kopiert, bitte warten ..."],
["... completed", "... abgeschlossen"],
["Error on copy files!<br>Check filesystem with fsck/chkdsk and try installation again.", "Fehler beim Kopieren!<br>Überprüfe das Dateisystem mit fsck/chkdsk und führe die Einrichtung erneut aus."],
["Copied %d from %d files", "%d von %d Dateien kopiert"],
["Press Button 'OK' and restart the camera!", "Drücke die 'OK'-Schaltfläche und starte die Kamera neu!"]
);
$| = 1; #flush for print
print "<li>$text[0][$langDE]</li>\n";
my $err = refreshSD(1);
if (!$err) {
my @res = `unzip -o $chdkZip -d /mnt/sd/`;
my $res = 0;
foreach $line (@res) {
if ($line =~ /inflating:/) { $res += 1; }
}
if ($qsChdkFileCount == $res) {
print "<li>$text[1][$langDE]</li>\n";
} else {
print "<li class=\"error\" style=\"margin: 0px;\">$text[2][$langDE]</li>\n";
}
printf "<li>$text[3][$langDE]</li>\n", $res, $qsChdkFileCount;
#wait duration for sync
#highest value from data volume, ref=250'000 byte/sec
my $wd = $chdkUPsize/250000;
#or file count, ref=25 files/sec
if ($res/25 > $wd) { $wd = $res/25; }
$err = refreshSD(int($wd)+1); #round up
}
deleteFile;
if (!$err) { print "<li>$text[4][$langDE]</li>\n"; }
return ($err)?1:0;
}
sub qsSplit {
my @nameValuePairs = split (/&/, $queryString);
foreach $nameValue (@nameValuePairs) {
my ($name, $value) = split (/=/, $nameValue);
$value =~ tr/+/ /;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/ pack ("C",hex ($1))/eg;
$form{$name} = $value;
}
}
sub writeChdkFileinfo {
my @text = (
["Update", "Aktualisierung"],
["Complete", "Komplett"],
["CHDK (absent value)", "CHDK (Angabe fehlt)"],
["Uploaded file", "hochgeladene Datei"],
["Name", "Name"],
["Size", "Größe"],
["File content", "Inhalt der Datei"],
["Package", "Paket"],
["Files", "Dateien"],
["Informations from filename", "Informationen aus dem Dateinamen"],
["Type", "Typ"],
["Camera", "Kamera"],
["Version", "Version"],
["Revision", "Revision"]
);
my $package = ($fullChdk == 0)?$text[0][$langDE]:$text[1][$langDE];
my $typ = (!$langDE)?"unknown":"unbekannt";
my $cam = $typ;
my $ver = $typ;
my $rev = $typ;
my $err = 1;
if ($qsChdkZip =~ /^(CHDK\-DE|CHDK_DE|CHDK)?[-_]?([a-z]+\d+[a-z]*_?\w*\-\d\d\d[a-z])\-(\d+\.\d+\.\d+)\-[-_A-Za-z]*(\d+).*\.zip/) {
if ($1) { $typ = $1 }
if ($2) { $cam = $2 }
if ($3) { $ver = $3 }
if ($4) { $rev = $4 }
if (!$1 && $2 && $3 && $4) { $typ = $text[2][$langDE] }
$err = 0;
}
print "<div class=\"hint\">\n";
if($qsChdkZipSize > 0) {
print "<table class=\"fileinfo\">\n";
print "<caption>$text[3][$langDE]</caption>\n";
print "<tr><th scope=\"row\">$text[4][$langDE]:</th><td>$qsChdkZip</td></tr>\n";
print "<tr><th scope=\"row\">$text[5][$langDE]:</th><td>$qsChdkZipSize Byte</td></tr>\n";
print "</table>\n";
}
print "<table class=\"fileinfo\">\n";
print "<caption>$text[6][$langDE]</caption>\n";
print "<tr><th scope=\"row\">$text[7][$langDE]:</th><td>$package</td></tr>\n";
print "<tr><th scope=\"row\">$text[8][$langDE]:</th><td>$chdkFileCount</td></tr>\n";
print "<tr><th scope=\"row\">$text[5][$langDE]:</th><td>$chdkUPsize Byte</td></tr>\n";
print "</table>\n";
print "<table class=\"fileinfo\">\n";
print "<caption>$text[9][$langDE]</caption>\n";
print "<tr><th scope=\"row\">$text[10][$langDE]:</th><td>$typ</td></tr>\n";
print "<tr><th scope=\"row\">$text[11][$langDE]:</th><td>$cam</td></tr>\n";
print "<tr><th scope=\"row\">$text[12][$langDE]:</th><td>$ver</td></tr>\n";
print "<tr><th scope=\"row\">$text[13][$langDE]:</th><td>$rev</td></tr>\n";
print "</table>\n";
print "</div>\n";
return $err;
}
#POST required
if($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $queryString, $ENV{'CONTENT_LENGTH'});
qsSplit;
}
if (length($form{fn}) > 0) {
$qsChdkZip = $form{fn};
$chdkZip = $srcfolder.$qsChdkZip;
}
if (length($form{fc}) > 0) { $qsChdkFileCount = $form{fc}; }
if (length($form{fs}) > 0) { $qsChdkZipSize = $form{fs}; }
if (length($form{time}) > 0) { $qsTime = $form{time}; }
if (length($form{utime}) > 0) { $updTime = $form{utime}; }
if (length($form{abort}) > 0) { $abort = $form{abort}; }
if (checkChdkZip == 0) {
$htmlTitle = ($qsChdkFileCount == $chdkFileCount)?"$htmlTitle : 2":"$htmlTitle : 1";
}
# HTML HEADER BEGIN
print "Content-type: text/html\n\n";
print "<!DOCTYPE html>\n";
print "<html>\n";
print "<head>\n";
print "<title>$htmlTitle</title>\n";
print "<style type=\"text/css\">\n";
print "body {\n";
print " font-family: Arial, sans-serif;\n";
print " background-color: #004488;\n";
print " min-width: 600px;\n";
print " margin: 5px 0px;\n";
print " padding: 5px;\n";
print "}\n";
print "h1 {\n";
print " color: #ffffff;\n";
print " font-size: 20px;\n";
print " margin: 0px 40px;\n";
print "}\n";
print "form {\n";
print " margin: 10px;\n";
print "}\n";
print "a {\n";
print " color: #ffffff;\n";
print " font-size: 11px;\n";
print " text-decoration: none;\n";
print "}\n";
print "a:hover {\n";
print " text-decoration: underline;\n";
print "}\n";
print "table {\n";
print " width: 100%;\n";
print " border: 1px dotted;\n";
print " margin: 0px 0px 10px;\n";
print "}\n";
print "table caption{\n";
print " background-color: #eeeeee;\n";
print " padding: 2px 10px;\n";
print " text-align: left;\n";
print " text-transform: uppercase;\n";
print "}\n";
print "table th {\n";
print " width: 100px;\n";
print " text-align: right;\n";
print "}\n";
print ".article {\n";
print " background-color: #ffffff;\n";
print " margin: 10px;\n";
print " padding: 10px;\n";
print " padding-top: 4px;\n";
print " font-size: 14px;\n";
print "}\n";
print ".article hr{\n";
print " color: #000000;\n";
print " background-color: #000000;\n";
print " height: 1px;\n";
print " border: 0px;\n";
print "}\n";
print ".article fieldset{\n";
print " border: 1px solid;\n";
print "}\n";
print ".article legend{\n";
print " font-weight: 400;\n";
print " text-transform: uppercase;\n";
print "}\n";
print ".dir{\n";
print " font-family: monospace;\n";
print "}\n";
print ".hint{\n";
print " margin: 0px 14px;\n";
print " font-size: 12px;\n";
print "}\n";
print ".footer {\n";
print " color: #ffffff;\n";
print " font-size: 11px;\n";
print " margin: 3px 40px;\n";
print " float: left;\n";
print "}\n";
print ".version {\n";
print " color: #ffffff;\n";
print " font-size: 11px;\n";
print " margin: 3px 40px;\n";
print " float: right;\n";
print "}\n";
print ".fileinput {\n";
print " font-size: 14px;\n";
print " width: 370px;\n";
print " height: 26px;\n";
print " background-color: #ffffff;\n";
print " border: 1px dotted #004488;\n";
print "}\n";
print ".submit {\n";
print " margin-left: 20px;\n";
print " font-size: 14px;\n";
print " width: 120px;\n";
print " height: 26px;\n";
print " background-color: #ffffff;\n";
print " border: 1px solid #004488;\n";
print "}\n";
print ".error {\n";
print " color: #ff0000;\n";
print " font-weight: bold;\n";
print " margin: 0px 20px;\n";
print "}\n";
print "</style>\n";
print "</head>\n";
print "<body>\n";
print " <h1>$htmlTitle</h1>\n";
print " <div class=\"article\">\n";
print " <section>\n";
print " <fieldset>\n";
#HTML HEADER END
if (checkChdkZip == 0) {
if ($qsChdkFileCount == $chdkFileCount) {
#step 2: install
my @text = (
["Step 2 - Copy files", "Schritt 2 - CHDK-Dateien kopieren"],
["Current server time", "Aktuelle Serverzeit"],
["Unsafe filename!", "Unsicherer Dateiname!"],
["Step 2 completed", "Schritt 2 abgeschlossen"],
["Error on step 2", "Fehler im Schritt 2"]
);
print "<legend>$text[0][$langDE]</legend>\n";
my $pi = writeChdkFileinfo;
print "<hr>\n";
print "<ul>\n";
if ($updTime == 1) {
my $lt = localtime;
print "<li>$text[1][$langDE]: $lt</li>\n";
}
if ($pi) { print "<li class=\"error\" style=\"margin: 0px;\">$text[2][$langDE]</li>\n"; }
$pi = processInstall;
print "</ul>\n";
print "<hr>\n";
print "<form action=$mainhtml>\n";
print "<span>$text[3+$pi][$langDE]</span>\n";
print "<input type=submit value=\"OK\" class=\"submit\">\n";
print "</form>\n";
} else {
#step 1: check
my @text = (
["Step 1 completed", "Schritt 1 abgeschlossen"],
["Unsafe filename!", "Unsicherer Dateiname!"],
["Step 2 - Copy files", "Schritt 2 - CHDK-Dateien kopieren"],
["Cancel", "Abbrechen"],
["Next", "Weiter"]
);
$| = 1; #flush for print
isSvrTime;
print "<legend>$text[0][$langDE]</legend>";
my $fi = writeChdkFileinfo;
print "<hr>\n";
print "<form name=\"_f\" action=\"/cgi-bin/chdk_install.cgi\" method=\"post\">\n";
print "<input type=\"hidden\" name=\"fn\" value=\"$qsChdkZip\">\n";
print "<input type=\"hidden\" name=\"fc\" value=\"$chdkFileCount\">\n";
print "<input type=\"hidden\" name=\"utime\" value=\"$updTime\">\n";
print "<input type=\"hidden\" name=\"abort\" value=\"0\">\n";
if ($fi) { print "<div class=\"error\">$text[1][$langDE]</div>" }
print "<span>$text[2][$langDE]</span>\n";
print "<input type=\"button\" value=\"$text[3][$langDE]\" class=\"submit\" onclick=\"document.forms._f.abort.value = '1'; document.forms._f.submit()\">\n";
print "<input type=\"submit\" value=\"$text[4][$langDE]\" class=\"submit\">\n";
print "</form>\n";
}
} else {
my @text = (
["Error", "Fehler"],
["", ""]
);
#check error
print "<legend>$text[0][$langDE]</legend>\n";
print "<p class=\"error\">$htmlCheckErr</p>\n";
print "<ul>\n";
deleteFile;
print "</ul>\n";
print "<hr>\n";
print "<form action=$mainhtml>\n";
print "<span>$text[1][$langDE]</span>\n";
print "<input type=\"submit\" value=\"OK\" class=\"submit\">\n";
print "</form>\n";
}
# HTML FOOTER BEGIN
print " </fieldset>\n";
print " </section>\n";
print " </div>\n";
print " <div class=\"footer\">(C)2014 rudi, <a target=\"_blank\" href=\"http://forum.chdk-treff.de/viewtopic.php?t=3287\">forum.chdk-treff.de</a></div>\n";
print " <div class=\"version\">chdk_install.cgi: v1.6</div>\n";
print "</body>\n";
print "</html>\n";
# HTML FOOTER END
#! push to end of script
# webserver output fails with set date on execute cgi
# at first time after boot
setSvrTime;

324
.wifisd/chdk/chdk.html Normal file
View File

@ -0,0 +1,324 @@
<!DOCTYPE html>
<html>
<head>
<title>WIFISD CHDK Add-on</title>
<style type="text/css">
body {
font-family: Arial, sans-serif;
background-color: #004488;
min-width: 600px;
margin: 5px 0px;
padding: 5px;
}
h1 {
color: #ffffff;
font-size: 20px;
margin: 0px 40px;
}
form {
margin: 10px;
clear: both;
}
a {
color: #ffffff;
font-size: 11px;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.article {
background-color: #ffffff;
margin: 10px;
padding: 10px;
padding-top: 4px;
font-size: 14px;
}
.article hr{
color: #000000;
background-color: #000000;
height: 1px;
border: 0px;
}
.article fieldset{
border: 1px solid;
}
.article legend{
font-weight: 400;
text-transform: uppercase;
}
.dir{
font-family: monospace;
}
.hint{
margin: 0px 14px;
font-size: 12px;
}
.footer {
color: #ffffff;
font-size: 11px;
margin: 3px 40px;
float: left;
}
.version {
color: #ffffff;
font-size: 11px;
margin: 3px 40px;
float: right;
}
.fileinput {
font-size: 14px;
width: 370px;
height: 26px;
background-color: #ffffff;
border: 1px dotted #004488;
}
.submit {
margin-left: 20px;
position: absolute;
font-size: 14px;
width: 120px;
height: 26px;
background-color: #ffffff;
border: 1px solid #004488;
}
.error {
color: #ff0000;
font-weight: bold;
margin: 0px 20px;
}
#script {
display: none;
}
#noscript {
display: block;
}
</style>
<script type="text/javascript">
var fn = "<insert lastfilename>";
var fs = "<insert bytecount>";
var em = "<insert MESSAGE>";
var _GET = new Array();
var _GETcount = 0;
var langDE = (navigator.language.indexOf("de") >= 0);
var canSubmit = true;
var params = unescape(location.search.substring(1, location.search.length)).split("&");
for(var i=0; i < params.length; i++) {
param = params[i].split("=");
_GET[param[0]] = param[1];
if (param[0]) { _GETcount+=1; }
}
function isUploadBad() {
return (em.substr(0,1) != "<");
}
function isUploadGood() {
return (fn.substr(0,1) != "<") && (fs.substr(0,1) != "<");
}
function isUploadEnd() {
return (isUploadBad() || isUploadGood());
}
function formatGetVals() {
var res = "?p="+_GET.p;//location.search;
if (isUploadBad()) {
res += "&res=bad&em="+em;
} else {
if (isUploadGood()) { res += "&res=good&fn="+fn+"&fs="+fs; }
}
return res;
}
function currTime() {
var now = new Date();
var Y = now.getFullYear();
var M = now.getMonth()+1;
var D = now.getDate();
var h = now.getHours();
var m = now.getMinutes();
M = ((M < 10)? "0"+M:M);
D = ((D < 10)? "0"+D:D);
h = ((h < 10)? "0"+h:h);
m = ((m < 10)? "0"+m:m);
return Y+M+D+h+m;
}
function writeResult(id, text, iserr) {
var node = document.getElementById(id);
node.innerHTML = text;
node.style.color = (iserr)?"red":"green";
setTimeout(function() { node.innerHTML = ""; }, 10000);
}
function writeUploadResult() {
var _text1 = (langDE)? "hochgeladene Datei: ":"uploaded file: "
var _text2 = (langDE)? "Byte":"byte"
var _text3 = (langDE)? "Fehler beim Hochladen: ":"upload error: "
writeResult(_GET.p, (_GET.res=="good")? _text1+_GET.fn+" ["+_GET.fs+" "+_text2+"]":_text3+_GET.em, (_GET.res == "good")?0:1);
}
function checkFileExt(tfile, extlist, idErr) {
var name = tfile.value;
if (name.length > 0) {
var res = 0;
var ldp = name.lastIndexOf(".") + 1;
if (extlist.length > 0 && ldp > 1 && (name.length-ldp) > 1) {
var ext = name.substr(ldp);
for (i in extlist) {
if (extlist[i] == ext) { res = 1; break; }
}
}
if (res == 0) {
tfile.value = "";
var msg = (langDE)?"Gültige Dateiendung":"Valid file extension";
var pl = "";
if (extlist.length > 1) { pl = (langDE)?"en":"s"; }
writeResult(idErr, msg+pl+": "+extlist, 1);
}
}
}
function btnSubmit(formID, errID) {
var _text = (langDE)?"Es wird bereits eine Datei hochgeladen!":"There is a file upload already in process!"
if (canSubmit) {
if (formID.file1.value.length == 0) {
_text = (langDE)?"Keine Datei ausgewählt!":"No file selected!";
} else {
canSubmit = false;
return true;
}
}
writeResult(errID, _text, true);
return false;
}
function myload() {
//is upload finished?
if (isUploadEnd()) {
if (_GET.p == "/tmp/" && isUploadGood()) {
//redirect to step 2
var dfs2 = document.forms.step2;
dfs2.fn.value = fn;
dfs2.fs.value = fs;
dfs2.time.value = currTime();
dfs2.submit();
} else {
//redirect with get
var ref = document.referrer;
var i = ref.indexOf("?");
if (i > 0) { ref = ref.substring(0,i); }
location.replace(ref+formatGetVals());
}
} else {
//is redirected to main html?
if (_GETcount > 0) { writeUploadResult(); }
document.getElementById("script").style.display = "block";
}
}
function toLangDE() {
document.title = "WIFISD-CHDK-Erweiterung";
document.getElementById("_title").innerHTML = document.title;
document.getElementById("_leg1").innerHTML = "Skript hochladen";
document.getElementById("_hint1").innerHTML = "Kopiert ein Skript nach <span class=\"dir\">/CHDK/SCRIPTS/</span>";
document.getElementById("_cap1").innerHTML = "Skript auswählen";
document.forms._f1._b1.value = "Hochladen";
document.getElementById("_leg2").innerHTML = "Bibliothek hochladen";
document.getElementById("_hint2").innerHTML = "Kopiert eine LUA-Bibliothek nach <span class=\"dir\">/CHDK/LUALIB/</span>";
document.getElementById("_cap2").innerHTML = "Bibliothek auswählen";
document.forms._f2._b2.value = "Hochladen";
document.getElementById("_leg3").innerHTML = "CHDK einrichten";
document.getElementById("_hint3").innerHTML = "Kopiert die CHDK-Dateien aus einer CHDK-ZIP-Datei. Komplett- oder Aktualisierungsdateien sind zulässig.<p>Das Einrichten erfolgt in 2 Schritten:<ol><li>ZIP-Datei hochladen (dauert etwa 30 Sekunden)</li><li>Dateien kopieren</li></ol></p>";
document.getElementById("_cap3").innerHTML = "CHDK-ZIP-Datei auswählen";
document.forms._f3._b3.value = "Hochladen";
}
window.onload = function () {
myload();
if (langDE) { toLangDE(); }
document.getElementById("noscript").style.display = "none";
};
</script>
</head>
<body>
<h1 id="_title">WIFISD CHDK Add-on</h1>
<div id="script">
<div class="article">
<section>
<fieldset>
<legend id="_leg1">Script upload</legend>
<div class="hint" id="_hint1">Copies a script to <span class="dir">/CHDK/SCRIPTS/</span></div>
<hr>
<form name="_f1" action="/cgi-bin/uploadto?p=/mnt/sd/CHDK/SCRIPTS/" method="post" enctype="multipart/form-data">
<div id="/mnt/sd/CHDK/SCRIPTS/"></div>
<input type="hidden" name="OkPage" value="../chdk.html">
<input type="hidden" name="BadPage" value="../chdk.html">
<div id="_cap1">Select script</div>
<input type="file" name="file1" class="fileinput" onchange='checkFileExt(this, ["lua","bas"], "/mnt/sd/CHDK/SCRIPTS/");'>
<input type="submit" value="Upload" name="_b1" class="submit" onclick='return btnSubmit(_f1, "/mnt/sd/CHDK/SCRIPTS/");'>
</form>
</fieldset>
</section>
</div>
<div class="article">
<section>
<fieldset>
<legend id="_leg2">Library upload</legend>
<div class="hint" id="_hint2">Copies a lua library to <span class="dir">/CHDK/LUALIB/</span></div>
<hr>
<form name="_f2" action="/cgi-bin/uploadto?p=/mnt/sd/CHDK/LUALIB/" method="post" enctype="multipart/form-data">
<div id="/mnt/sd/CHDK/LUALIB/"></div>
<input type="hidden" name="OkPage" value="../chdk.html">
<input type="hidden" name="BadPage" value="../chdk.html">
<div id="_cap2">Select library</div>
<input type="file" name="file1" class="fileinput" onchange='checkFileExt(this, ["lua"], "/mnt/sd/CHDK/LUALIB/");'>
<input type="submit" value="Upload" name="_b2" class="submit" onclick='return btnSubmit(_f2, "/mnt/sd/CHDK/LUALIB/");'>
</form>
</fieldset>
</section>
</div>
<div class="article">
<section>
<fieldset>
<legend id="_leg3">install CHDK</legend>
<div class="hint" id="_hint3">Copy CHDK files from CHDK ZIP file. Accept complete or update packages.
<p>Two steps to install:
<ol>
<li>upload ZIP file (need approximate 30 seconds time)</li>
<li>copy files</li>
</ol>
</p>
</div>
<hr>
<form name="_f3" action="/cgi-bin/uploadto?p=/tmp/" method="post" enctype="multipart/form-data">
<div id="/tmp/"></div>
<input type="hidden" name="OkPage" value="../chdk.html">
<input type="hidden" name="BadPage" value="../chdk.html">
<div id="_cap3">Select CHDK ZIP file</div>
<input type="file" name="file1" class="fileinput" onchange='checkFileExt(this, ["zip"], "/tmp/");'>
<input type="submit" value="Upload" name="_b3" class="submit" onclick='return btnSubmit(_f3, "/tmp/");'>
</form>
</fieldset>
</section>
</div>
</div>
<div class="article" id="noscript">
<section>
<fieldset>
<legend>Error / Fehler</legend>
<p class="error">Javascript is requiered! / Javascript erforderlich!</p>
</fieldset>
</section>
</div>
<div class="footer">&copy;2014 rudi, <a target="_blank" href="http://forum.chdk-treff.de/viewtopic.php?t=3287">forum.chdk-treff.de</a></div>
<div class="version">chdk.html: v1.5</div>
<form name="step2" action="/cgi-bin/chdk_install.cgi" method="post">
<input type="hidden" name="fn" value="">
<input type="hidden" name="fs" value="">
<input type="hidden" name="time" value="0">
</form>
</body>
</html>

287
.wifisd/chdk/webdev.html Normal file
View File

@ -0,0 +1,287 @@
<!DOCTYPE html>
<html>
<head>
<title>WIFISD Webserver Development</title>
<style type="text/css">
body {
font-family: Arial, sans-serif;
background-color: #004488;
min-width: 600px;
margin: 5px 0px;
padding: 5px;
}
h1 {
color: #ffffff;
font-size: 20px;
margin: 0px 40px;
}
form {
margin: 10px;
}
a {
color: #ffffff;
font-size: 11px;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.article {
background-color: #ffffff;
margin: 10px;
padding: 10px;
padding-top: 4px;
font-size: 14px;
}
.article hr{
color: #000000;
background-color: #000000;
height: 1px;
border: 0px;
}
.article fieldset{
border: 1px solid;
}
.article legend{
font-weight: 400;
text-transform: uppercase;
}
.dir{
font-family: monospace;
}
.hint{
margin: 0px 14px;
font-size: 12px;
}
.footer {
color: #ffffff;
font-size: 11px;
margin: 3px 40px;
float: left;
}
.version {
color: #ffffff;
font-size: 11px;
margin: 3px 40px;
float: right;
}
.fileinput {
font-size: 14px;
width: 370px;
height: 26px;
background-color: #ffffff;
border: 1px dotted #004488;
}
.submit {
margin-left: 20px;
position: absolute;
font-size: 14px;
width: 120px;
height: 26px;
background-color: #ffffff;
border: 1px solid #004488;
}
.error {
color: #ff0000;
font-weight: bold;
margin: 0px 20px;
}
#script {
display: none;
}
#noscript {
display: block;
}
</style>
<script type="text/javascript">
var fn = "<insert lastfilename>";
var fs = "<insert bytecount>";
var em = "<insert MESSAGE>";
var _GET = new Array();
var _GETcount = 0;
var langDE = (navigator.language.indexOf("de") >= 0);
var canSubmit = true;
var params = unescape(location.search.substring(1, location.search.length)).split("&");
for(var i=0; i < params.length; i++) {
param = params[i].split("=");
_GET[param[0]] = param[1];
if (param[0]) { _GETcount += 1; }
}
function isUploadBad() {
return (em.substr(0,1) != "<");
}
function isUploadGood() {
return (fn.substr(0,1) != "<") && (fs.substr(0,1) != "<");
}
function isUploadEnd() {
return (isUploadBad() || isUploadGood());
}
function formatGetVals() {
var res = "?p="+_GET.p;//location.search;
if (isUploadBad()) {
res += "&res=bad&em="+escape(em);
} else {
if (isUploadGood()) { res += "&res=good&fn="+escape(fn)+"&fs="+escape(fs); }
}
return res;
}
function writeResult(id, text, iserr) {
var node = document.getElementById(id);
node.innerHTML = text;
node.style.color = (iserr)?"red":"green";
setTimeout(function() { node.innerHTML = ""; }, 10000);
}
function writeUploadResult() {
var _text1 = (langDE)?"hochgeladene Datei: ":"uploaded file: "
var _text2 = (langDE)?"Byte":"byte"
var _text3 = (langDE)?"Fehler beim Hochladen: ":"upload error: "
writeResult(_GET.p, (_GET.res=="good")? _text1+_GET.fn+" ["+_GET.fs+" "+_text2+"]":_text3+_GET.em, (_GET.res == "good")?0:1);
}
function checkFileExt(tfile, extlist, idErr) {
var name = tfile.value;
if (name.length > 0) {
var res = 0;
var ldp = name.lastIndexOf(".") + 1;
if (extlist.length > 0 && ldp > 1 && (name.length-ldp) > 1) {
var ext = name.substr(ldp);
for (i in extlist) {
if (extlist[i] == ext) { res = 1; break; }
}
}
if (res == 0) {
tfile.value = "";
var msg = (langDE)?"Gültige Dateiendung":"Valid file extension";
var pl = "";
if (extlist.length > 1) { pl = (langDE)?"en":"s"; }
writeResult(idErr, msg+pl+": "+extlist, 1);
}
}
}
function btnSubmit(formID, errID) {
var _text = (langDE)?"Es wird bereits eine Datei hochgeladen!":"There is a file upload already in process!"
if (canSubmit) {
if (formID.file1.value.length == 0) {
_text = (langDE)?"Keine Datei ausgewählt!":"No file selected!";
} else {
canSubmit = false;
return true;
}
}
writeResult(errID, _text, true);
return false;
}
function myload() {
//is upload finished?
if (isUploadEnd()) {
//redirect with get
var ref = document.referrer;
var i = ref.indexOf("?");
if (i > 0) { ref = ref.substring(0, i); }
location.replace(ref + formatGetVals());
} else {
//is redirected to main html?
if (_GETcount > 0) { writeUploadResult(); }
document.getElementById("script").style.display = "block";
}
}
function toLangDE() {
document.title = "WIFISD-Webserver-Entwicklung";
document.getElementById("_title").innerHTML = document.title;
document.getElementById("_leg1").innerHTML = "Ziel: Server";
document.getElementById("_hint1").innerHTML = "Kopiert die Datei in das Arbeitserzeichnis des Webservers. Gültig bis zum Auschalten der Kamera.";
document.getElementById("_cap1a").innerHTML = "Verzeichnis <span class=\"dir\">/www/</span>";
document.forms._f1a._b1a.value="Hochladen";
document.getElementById("_cap1b").innerHTML = "Verzeichnis <span class=\"dir\">/www/cgi-bin/</span>";
document.forms._f1b._b1b.value="Hochladen";
document.getElementById("_leg2").innerHTML = "Ziel: SD-Karte";
document.getElementById("_hint2").innerHTML = "Kopiert die Datei auf die SD-Karte in das Verzeichnis für <span class=\"dir\">autorun.sh</span>.";
document.getElementById("_cap2a").innerHTML = "Verzeichnis <span class=\"dir\">/www/</span>";
document.forms._f2a._b2a.value="Hochladen";
document.getElementById("_cap2b").innerHTML = "Verzeichnis <span class=\"dir\">/www/cgi-bin/</span>";
document.forms._f2b._b2b.value="Hochladen";
}
window.onload = function () {
myload();
if (langDE) { toLangDE(); }
document.getElementById("noscript").style.display = "none";
}
</script>
</head>
<body>
<h1 id="_title">WIFISD Webserver Development</h1>
<div id="script">
<div class="article">
<section>
<fieldset>
<legend id="_leg1">destination: server</legend>
<div class="hint" id="_hint1">Copies the file to working directory on server. Available until switching of the camera.</div>
<hr>
<form name="_f1a" action="/cgi-bin/uploadto?p=/www/" method="post" enctype="multipart/form-data">
<div id="/www/"></div>
<input type="hidden" name="OkPage" value="../webdev.html">
<input type="hidden" name="BadPage" value="../webdev.html">
<div id="_cap1a">Directory <span class="dir">/www/</span></div>
<input type="file" name="file1" class="fileinput" onchange='checkFileExt(this, ["htm","html"], "/www/");'>
<input type="submit" value="Upload" name="_b1a" class="submit" onclick='return btnSubmit(_f1a, "/www/");'>
</form>
<form name="_f1b" action="/cgi-bin/uploadto?p=/www/cgi-bin/" method="post" enctype="multipart/form-data">
<div id="/www/cgi-bin/"></div>
<input type="hidden" name="OkPage" value="../webdev.html">
<input type="hidden" name="BadPage" value="../webdev.html">
<div id="_cap1b">Directory <span class="dir">/www/cgi-bin/</span></div>
<input type="file" name="file1" class="fileinput" onchange='checkFileExt(this, ["cgi","pl"], "/www/cgi-bin/");'>
<input type="submit" value="Upload" name="_b1b" class="submit" onclick='return btnSubmit(_f1b, "/www/cgi-bin/");'>
</form>
</fieldset>
</section>
</div>
<div class="article">
<section>
<fieldset>
<legend id="_leg2">destination: sd card</legend>
<div class="hint" id="_hint2">Copies the file to sd card for <span class="dir">autorun.sh</span>.</div>
<hr>
<form name="_f2a" action="/cgi-bin/uploadto?p=/mnt/sd/WIFISD/www/" method="post" enctype="multipart/form-data">
<div id="/mnt/sd/WIFISD/www/"></div>
<input type="hidden" name="OkPage" value="../webdev.html">
<input type="hidden" name="BadPage" value="../webdev.html">
<div id="_cap2a">Directory <span class="dir">/www/</span></div>
<input type="file" name="file1" class="fileinput" onchange='checkFileExt(this, ["htm","html"], "/mnt/sd/WIFISD/www/");'>
<input type="submit" value="Upload" name="_b2a" class="submit" onclick='return btnSubmit(_f2a, "/mnt/sd/WIFISD/www/");'>
</form>
<form name="_f2b" action="/cgi-bin/uploadto?p=/mnt/sd/WIFISD/www/cgi-bin/" method="post" enctype="multipart/form-data">
<div id="/mnt/sd/WIFISD/www/cgi-bin/"></div>
<input type="hidden" name="OkPage" value="../webdev.html">
<input type="hidden" name="BadPage" value="../webdev.html">
<div id="_cap2b">Directory <span class="dir">/www/cgi-bin/</span></div>
<input type="file" name="file1" class="fileinput" onchange='checkFileExt(this, ["cgi","pl"], "/mnt/sd/WIFISD/www/cgi-bin/");'>
<input type="submit" value="Upload" name="_b2b" class="submit" onclick='return btnSubmit(_f2b, "/mnt/sd/WIFISD/www/cgi-bin/");'>
</form>
</fieldset>
</section>
</div>
</div>
<div class="article" id="noscript">
<section>
<fieldset>
<legend>Error / Fehler</legend>
<p class="error">Javascript is requiered! / Javascript erforderlich!</p>
</fieldset>
</section>
</div>
<div class="footer">&copy;2014 rudi, <a target="_blank" href="http://forum.chdk-treff.de/viewtopic.php?t=3287">forum.chdk-treff.de</a></div>
<div class="version">webdev.html: v1.3</div>
</body>
</html>

View File

@ -0,0 +1,4 @@
#!/bin/sh
# based on http://haxit.blogspot.ch/2013/08/hacking-transcend-wifi-sd-cards.html
cp /mnt/sd/.wifisd/busybox-armv5l /bin/busybox-extra
chmod a+x /bin/busybox-extra

3
.wifisd/init.d/05ntpd.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
# add custom dhcp code (ntpd & local access)
cat /mnt/sd/.wifisd/ntpd.sh >>/etc/dhcp.script

View File

@ -0,0 +1,3 @@
#!/bin/sh
# add custom dhcp code (ntpd & local access)
cat /mnt/sd/.wifisd/access.sh >>/etc/dhcp.script

View File

@ -0,0 +1,4 @@
#!/bin/sh
# safety - change mount to ro
busybox-extra sed -i.orig -e 's/ -w / /' -e 's/-o iocharset/-o ro,iocharset/' /usr/bin/refresh_sd
refresh_sd

13
.wifisd/init.d/20chdk.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/sh
# copy files from specific sd card directory /WIFISD/
# to servers root directory
cp -Rf /mnt/sd/.wifisd/chdk/* /www/
# make scipts executable
chmod a+x /www/cgi-bin/*
# add links to /www/frame1.html (insert before </tbody></table>)
# Schema: <tr><td width="100%"><a href="/..." target="f3">&#8226; Title</a></td></tr>
busybox-extra sed -i.orig1 -e 's/<\/tbody>/<tr><td width="100%"><a href="\/chdk.html" target="f3">\&#8226; CHDK<\/a><\/td><\/tr>\n<\/tbody>/' /www/frame1.html
busybox-extra sed -i.orig2 -e 's/<\/tbody>/<tr><td width="100%"><a href="\/webdev.html" target="f3">\&#8226; WebDev<\/a><\/td><\/tr>\n<\/tbody>/' /www/frame1.html

View File

@ -0,0 +1,4 @@
#!/bin/sh
# install the uploader tool
cp /mnt/sd/.wifisd/autoupload.pl /usr/bin
chmod a+x /usr/bin/autoupload.pl

7
.wifisd/init.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
#telnetd -l /bin/bash &
for SCRIPT in /mnt/sd/.wifisd/init.d/*.sh; do
chmod a+x $SCRIPT
. $SCRIPT
done

15
.wifisd/ntpd.sh Normal file
View File

@ -0,0 +1,15 @@
# https://www.pitt-pladdy.com/blog/_20140202-083815_0000_Transcend_Wi-Fi_SD_Hacks_CF_adaptor_telnet_custom_upload_/
# kill existing ntp daemon
[ -f /var/run/ntpd.pid ] && kill `cat /var/run/ntpd.pid`
# try start a new ntp daemon
if [ -n "$ntpsrv" ]; then
ntpcommand="busybox-extra ntpd"
for ntp in $ntpsrv; do
ntpcommand="$ntpcommand -p $ntp"
done
$ntpcommand
else
busybox-extra ntpd -p pool.ntp.org
fi

View File

@ -0,0 +1,2 @@
#!/bin/sh
wget -N http://busybox.net/downloads/binaries/latest/busybox-armv5l

3
autorun.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
chmod a+x /mnt/sd/.wifisd/init.sh
/mnt/sd/.wifisd/init.sh