This would not have been possible without Georg Lukas' work!
-
Always-On wifi
-
Connect the camera to the wifi the regular way (for me only 2.4ghz wifi worked to automatically connect)
-
Find the corresponding settings file in /mnt/ubi1/data/var/lib/connman/*/settings (note down the folder name for the connection you automatically want to connect to)
-
Create the wpa_supplicant.conf file in /mnt/mmc/:
nx300:/mnt/mmc# cat /tmp/wpa_supplicant.conf ctrl_interface=DIR=/var/run/wifi device_name=NX300-CAMERA manufacturer=SAMSUNG model_name=NX300 model_number=RAE011112-00CS serial_number=XXXXXXXXXX config_methods=physical_display virtual_push_button keypad country=NL
-
Append the following to autoexec.sh
# Always on wifi cp /mnt/mmc/wpa_supplicant.conf /tmp/ /usr/bin/wlan.sh start NL 0x8210 >> /mnt/mmc/wifi.log 2>&1 /usr/sbin/connmand -W nl80211 -r /usr/sbin/net-config sleep 2 #dbus-send --system --type=method_call --print-reply --dest=net.connman / net.connman.Manager.GetServices|grep service >> /mnt/mmc/wifi.log 2>&1 dbus-send --system --type=method_call --print-reply --dest=net.connman /net/connman/service/wifi_a0219572b25b_7777772e6c656d6d737465722e6465_managed_psk net.connman.Service.Connect >> /mnt/mmc/wifi.log 2>&1
-
-
FTPd (started via inetd)
-
Make inetd start ftpd automatically by appending the following to autoexec.sh:
# Create inetd config file that activates ftpd echo "21 stream tcp nowait root ftpd /usr/sbin/ftpd /mnt/mmc/DCIM/" > /mnt/mmc/inetd.conf # start inetd (in background) that spawns ftpd on demand /usr/sbin/inetd /mnt/mmc/inetd.conf
-
On a remote host periodically poll (less elegant) for new files (if the camera is on-line). The second line purges the mirrored files from the camera so that they do not get downloaded again if deleted from the backup:
while true; do sleep 5 && ping -q -c 3 nx300 > /dev/null && wget -q -m ftp://nx300/ ; done #(sleep 1; echo -e "cd /mnt/mmc/DCIM/100Photo/ && rm SAM_0158.JPG SAM_0159.JPG";) | nc -q 5 nx300 23
-
If you additionally want to only mirror files that are newer than a sentinel file (e.g. because you might want to be allowed to delete files locally without re-mirroring the file again), run:
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/bin/bash ## ## Mirrors files from the nx300 samsung camera to the local machine. The set of files mirrored is the subset of files newer than the given sentinel. ## ## License see http://unlicense.org/ ## ## mirrorers the files from the camera stored in the 100PHOTO/ folder int the local 100PHOTO/ folder lftp nx300 -e "set ftp:use-feat off; mirror --newer-than=100PHOTO/.sentinel 100PHOTO 100PHOTO; quit" ## Keep the last (newest) mirrored file at a sentinel. ## (Do not just store the name of the file because the original file can be touched (e.g. modified by an image editing program) on the local end cp -a 100PHOTO/`ls -tp 100PHOTO/ | grep -v /$ | head -1` 100PHOTO/.sentinel
-
However, I have found that ftpd/lftpd do not correctly preserve the ctime/mtime/... when transfering the file. Thus, the sentinal approach does not work reliably.
-
-
inotifywait
-
Download following squeeze (oldstable) armel deb packages from packages.debian.org:
-
Extract the data bits of both .deb files with 'ar p notify data.tar.gz | tar zx' and flatten libinotifytools.so.0, libinotifytools.so.0.4.1 inotifywait and inotifywatch from the resulting usr/* to /mnt/mmc
-
Start /mnt/mmc/mirror.sh via /mnt/mmc/autoexec.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/bin/sh ## make sure to find libinotify in current directory LD_LIBRARY_PATH=/mnt/mmc/:$LD_LIBRARY_PATH ## directory to watch for images DIR=/mnt/mmc/DCIM/100PHOTO ## target to ftpput files to TARGET=strawberry ## watch for new files and immediately copy to remote and delete afterwards while F=$(/mnt/mmc/inotifywait -e create $DIR --format %f .) do ( ftpput $TARGET /incoming/$F $DIR/$F && rm $DIR/$F ) & done
-
-
Install vsftpd on a raspberry pi
-
apt-get install vsftpd && mkdir -p /var/ftp/incoming && chown root:root /var/ftp && chown ftp:ftp /var/ftp/incoming
-
Add anon_upload_enable=YES, write_enable=YES, anonymous_enable=YES, anon_root=/var/ftp and anon_umask=022 to /etc/vsftpd and restart vsftpd
-
-
The final autoexe.sh looks like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/bin/sh TARGET=strawberry mkdir -p /dev/pts mount -t devpts none /dev/pts # Start telnet server telnetd -l /bin/bash -F > /mnt/mmc/telnetd.log 2>&1 & # Create inetd config file that activates ftpd echo "21 stream tcp nowait root ftpd /usr/sbin/ftpd /mnt/mmc/DCIM/" > /mnt/mmc/inetd.conf # start inetd (in background) that spawns ftpd on demand /usr/sbin/inetd /mnt/mmc/inetd.conf # automatically start wifi cp /mnt/mmc/wpa_supplicant.conf /tmp/ /usr/bin/wlan.sh start NL 0x8210 /usr/sbin/connmand -W nl80211 -r /usr/sbin/net-config sleep 2 dbus-send --system --type=method_call --print-reply --dest=net.connman /net/connman/service/wifi_a0219572b25b_7777772e6c656d6d737465722e6465_managed_psk net.connman.Service.Connect # start mirror.sh # (TODO: inline the mirror.sh script?) /mnt/mmc/mirror.sh > /mnt/mmc/mirror.log & 2>&1 # copy any file the mirror.sh script might have missed in previous runs for f in /mnt/mmc/DCIM/100PHOTO/*.JPG; do file=`basename $f` && ftpput $TARGET incoming/$file $f && rm $f; done