Compare commits

11 Commits

Author SHA1 Message Date
Dave
2dc965719c fixed if statements 2018-10-11 22:26:51 +01:00
Dave
f7d0bd6558 fixed referencing 2018-10-11 22:15:41 +01:00
Dave
06c7c65420 permsision changes 2018-10-11 19:15:00 +01:00
Dave
56491b7ab0 added in GPIO led functionality 2018-10-11 18:57:23 +01:00
Dave
f13802a62b more LED timing tweaks 2018-10-07 21:47:38 +01:00
Dave
f234853b44 added basic LED functionality 2018-10-07 21:25:17 +01:00
Dave
7c23f293da created percentage progess 2018-10-07 13:20:53 +01:00
Dave
62667d11f8 small update on CARD_READER variable 2018-10-06 22:04:39 +01:00
Dave
8681034d63 minor changes 2018-10-06 21:49:52 +01:00
Dave
00a8c0e170 updated readme with link 2018-10-06 21:27:00 +01:00
Dave
a90ff2c1f8 allows a device in any slot to work 2018-10-06 21:26:10 +01:00
29 changed files with 767 additions and 341 deletions

View File

@@ -1,8 +1,8 @@
# Little Backup Box # Little Backup Box
A collection of scripts that transform a Raspberry Pi (or any single-board computer running a Debian-based Linux distribution) into an inexpensive, fully-automatic, pocketable photo backup device. Bash shell scripts that transforms a Raspberry Pi (or any single-board computer running a Debian-based Linux distribution) into an inexpensive, fully-automatic, pocketable photo backup device.
<img src="https://i.imgur.com/ecKM606.jpg" alt="" width="500"/> <img src="https://i.imgur.com/OQ3AQfM.jpg" alt="" width="375"/>
**IMPORTANT** **IMPORTANT**
Little Backup Box is designed to work with USB sticks as backup media. Theoretically, it's possible to make Little Backup Box work with an external hard disk, but this setup is not officially supported. Little Backup Box is designed to work with USB sticks as backup media. Theoretically, it's possible to make Little Backup Box work with an external hard disk, but this setup is not officially supported.
@@ -11,7 +11,7 @@ Little Backup Box is designed to work with USB sticks as backup media. Theoretic
1. Create a bootable SD card with the latest version of Raspbian Lite for use with Little Backup Box. 1. Create a bootable SD card with the latest version of Raspbian Lite for use with Little Backup Box.
2. Make sure that your Raspberry Pi is connected to the internet. 2. Make sure that your Raspberry Pi is connected to the internet.
3. Run the following command on the Raspberry Pi: `curl -sSL https://is.gd/littlebackupbox | bash` 3. Run the following command on the Raspberry Pi: `curl -sSL https://raw.githubusercontent.com/skidave/little-backup-box/master/install-little-backup-box.sh | bash`
Little Backup Box supports three backup modes: Little Backup Box supports three backup modes:
@@ -47,16 +47,12 @@ The exact steps depend on the backup mode.
### Remote control mode ### Remote control mode
1. Point the browser to *http://127.0.0.1:8000* (replace *127.0.0.1* with the actual IP address of the Raspberry Pi). 1. Point the browser to *http://[IP-ADDRESS]:8080* (replace *[IP-ADDRESS]* with the actual IP address of the Raspberry Pi)
2. Start the desired action by pressing the appropriate button. 2. Start the desired backup mode by pressing the appropriate button.
The access the contents of the storage device, plug it into the Raspberry Pi and press the **DLNA & SAMBA** button. You can then use a uPnP or Samba client on any device on the same network to browse and view the contents of the storage device.
<img src="img/rc.png" alt="" /> <img src="img/rc.png" alt="" />
Activating the DLNA and Samba servers also returns the disk space usage information. You can use this information to monitor the remaining free space on the storage device. The remote control mode gives you access to the **Device backup** action that backs up the */home/pi/BACKUP* folder on the Raspberry Pi to an external storage device. This can be useful when you transfer files in the camera backup mode, and later want to back up the transferred files to a external storage device.
The **System info** link gives you access to basic system information, such as a list of storage devices and memory usage.
## Problems? ## Problems?

BIN
fonts/Lato/Lato-Black.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
fonts/Lato/Lato-Bold.ttf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
fonts/Lato/Lato-Italic.ttf Normal file

Binary file not shown.

BIN
fonts/Lato/Lato-Light.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
fonts/Lato/Lato-Regular.ttf Normal file

Binary file not shown.

93
fonts/Lato/OFL.txt Normal file
View File

@@ -0,0 +1,93 @@
Copyright (c) 2010-2014 by tyPoland Lukasz Dziedzic (team@latofonts.com) with Reserved Font Name "Lato"
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -13,50 +13,67 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
echo "----------------------" sudo apt update
echo "Updating the system..." sudo apt dist-upgrade -y
echo "----------------------" sudo apt update
sudo apt install acl git-core screen rsync exfat-fuse exfat-utils ntfs-3g gphoto2 libimage-exiftool-perl dialog python3-pip -y
sudo pip3 install bottle
apt update sudo mkdir /media/card
apt dist-upgrade -y sudo mkdir /media/storage
apt update sudo chown -R pi:pi /media/storage
sudo chmod -R 775 /media/storage
echo "-----------------------------------" sudo setfacl -Rdm g:pi:rw /media/storage
echo "Installing the required packages..."
echo "-----------------------------------"
apt install acl git-core screen rsync exfat-fuse exfat-utils ntfs-3g gphoto2 libimage-exiftool-perl dialog php cifs-utils sudo -y
USER="root"
mkdir /media/card
echo "-----------------------------"
echo "Fetching Little Backup Box..."
echo "-----------------------------"
cd cd
git clone https://trans.bprieshof.nl/gitea/brammp/little-backup-box-Bram.git git clone https://github.com/skidave/little-backup-box.git
cd little-backup-box/fonts
sudo cp -R . /home/pi/.fonts
cd ../scripts
sudo chmod u+x gpio
sudo chmod u+x blink
cd
mkdir /mnt/SMB HEIGHT=15
cat > /etc/network/if-up.d/mountsmb <<- "EOF" WIDTH=40
#! /bin/sh CHOICE_HEIGHT=4
mount -t cifs -o username=import,password=importpw,iocharset=utf8,sec=ntlmssp,file_mode=0775,dir_mode=0775 //192.168.2.144/Data /mnt/SMB BACKTITLE="Little Backup Box"
exit 0 TITLE="Backup mode"
EOF MENU="Select the default backup mode:"
cat > /etc/network/if-up.d/startphpweb <<- "EOF" OPTIONS=(1 "Remote control"
#! /bin/sh 2 "Card backup"
cd /root/little-backup-box-Bram/scripts && php -S 0.0.0.0:8000 & 3 "Camera backup")
exit 0
EOF
chmod +x /etc/network/if-up.d/startphpweb CHOICE=$(dialog --clear \
chmod +x /etc/network/if-up.d/mountsmb --backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
case $CHOICE in
1)
crontab -l | { cat; echo "#@reboot sudo /home/pi/little-backup-box/scripts/card-backup.sh >> /home/pi/little-backup-box.log 2>&1"; } | crontab
crontab -l | { cat; echo "#@reboot sudo /home/pi/little-backup-box/scripts/camera-backup.sh >> /home/pi/little-backup-box.log 2>&1"; } | crontab
crontab -l | { cat; echo "@reboot sudo /home/pi/little-backup-box/scripts/rc.sh >> /home/pi/little-backup-box.log 2>&1"; } | crontab
;;
2)
crontab -l | { cat; echo "@reboot sudo /home/pi/little-backup-box/scripts/card-backup.sh >> /home/pi/little-backup-box.log 2>&1"; } | crontab
crontab -l | { cat; echo "#@reboot sudo /home/pi/little-backup-box/scripts/camera-backup.sh >> /home/pi/little-backup-box.log 2>&1"; } | crontab
crontab -l | { cat; echo "#@reboot sudo /home/pi/little-backup-box/scripts/rc.sh >> /home/pi/little-backup-box.log 2>&1"; } | crontab
;;
3)
crontab -l | { cat; echo "#@reboot sudo /home/pi/little-backup-box/scripts/card-backup.sh >> /home/pi/little-backup-box.log 2>&1"; } | crontab
crontab -l | { cat; echo "@reboot sudo /home/pi/little-backup-box/scripts/camera-backup.sh >> /home/pi/little-backup-box.log 2>&1"; } | crontab
crontab -l | { cat; echo "#@reboot sudo /home/pi/little-backup-box/scripts/rc.sh >> /home/pi/little-backup-box.log 2>&1"; } | crontab
;;
esac
echo "---------------------------------------------" echo "---------------------------------------------"
echo "All done! The system will reboot in 1 minute." echo "All done! The system will reboot in 1 minute."
echo "---------------------------------------------" echo "---------------------------------------------"
shutdown -r 1 sudo shutdown -r 1

View File

@@ -1,42 +0,0 @@
#!/usr/bin/env bash
# Author: Dmitri Popov, dmpop@linux.com
# License: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
if [ -z "$1" ] && [ -z "$2" ]; then
echo "ERROR: Specify image file and device name"
echo "E.g.: $0 /path/to/foo.img /dev/sdb"
exit 1
fi
echo "Writing the image file..."
echo
sudo dd if="$1" of="$2" bs=1M status=progress
sudo mount "$2"1 /mnt
sudo touch /mnt/ssh
sudo umount /mnt
sudo mount "$2"2 /mnt
sudo mv /mnt/etc/wpa_supplicant/wpa_supplicant.conf /mnt/etc/wpa_supplicant/wpa_supplicant.conf.bak
echo "Enter the name of the wireless network: "
read SSID
echo "Enter the wireless network password: "
read -s PASS
cat >$HOME/wpa_supplicant.conf <<EOF
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="$SSID"
psk="$PASS"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}
EOF
sudo mv $HOME/wpa_supplicant.conf /mnt/etc/wpa_supplicant/wpa_supplicant.conf
sudo umount /mnt
echo "All done!"

41
rc/exit.tpl Normal file
View File

@@ -0,0 +1,41 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
p.left {
text-align: left;
}
p.center {
text-align: center;
}
img {
display: block;
margin-left: auto;
margin-right: auto;
}
#content {
font: 1em/1.5em 'Lato', sans-serif;
margin: 0px auto;
width: 275px;
text-align: center;
}
#dialog {
width: auto; height: auto;
background: #009933;
border-radius: 5px;
color: #fff;
font-family: 'Lato', sans-serif; font-size: 17px;
padding-right: 0.5em;
padding-left: 0.5em;
padding-top: 0.5em;
padding-bottom: 0.5em;
border:none;
}
</style>
</head>
<title>Little Backup Box</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<div id="content">
<div id="dialog">Command sent. You can close this page.</div>
</div>

43
rc/rc.py Executable file
View File

@@ -0,0 +1,43 @@
#!/usr/bin/python
# 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 3 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, see <http://www.gnu.org/licenses/>.
from bottle import post, route, request, template, static_file, run
import os, subprocess
@route('/')
@route('/', method='POST')
def remote_control():
st_home = os.statvfs("/home")
free_home = "%.2f" % float((st_home.f_bavail * st_home.f_frsize)/1.073741824e9)
if (request.POST.get("cardbackup")):
process = subprocess.Popen("sudo /home/pi/little-backup-box/scripts/card-backup.sh", shell=True)
return template('exit.tpl')
if (request.POST.get("camerabackup")):
process = subprocess.Popen("sudo /home/pi/little-backup-box/scripts/camera-backup.sh", shell=True)
return template('exit.tpl')
if (request.POST.get("devicebackup")):
process = subprocess.Popen("sudo /home/pi/little-backup-box/scripts/device-backup.sh", shell=True)
return template('exit.tpl')
if (request.POST.get("shutdown")):
process = subprocess.Popen("sudo shutdown -h now", shell=True)
return template('exit.tpl')
return template('rc.tpl', freespace_home=free_home)
@route('/static/:path#.+#', name='static')
def static(path):
return static_file(path, root='static')
run(host="0.0.0.0", port=8080, debug=True, reloader=True)

59
rc/rc.tpl Normal file
View File

@@ -0,0 +1,59 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
p.left {
text-align: left;
}
p.center {
text-align: center;
}
img {
display: block;
margin-left: auto;
margin-right: auto;
}
#content {
font: 1em/1.5em 'Lato', sans-serif;
margin: 0px auto;
width: 275px;
text-align: left;
}
#header {
font: bold 1.7em/2em 'Lato', sans-serif;
text-align: center;
}
#btn {
width: 11em; height: 2em;
background: #3399ff;
border-radius: 5px;
color: #fff;
font-family: 'Lato', sans-serif; font-size: 25px; font-weight: 900;
letter-spacing: 3px;
border:none;
}
#btn.orange {
background: #ff9900;
}
#btn.red {
background: #cc0000;
}
</style>
</head>
<title>Little Backup Box</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<form method="POST" action="/">
<div id="content">
<div id="header"><img src="static/ichigo.svg" height="39px" alt="Ichigo" align=""> Little Backup Box</div>
<p class="center">Free disk space on <i>/home</i>: <b>{{freespace_home}}</b> GB</p>
<hr>
<p class="left">Back up a storage card connected via a card reader</p>
<p><input id="btn" name="cardbackup" type="submit" value="Card backup"></p>
<p class="left">Transfer files directly from the connected camera</p>
<p><input id="btn" name="camerabackup" type="submit" value="Camera backup"></p>
<p class="left">Back up files from the internal storage to an external storage device</p>
<p><input id="btn" class="orange" name="devicebackup" type="submit" value="Device backup"></p>
<p class="left">Shut down the Little Backup Box</p>
<p><input id="btn" class="red" name="shutdown" value="Shut down" type="submit" /></p>
</div>

229
rc/static/ichigo.svg Normal file
View File

@@ -0,0 +1,229 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
x="0px"
y="0px"
viewBox="0 0 83.28714 89.003151"
enable-background="new 0 0 100 100"
xml:space="preserve"
id="svg2"
inkscape:version="0.91 r13725"
sodipodi:docname="ichigo.svg"
width="83.28714"
height="89.003151"
inkscape:export-filename="/home/dmpop/ichigo.png"
inkscape:export-xdpi="96.190002"
inkscape:export-ydpi="96.190002"><metadata
id="metadata102"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs100" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1375"
inkscape:window-height="876"
id="namedview98"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="1.888"
inkscape:cx="41.642749"
inkscape:cy="32.001001"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" /><g
id="g4"
style="fill:#ff0000"
transform="translate(-8.3572506,-5.4978477)"><path
d="m 89.678,23.383 c 0.839,0.229 1.691,-0.273 1.913,-1.107 0.223,-0.834 -0.273,-1.691 -1.107,-1.913 -9.077,-2.421 -16.374,-0.292 -21.772,6.298 0.318,-4.744 0.052,-9.658 -1.913,-13.87 -0.22,-0.471 -0.659,-0.803 -1.173,-0.883 -0.51,-0.08 -1.034,0.099 -1.388,0.479 -1.983,2.132 -3.446,4.95 -4.311,8.089 C 58.134,15.813 56.835,11.28 56.003,6.776 55.882,6.125 55.364,5.62 54.71,5.517 54.057,5.414 53.406,5.733 53.092,6.316 c -2.19,4.042 -2.497,7.907 -1.833,11.703 -4.53,-2.437 -8.717,-3.654 -12.606,-3.654 -9.42,0 -15.805,6.971 -21.301,14.503 -10.326,14.152 -11.764,54.006 -4.3,61.47 3.621,3.622 13.665,4.163 19.33,4.163 14.581,0 33.675,-3.342 41.958,-9.729 5.704,-4.398 12.325,-10.604 12.906,-19.638 0.294,-4.562 -0.965,-9.455 -3.784,-14.742 1.567,0.699 3.177,1.135 4.803,1.135 0.629,0 1.25,-0.065 1.848,-0.196 0.438,-0.097 0.813,-0.376 1.032,-0.768 0.218,-0.392 0.258,-0.859 0.108,-1.282 -1.612,-4.557 -5.162,-8.104 -10.118,-10.3 2.85,-1.879 5.729,-4.845 8.888,-9.087 0.311,-0.417 0.394,-0.959 0.222,-1.449 -0.171,-0.491 -0.574,-0.863 -1.076,-0.996 -2.496,-0.659 -4.812,-0.979 -7.077,-0.979 -3.973,0 -7.695,0.994 -11.749,3.176 4.701,-6.417 11.057,-8.468 19.335,-6.263 z m -24.775,-6.71 c 0.852,3.078 1.004,6.864 0.503,11.893 -1.084,-1.001 -2.153,-1.955 -3.204,-2.849 0.206,-3.333 1.164,-6.531 2.701,-9.044 z M 54.182,12.915 c 0.763,2.883 1.715,5.792 2.854,8.746 C 56.35,21.169 55.671,20.701 55,20.26 54.259,17.789 53.887,15.361 54.182,12.915 Z m 29.944,52.021 c -0.498,7.736 -6.191,13.118 -11.695,17.362 -7.647,5.896 -26.343,9.078 -40.05,9.078 -10.228,0 -15.55,-1.678 -17.12,-3.247 -5.808,-5.808 -5.33,-43.785 4.616,-57.417 5.79,-7.935 11.198,-13.22 18.775,-13.22 7.677,0 16.917,5.509 28.248,16.84 12.135,12.134 17.77,22.146 17.226,30.604 z m 3.282,-16.591 c -2.545,-0.335 -5.259,-2.082 -7.779,-4.056 -0.788,-1.101 -1.632,-2.217 -2.543,-3.353 0.066,-0.02 0.133,-0.04 0.2,-0.061 4.675,1.435 8.196,4.019 10.122,7.47 z M 82.09,29.598 c 1.277,0 2.579,0.118 3.938,0.357 -3.221,4.014 -6.067,6.47 -8.894,7.635 -1.119,-0.296 -2.287,-0.535 -3.502,-0.714 -0.729,-0.81 -1.489,-1.629 -2.277,-2.456 l -0.87,-1.262 c 4.159,-2.485 7.7,-3.56 11.605,-3.56 z"
id="path6"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 39.336,41.333 -0.565,0.972 c -0.434,0.747 -0.181,1.703 0.566,2.137 0.247,0.144 0.518,0.211 0.784,0.211 0.539,0 1.063,-0.278 1.353,-0.777 l 0.565,-0.972 c 0.434,-0.747 0.181,-1.703 -0.566,-2.137 -0.746,-0.434 -1.703,-0.18 -2.137,0.566 z"
id="path8"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 19.845,40.694 c 0.113,0.025 0.226,0.037 0.337,0.037 0.718,0 1.365,-0.498 1.525,-1.228 l 0.507,-2.312 c 0.186,-0.843 -0.348,-1.677 -1.191,-1.861 -0.841,-0.186 -1.677,0.347 -1.862,1.191 l -0.507,2.312 c -0.186,0.842 0.348,1.676 1.191,1.861 z"
id="path10"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 55.102,31.817 c 0.192,0.077 0.39,0.114 0.585,0.114 0.618,0 1.204,-0.37 1.45,-0.979 l 0.605,-1.5 c 0.322,-0.801 -0.064,-1.712 -0.865,-2.035 -0.801,-0.324 -1.711,0.064 -2.034,0.864 l -0.605,1.5 c -0.324,0.802 0.064,1.713 0.864,2.036 z"
id="path12"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 64.548,37.412 -0.751,0.736 c -0.616,0.604 -0.626,1.594 -0.021,2.21 0.306,0.313 0.711,0.469 1.116,0.469 0.395,0 0.79,-0.148 1.094,-0.447 l 0.751,-0.736 c 0.616,-0.604 0.626,-1.594 0.021,-2.21 -0.604,-0.618 -1.595,-0.627 -2.21,-0.022 z"
id="path14"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 48.923,44.316 c 0.306,0.311 0.709,0.467 1.113,0.467 0.396,0 0.792,-0.149 1.097,-0.449 l 0.93,-0.916 c 0.615,-0.605 0.623,-1.595 0.018,-2.21 -0.605,-0.615 -1.596,-0.623 -2.211,-0.017 l -0.93,0.916 c -0.615,0.604 -0.623,1.595 -0.017,2.209 z"
id="path16"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 28.877,42.37 -1.288,1.272 c -0.614,0.606 -0.62,1.596 -0.013,2.21 0.305,0.309 0.708,0.464 1.111,0.464 0.397,0 0.794,-0.15 1.099,-0.452 l 1.287,-1.272 c 0.614,-0.606 0.62,-1.596 0.013,-2.209 -0.604,-0.614 -1.595,-0.62 -2.209,-0.013 z"
id="path18"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 19.101,50.073 c 0.133,0.035 0.268,0.052 0.399,0.052 0.693,0 1.326,-0.464 1.511,-1.165 l 0.507,-1.923 c 0.22,-0.835 -0.278,-1.69 -1.113,-1.91 -0.837,-0.22 -1.69,0.278 -1.91,1.113 l -0.507,1.923 c -0.22,0.835 0.278,1.69 1.113,1.91 z"
id="path20"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 24.745,57.541 c 0.236,0.127 0.49,0.188 0.741,0.188 0.556,0 1.094,-0.297 1.377,-0.82 l 0.897,-1.662 c 0.41,-0.76 0.126,-1.707 -0.633,-2.118 -0.76,-0.408 -1.708,-0.126 -2.118,0.634 l -0.897,1.662 c -0.41,0.758 -0.127,1.706 0.633,2.116 z"
id="path22"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 49.346,51.083 c -0.679,-0.532 -1.663,-0.413 -2.194,0.268 l -1.353,1.728 c -0.532,0.679 -0.413,1.662 0.267,2.193 0.286,0.225 0.625,0.333 0.963,0.333 0.464,0 0.923,-0.206 1.231,-0.6 l 1.353,-1.728 c 0.532,-0.678 0.412,-1.662 -0.267,-2.194 z"
id="path24"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 41.778,65.897 0.849,-1.712 c 0.384,-0.772 0.067,-1.71 -0.706,-2.094 -0.773,-0.385 -1.71,-0.067 -2.094,0.706 l -0.849,1.711 c -0.384,0.773 -0.067,1.711 0.706,2.095 0.223,0.111 0.459,0.163 0.693,0.163 0.575,10e-4 1.128,-0.319 1.401,-0.869 z"
id="path26"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 32.344,66.587 1.563,-2.246 c 0.493,-0.709 0.318,-1.683 -0.391,-2.176 -0.709,-0.494 -1.683,-0.317 -2.175,0.391 l -1.563,2.246 c -0.493,0.709 -0.318,1.683 0.391,2.176 0.272,0.189 0.583,0.28 0.891,0.28 0.495,0 0.981,-0.235 1.284,-0.671 z"
id="path28"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 16.133,62.685 c 0.035,0.003 0.07,0.004 0.104,0.004 0.816,0 1.504,-0.634 1.558,-1.46 l 0.118,-1.793 C 17.97,58.575 17.317,57.83 16.456,57.774 15.59,57.698 14.85,58.369 14.794,59.23 l -0.118,1.793 c -0.056,0.861 0.596,1.606 1.457,1.662 z"
id="path30"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 16.853,73.331 -0.012,-2.312 c -0.004,-0.861 -0.704,-1.555 -1.563,-1.555 -0.003,0 -0.006,0 -0.008,0 -0.864,0.004 -1.56,0.707 -1.555,1.57 l 0.012,2.312 c 0.004,0.861 0.704,1.556 1.563,1.556 0.003,0 0.006,0 0.008,0 0.864,-0.005 1.559,-0.708 1.555,-1.571 z"
id="path32"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 21.743,65.777 -0.963,2.378 c -0.324,0.8 0.063,1.712 0.862,2.036 0.192,0.077 0.391,0.114 0.586,0.114 0.618,0 1.203,-0.369 1.449,-0.977 L 24.64,66.95 c 0.324,-0.8 -0.063,-1.712 -0.862,-2.036 -0.801,-0.321 -1.711,0.064 -2.035,0.863 z"
id="path34"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 33.719,78.845 1.742,-0.688 c 0.804,-0.316 1.197,-1.225 0.88,-2.027 -0.316,-0.803 -1.223,-1.199 -2.027,-0.88 l -1.743,0.688 c -0.803,0.316 -1.197,1.225 -0.88,2.027 0.243,0.614 0.831,0.99 1.455,0.99 0.19,0 0.385,-0.035 0.573,-0.11 z"
id="path36"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 43.213,72.764 c 0.293,0.486 0.81,0.755 1.339,0.755 0.276,0 0.554,-0.072 0.807,-0.226 l 1.276,-0.771 c 0.739,-0.446 0.976,-1.407 0.529,-2.146 -0.447,-0.74 -1.409,-0.977 -2.146,-0.529 l -1.276,0.771 c -0.738,0.446 -0.975,1.407 -0.529,2.146 z"
id="path38"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 51.571,62.268 -1.45,0.72 c -0.772,0.385 -1.088,1.323 -0.704,2.096 0.273,0.55 0.826,0.868 1.401,0.868 0.234,0 0.47,-0.053 0.695,-0.163 l 1.449,-0.721 c 0.772,-0.384 1.089,-1.322 0.704,-2.096 -0.384,-0.772 -1.318,-1.088 -2.095,-0.704 z"
id="path40"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 56.506,55.662 c 0.708,-0.494 0.881,-1.469 0.388,-2.177 -0.495,-0.708 -1.47,-0.882 -2.176,-0.388 l -2.197,1.532 c -0.709,0.494 -0.882,1.469 -0.389,2.176 0.305,0.437 0.789,0.67 1.283,0.67 0.309,0 0.62,-0.092 0.893,-0.281 l 2.198,-1.532 z"
id="path42"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 56.378,45.247 c 0.301,0.453 0.797,0.698 1.303,0.698 0.297,0 0.598,-0.084 0.863,-0.261 l 1.48,-0.984 c 0.72,-0.478 0.915,-1.448 0.437,-2.167 -0.478,-0.72 -1.449,-0.914 -2.166,-0.437 l -1.48,0.984 c -0.72,0.478 -0.916,1.448 -0.437,2.167 z"
id="path44"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 46.861,35.624 c 0.199,0.084 0.404,0.124 0.607,0.124 0.609,0 1.189,-0.36 1.441,-0.957 l 0.557,-1.322 c 0.335,-0.795 -0.038,-1.712 -0.833,-2.047 -0.798,-0.337 -1.713,0.038 -2.048,0.833 l -0.557,1.322 c -0.335,0.795 0.038,1.712 0.833,2.047 z"
id="path46"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 33.675,25.045 c 0.396,0 0.792,-0.149 1.096,-0.449 l 0.914,-0.899 c 0.615,-0.606 0.623,-1.595 0.018,-2.211 -0.607,-0.615 -1.596,-0.623 -2.211,-0.018 l -0.914,0.899 c -0.615,0.606 -0.623,1.595 -0.018,2.21 0.307,0.313 0.711,0.468 1.115,0.468 z"
id="path48"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 43.749,25.498 c 0.396,0 0.792,-0.149 1.097,-0.449 l 0.995,-0.98 c 0.614,-0.606 0.622,-1.595 0.016,-2.21 -0.605,-0.614 -1.595,-0.623 -2.21,-0.017 l -0.995,0.98 c -0.614,0.606 -0.623,1.595 -0.017,2.21 0.306,0.31 0.71,0.466 1.114,0.466 z"
id="path50"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 27.986,34.515 c 0.17,0.059 0.342,0.087 0.513,0.087 0.647,0 1.253,-0.406 1.477,-1.051 l 0.476,-1.37 c 0.283,-0.816 -0.149,-1.707 -0.964,-1.99 -0.817,-0.283 -1.707,0.149 -1.989,0.964 l -0.476,1.37 c -0.284,0.816 0.148,1.707 0.963,1.99 z"
id="path52"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 62.479,54.467 c 0.214,0 0.432,-0.044 0.639,-0.138 l 1.679,-0.753 c 0.787,-0.354 1.139,-1.278 0.785,-2.066 -0.353,-0.788 -1.279,-1.139 -2.065,-0.786 l -1.678,0.754 c -0.787,0.354 -1.14,1.278 -0.786,2.065 0.26,0.58 0.83,0.924 1.426,0.924 z"
id="path54"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 70.042,49.497 c 0.143,0 0.288,-0.021 0.434,-0.062 l 1.482,-0.427 c 0.829,-0.239 1.308,-1.105 1.069,-1.935 -0.239,-0.83 -1.103,-1.31 -1.936,-1.069 l -1.482,0.427 c -0.829,0.239 -1.308,1.105 -1.069,1.935 0.198,0.685 0.822,1.131 1.502,1.131 z"
id="path56"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="M 62.933,62.099 C 62.375,61.441 61.388,61.36 60.73,61.919 l -0.963,0.817 c -0.658,0.559 -0.738,1.545 -0.179,2.203 0.309,0.363 0.748,0.551 1.191,0.551 0.357,0 0.718,-0.122 1.011,-0.372 l 0.963,-0.817 c 0.658,-0.559 0.739,-1.545 0.18,-2.202 z"
id="path58"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 59.074,72.899 -1.027,0.168 c -0.853,0.139 -1.431,0.942 -1.29,1.794 0.125,0.767 0.788,1.311 1.54,1.311 0.084,0 0.169,-0.006 0.254,-0.021 l 1.027,-0.168 c 0.853,-0.14 1.431,-0.942 1.29,-1.794 -0.139,-0.852 -0.941,-1.433 -1.794,-1.29 z"
id="path60"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="M 53.559,78.573 C 53.276,77.757 52.383,77.327 51.57,77.609 l -1.418,0.493 c -0.815,0.282 -1.247,1.174 -0.964,1.988 0.225,0.646 0.83,1.051 1.477,1.051 0.17,0 0.343,-0.027 0.513,-0.087 l 1.418,-0.493 c 0.814,-0.282 1.246,-1.173 0.963,-1.988 z"
id="path62"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 45.642,80.044 c -0.12,-0.854 -0.914,-1.445 -1.766,-1.33 L 42.8,78.865 c -0.855,0.121 -1.45,0.911 -1.33,1.766 0.11,0.781 0.779,1.346 1.545,1.346 0.073,0 0.146,-0.005 0.22,-0.016 l 1.076,-0.151 c 0.855,-0.121 1.45,-0.912 1.331,-1.766 z"
id="path64"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 28.475,81.963 -1.896,0.223 c -0.857,0.1 -1.471,0.876 -1.371,1.733 0.092,0.796 0.768,1.382 1.55,1.382 0.061,0 0.122,-0.004 0.184,-0.011 l 1.896,-0.223 c 0.857,-0.1 1.471,-0.876 1.371,-1.733 -0.1,-0.857 -0.879,-1.469 -1.734,-1.371 z"
id="path66"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="M 25.312,76.528 C 25.174,75.675 24.364,75.097 23.52,75.234 l -2.196,0.354 c -0.852,0.139 -1.432,0.94 -1.293,1.792 0.124,0.769 0.788,1.314 1.541,1.314 0.083,0 0.167,-0.007 0.251,-0.021 l 2.195,-0.354 c 0.853,-0.136 1.432,-0.938 1.294,-1.791 z"
id="path68"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 19.225,84.118 -2.152,0.19 c -0.859,0.075 -1.495,0.835 -1.419,1.694 0.072,0.813 0.754,1.426 1.555,1.426 0.046,0 0.093,-0.003 0.14,-0.006 l 2.152,-0.19 c 0.859,-0.076 1.495,-0.835 1.419,-1.695 -0.077,-0.859 -0.833,-1.485 -1.695,-1.419 z"
id="path70"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 34.974,86.234 -0.865,0.329 c -0.807,0.308 -1.211,1.21 -0.904,2.018 0.237,0.623 0.831,1.007 1.46,1.007 0.185,0 0.373,-0.033 0.556,-0.104 l 0.865,-0.329 c 0.807,-0.308 1.211,-1.21 0.904,-2.017 -0.305,-0.807 -1.21,-1.211 -2.016,-0.904 z"
id="path72"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 46.386,85.388 -0.962,0.037 c -0.863,0.033 -1.535,0.76 -1.501,1.622 0.032,0.843 0.725,1.503 1.56,1.503 0.021,0 0.042,-10e-4 0.062,-10e-4 l 0.962,-0.038 c 0.863,-0.033 1.535,-0.76 1.501,-1.621 -0.033,-0.864 -0.782,-1.533 -1.622,-1.502 z"
id="path74"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 65.621,70.353 c 0.211,0.667 0.826,1.094 1.49,1.094 0.155,0 0.314,-0.023 0.47,-0.073 l 1.255,-0.396 c 0.824,-0.259 1.281,-1.137 1.021,-1.96 -0.26,-0.823 -1.141,-1.281 -1.96,-1.021 l -1.255,0.396 c -0.824,0.258 -1.281,1.136 -1.021,1.96 z"
id="path76"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 72.124,60.015 c -0.582,-0.638 -1.57,-0.686 -2.209,-0.104 l -0.881,0.801 c -0.638,0.581 -0.686,1.569 -0.104,2.209 0.309,0.339 0.732,0.511 1.157,0.511 0.375,0 0.752,-0.134 1.051,-0.406 l 0.881,-0.802 c 0.638,-0.581 0.686,-1.571 0.105,-2.209 z"
id="path78"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 77.292,57.129 c 0.247,0 0.498,-0.06 0.732,-0.184 l 1.417,-0.753 c 0.762,-0.405 1.052,-1.352 0.646,-2.113 -0.403,-0.763 -1.349,-1.053 -2.113,-0.646 l -1.417,0.753 c -0.762,0.405 -1.052,1.352 -0.646,2.113 0.28,0.529 0.82,0.83 1.381,0.83 z"
id="path80"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 78.734,63.239 -1.709,0.98 c -0.749,0.43 -1.008,1.385 -0.579,2.134 0.29,0.503 0.816,0.785 1.358,0.785 0.263,0 0.53,-0.066 0.775,-0.206 l 1.71,-0.98 c 0.749,-0.43 1.008,-1.385 0.578,-2.134 -0.428,-0.747 -1.382,-1.005 -2.133,-0.579 z"
id="path82"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 71.417,76.305 c 0.171,0.719 0.812,1.204 1.521,1.204 0.119,0 0.239,-0.014 0.36,-0.042 l 1.125,-0.266 c 0.84,-0.199 1.36,-1.04 1.162,-1.881 -0.199,-0.84 -1.045,-1.357 -1.88,-1.162 l -1.125,0.266 c -0.841,0.199 -1.361,1.041 -1.163,1.881 z"
id="path84"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 55.714,84.837 -1.482,-0.156 c -0.854,-0.089 -1.627,0.531 -1.719,1.39 -0.09,0.859 0.532,1.629 1.39,1.719 l 1.482,0.157 c 0.056,0.006 0.111,0.009 0.166,0.009 0.789,0 1.468,-0.597 1.553,-1.399 0.09,-0.86 -0.533,-1.629 -1.39,-1.72 z"
id="path86"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 64.467,79.771 -1.256,0.201 c -0.852,0.137 -1.433,0.938 -1.297,1.791 0.124,0.769 0.788,1.315 1.542,1.315 0.082,0 0.166,-0.006 0.249,-0.02 l 1.256,-0.201 c 0.852,-0.136 1.433,-0.938 1.297,-1.79 -0.138,-0.853 -0.946,-1.429 -1.791,-1.296 z"
id="path88"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 37.305,34.186 c 0.236,0.127 0.49,0.188 0.741,0.188 0.556,0 1.094,-0.297 1.377,-0.82 l 0.897,-1.662 c 0.41,-0.76 0.126,-1.708 -0.633,-2.118 -0.76,-0.409 -1.708,-0.125 -2.118,0.633 l -0.897,1.662 c -0.411,0.759 -0.127,1.706 0.633,2.117 z"
id="path90"
style="fill:#ff0000"
inkscape:connector-curvature="0" /><path
d="m 40.487,50.739 c -0.438,-0.744 -1.397,-0.991 -2.14,-0.556 l -1.612,0.949 c -0.744,0.438 -0.993,1.396 -0.556,2.139 0.292,0.496 0.813,0.771 1.349,0.771 0.27,0 0.542,-0.069 0.791,-0.216 l 1.612,-0.947 c 0.745,-0.438 0.994,-1.396 0.556,-2.14 z"
id="path92"
style="fill:#ff0000"
inkscape:connector-curvature="0" /></g></svg>

After

Width:  |  Height:  |  Size: 18 KiB

25
scripts/blink Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
. /home/pi/little-backup-box/scripts/gpio
function blink()
{
local pin=$1
local speed=$2
while :
do
gpio write $pin 1
sleep $speed
gpio write $pin 0
sleep $speed
done
}
# Just invoke our function if the script is called directly
if [ "$BASH_SOURCE" == "$0" ]; then
gpio mode $1 out
blink $@
fi

View File

@@ -17,17 +17,56 @@
# Run the install-little-backup-box.sh script first # Run the install-little-backup-box.sh script first
# to install the required packages and configure the system. # to install the required packages and configure the system.
# Specify devices and their their mount points # Specify devices and their mount points
# as well as other settings # and other settings
STORAGE_DEV="sdc1" # Name of the storage device
STORAGE_MOUNT_POINT="/mnt/SMB" # Mount point of the storage device STORAGE_MOUNT_POINT="/media/storage" # Mount point of the storage device
CARD_DEV="sd[ab]1" # Name of the storage card
CARD_DEV="sdb1" # Name of the storage card
CARD_MOUNT_POINT="/media/card" # Mount point of the storage card CARD_MOUNT_POINT="/media/card" # Mount point of the storage card
SHUTD="5" # Minutes to wait before shutdown due to inactivity SHUTD="5" # Minutes to wait before shutdown due to inactivity
. /home/pi/little-backup-box/scripts/gpio
. /home/pi/little-backup-box/scripts/blink
gpio mode 5 out
gpio mode 6 out
gpio mode 13 out
gpio mode 19 out
gpio mode 26 out
gpio wirte 5 0
gpio write 6 0
gpio write 13 0
gpio write 19 0
gpio write 26 0
# Set the ACT LED to heartbeat
sudo sh -c "echo heartbeat > /sys/class/leds/led0/trigger"
# Shutdown after a specified period of time (in minutes) if no device is connected.
sudo shutdown -h $SHUTD "Shutdown is activated. To cancel: sudo shutdown -c"
# Wait for a USB storage device (e.g., a USB flash drive)
STORAGE=$(ls /dev/* | grep "$STORAGE_DEV" | cut -d"/" -f3)
#STORAGE=$(lsblk -x SIZE | grep sd[a-z]1 | awk '{print $1}' | sort | head -n 1)
while [ -z "${STORAGE}" ]
do
sleep 1
STORAGE=$(ls /dev/* | grep "$STORAGE_DEV" | cut -d"/" -f3)
done
# When the USB storage device is detected, mount it
mount /dev/"$STORAGE_DEV" "$STORAGE_MOUNT_POINT"
# Cancel shutdown
sudo shutdown -c
# Set the ACT LED to blink at 1000ms to indicate that the storage device has been mounted
sudo sh -c "echo timer > /sys/class/leds/led0/trigger"
sudo sh -c "echo 1000 > /sys/class/leds/led0/delay_on"
# Wait for a card reader or a camera # Wait for a card reader or a camera
# takes first device found # takes first device found
CARD_READER=($(ls /dev/* | grep "$CARD_DEV" | cut -d"/" -f3)) CARD_READER=($(ls /dev/* | grep "$CARD_DEV" | cut -d"/" -f3))
@@ -42,6 +81,8 @@ if [ ! -z "${CARD_READER[0]}" ]; then
mount /dev"/${CARD_READER[0]}" "$CARD_MOUNT_POINT" mount /dev"/${CARD_READER[0]}" "$CARD_MOUNT_POINT"
CARD_COUNT=$(find $CARD_MOUNT_POINT/ -type f | wc -l) CARD_COUNT=$(find $CARD_MOUNT_POINT/ -type f | wc -l)
# # Set the ACT LED to blink at 500ms to indicate that the card has been mounted
sudo sh -c "echo 500 > /sys/class/leds/led0/delay_on"
# Create a .id random identifier file if doesn't exist # Create a .id random identifier file if doesn't exist
cd "$CARD_MOUNT_POINT" cd "$CARD_MOUNT_POINT"
@@ -60,17 +101,80 @@ if [ ! -z "${CARD_READER[0]}" ]; then
rsync -avh --info=progress2 --exclude "*.id" "$CARD_MOUNT_POINT"/ "$BACKUP_PATH" & rsync -avh --info=progress2 --exclude "*.id" "$CARD_MOUNT_POINT"/ "$BACKUP_PATH" &
pid=$! pid=$!
COUNTER=0
while kill -0 $pid 2> /dev/null while kill -0 $pid 2> /dev/null
do do
STORAGE_COUNT=$(find $BACKUP_PATH/ -type f | wc -l) STORAGE_COUNT=$(find $BACKUP_PATH/ -type f | wc -l)
PERCENT=$(expr 100 \* $STORAGE_COUNT / $CARD_COUNT) PERCENT=$(expr 100 \* $STORAGE_COUNT / $CARD_COUNT)
sudo sh -c "echo $PERCENT" sudo sh -c "echo $PERCENT"
#IF STATEMENTS HERE FOR LEDS #IF STATEMENTS HERE FOR LEDS
# then if [ $PERCENT -lt 19 ]; then
#LEDS if [ "$COUNTER" -eq 0 ]; then
#fi blink 26 0.25 &
blink_pid1=$!
COUNTER=$((COUNTER+1))
fi
elif [ $PERCENT -gt 20 ] && [ $PERCENT -lt 39 ]; then
kill $blink_pid1 2> /dev/null
gpio write 26 1
if [ "$COUNTER" -eq 1 ]; then
blink 19 0.25 &
blink_pid2=$!
COUNTER=$((COUNTER+1))
fi
elif [ $PERCENT -gt 40 ] && [ $PERCENT -lt 59 ]; then
kill $blink_pid2 2> /dev/null
gpio write 26 1
gpio write 19 1
if [ "$COUNTER" -eq 2 ]; then
blink 13 0.25 &
blink_pid3=$!
COUNTER=$((COUNTER+1))
fi
elif [ $PERCENT -gt 60 ] && [ $PERCENT -lt 79 ]; then
kill $blink_pid3 2> /dev/null
gpio write 26 1
gpio write 19 1
gpio write 13 1
if [ "$COUNTER" -eq 3 ]; then
blink 6 0.25 &
blink_pid4=$!
COUNTER=$((COUNTER+1))
fi
elif [ $PERCENT -gt 80 ] && [ $PERCENT -lt 100 ]; then
kill $blink_pid4 2> /dev/null
gpio write 26 1
gpio write 19 1
gpio write 13 1
gpio write 6 1
if [ "$COUNTER" -eq 4 ]; then
blink 5 0.25 &
blink_pid5=$!
COUNTER=$((COUNTER+1))
fi
fi
sleep 1 sleep 1
done done
if [ "$COUNTER" -eq 5 ]; then
kill $blink_pid5 2> /dev/null
fi
gpio write 26 1
gpio write 19 1
gpio write 13 1
gpio write 6 1
gpio write 5 1
sleep 5
gpio clean 5
gpio clean 6
gpio clean 13
gpio clean 19
gpio clean 26
fi fi
# Shutdown # Shutdown

View File

@@ -17,15 +17,22 @@
# Run the install-little-backup-box.sh script first # Run the install-little-backup-box.sh script first
# to install the required packages and configure the system. # to install the required packages and configure the system.
# Specify devices and their their mount points # Specify devices and their mount points
# as well as other settings # and other settings
STORAGE_DEV="sda1" # Name of the storage device STORAGE_DEV="sda1" # Name of the storage device
STORAGE_MOUNT_POINT="/media/storage" # Mount point of the storage device STORAGE_MOUNT_POINT="/media/storage" # Mount point of the storage device
SOURCE_DIR="/home/pi/BACKUP/"
SHUTD="5" # Minutes to wait before shutdown due to inactivity
# Set the ACT LED to heartbeat
sudo sh -c "echo heartbeat > /sys/class/leds/led0/trigger"
# Shutdown after a specified period of time (in minutes) if no device is connected.
sudo shutdown -h $SHUTD "Shutdown is activated. To cancel: sudo shutdown -c"
# Wait for a USB storage device (e.g., a USB flash drive) # Wait for a USB storage device (e.g., a USB flash drive)
STORAGE=$(ls /dev/* | grep "$STORAGE_DEV" | cut -d"/" -f3) STORAGE=$(ls /dev/* | grep "$STORAGE_DEV" | cut -d"/" -f3)
#STORAGE=$(lsblk -x SIZE | grep sd[a-z]1 | awk '{print $1}' | sort | head -n 1) while [ -z ${STORAGE} ]
while [ -z "${STORAGE}" ]
do do
sleep 1 sleep 1
STORAGE=$(ls /dev/* | grep "$STORAGE_DEV" | cut -d"/" -f3) STORAGE=$(ls /dev/* | grep "$STORAGE_DEV" | cut -d"/" -f3)
@@ -34,11 +41,19 @@ done
# When the USB storage device is detected, mount it # When the USB storage device is detected, mount it
mount /dev/"$STORAGE_DEV" "$STORAGE_MOUNT_POINT" mount /dev/"$STORAGE_DEV" "$STORAGE_MOUNT_POINT"
# Cancel shutdown
sudo shutdown -c
# Set the ACT LED to blink at 1000ms to indicate that the storage device has been mounted # Set the ACT LED to blink at 1000ms to indicate that the storage device has been mounted
sudo sh -c "echo timer > /sys/class/leds/led0/trigger" sudo sh -c "echo timer > /sys/class/leds/led0/trigger"
sudo sh -c "echo 1000 > /sys/class/leds/led0/delay_on" sudo sh -c "echo 1000 > /sys/class/leds/led0/delay_on"
# Reload minidlna # Perform backup using rsync
rsync -av "$SOURCE_DIR" "$STORAGE_MOUNT_POINT"
sudo minidlnad -R # Turn off the ACT LED to indicate that the backup is completed
sudo service minidlna restart sudo sh -c "echo 0 > /sys/class/leds/led0/brightness"
# Shutdown
sync
shutdown -h now

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

55
scripts/gpio Normal file
View File

@@ -0,0 +1,55 @@
#!/bin/bash
# Utility to control the GPIO pins of the Raspberry Pi
# Can be called as a script or sourced so that the gpio
# function can be called directly
function gpio()
{
local verb=$1
local pin=$2
local value=$3
local pins=($GPIO_PINS)
if [[ "$pin" -lt ${#pins[@]} ]]; then
local pin=${pins[$pin]}
fi
local gpio_path=/sys/class/gpio
local pin_path=$gpio_path/gpio$pin
case $verb in
read)
cat $pin_path/value
;;
write)
sudo sh -c "echo $value > $pin_path/value"
;;
mode)
if [ ! -e $pin_path ]; then
sudo sh -c "echo $pin > $gpio_path/export"
fi
sudo sh -c "echo $value > $pin_path/direction"
;;
state)
if [ -e $pin_path ]; then
local dir=$(cat $pin_path/direction)
local val=$(cat $pin_path/value)
echo "$dir $val"
fi
;;
clean)
sudo sh -c "echo 0 > $pin_path/value"
sudo sh -c "echo $pin > $gpio_path/unexport"
;;
esac
}
# Just invoke our function if the script is called directly
if [ "$BASH_SOURCE" == "$0" ]; then
gpio $@
fi

View File

@@ -1,64 +0,0 @@
<html lang="en">
<!-- Author: Dmitri Popov, dmpop@linux.com
License: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt -->
<head>
<meta charset="utf-8">
<title>Little Backup Box</title>
<link rel="shortcut icon" href="favicon.png" />
<link rel="stylesheet" href="milligram.min.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#content {
margin: 0px auto;
text-align: center;
}
h2 {
letter-spacing: 3px;
}
img {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 1%;
margin-bottom: 1%;
}
</style>
</head>
<body>
<div id="content">
<a href="/"><img src="tokyo-taxi.svg" height="51px" alt="Tokyo taxi"></a>
<h2>Little Backup Box</h2>
<p><a href="sysinfo.php">System info</a></p>
<p>Back up a storage card connected via a card reader</p>
<p>
<form method="post">
<button name="cardbackup">Card backup</button>
</form>
</p>
<p class="left">Shut down the Little Backup Box</p>
<p>
<form method="post">
<button class="button button-outline" name="shutdown">Shut down</button>
</form>
</p>
<?php
if (isset($_POST['cardbackup']))
{
shell_exec('bash ./card-backup.sh > /dev/null 2>&1 & echo $!');
echo "<p>OK</p>";
}
if (isset($_POST['shutdown']))
{
shell_exec('sudo shutdown -h now > /dev/null 2>&1 & echo $!');
echo "<p>OK</p>";
}
?>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

24
scripts/rc.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
#!/usr/bin/env bash
# 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 3 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, see <http://www.gnu.org/licenses/>.
while :
do
if [[ ! $(pgrep -f rc.py) ]]; then
cd /home/pi/little-backup-box/rc/
sudo python3 rc.py
fi
done

View File

@@ -1,54 +0,0 @@
<html lang="en">
<!-- Author: Dmitri Popov, dmpop@linux.com
License: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt -->
<head>
<meta charset="utf-8">
<title>Little Backup Box</title>
<link rel="shortcut icon" href="ichigo.png" />
<link rel="stylesheet" href="milligram.min.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#content {
margin: 0px auto;
text-align: center;
}
img {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 1%;
margin-bottom: 1%;
}
</style>
</head>
<body>
<div id="content">
<a href="/"><img src="ichigo.svg" height="39px" alt="Ichigo"></a>
<h1>Little Backup Box</h1>
<p>Basic system information</p>
<h2>Devices</h2>
<div style="display: inline-block; text-align: left;">
<?php
echo '<pre>';
passthru("lsblk");
echo '</pre>';
?>
</div>
<h2>Memory (in MB)</h2>
<div style="display: inline-block; text-align: left;">
<?php
echo '<pre>';
passthru("free -m");
echo '</pre>';
?>
</div>
<form>
<input type="button" onClick="history.go(0)" value="Refresh">
</form>
<p>Read the <a href="https://gumroad.com/l/linux-photography">Linux Photography</a> book</p>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 45 KiB