From 82fbfca6a8c116d097847905ee6cab70b37aafe4 Mon Sep 17 00:00:00 2001 From: Dmitri Popov Date: Tue, 20 Mar 2018 10:03:05 +0100 Subject: [PATCH] Add WebUI --- backup.sh | 13 ++++++ gphoto-backup.sh | 13 ++++++ install-little-backup-box.sh | 13 ++++++ webui.py | 76 ++++++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100755 webui.py diff --git a/backup.sh b/backup.sh index eb8d55e..77a2085 100755 --- a/backup.sh +++ b/backup.sh @@ -1,5 +1,18 @@ #!/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 . + # IMPORTANT: # Run the install-little-backup-box.sh script first # to install the required packages and configure the system. diff --git a/gphoto-backup.sh b/gphoto-backup.sh index 30040e3..ed816a2 100755 --- a/gphoto-backup.sh +++ b/gphoto-backup.sh @@ -1,5 +1,18 @@ #!/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 . + # IMPORTANT: # Run the install-little-backup-box.sh script first # to install the required packages and configure the system. diff --git a/install-little-backup-box.sh b/install-little-backup-box.sh index 6ba367e..274dea5 100755 --- a/install-little-backup-box.sh +++ b/install-little-backup-box.sh @@ -1,5 +1,18 @@ #!/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 . + sudo apt update && sudo apt dist-upgrade -y && sudo apt install acl git-core screen rsync exfat-fuse exfat-utils ntfs-3g minidlna gphoto2 libimage-exiftool-perl -y sudo mkdir /media/card diff --git a/webui.py b/webui.py new file mode 100755 index 0000000..18f4116 --- /dev/null +++ b/webui.py @@ -0,0 +1,76 @@ + +#!/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 . + +from bottle import post, route, request, run +import os + +@route('/') +@route('/', method='POST') +def control(): + if (request.POST.get("cardbackup")): + os.system("sudo /home/pi/little-backup-box/backup.sh") + if (request.POST.get("camerabackup")): + os.system("sudo /home/pi/little-backup-box/backup.sh") + if (request.POST.get("shutdown")): + os.system("sudo shutdown -h now") + return """ + Little Backup Box + +
+

+

+

+ +

Press Card backup to back up a storage card connected via a card reader.

+

Press Camera backup to transfer files directly from the connected camera.

+

Press Shutdown to shut down the Little Backup Box.

+
+ + """ + +run(host="0.0.0.0",port=8080, debug=True, reloader=True)