From dd105dc87d1d12064580aa19ea7f5b025d5f7fde Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 24 Aug 2016 19:41:57 +0100 Subject: [PATCH] Beginning of librevault --- src/freedombone-app-librevault | 137 +++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100755 src/freedombone-app-librevault diff --git a/src/freedombone-app-librevault b/src/freedombone-app-librevault new file mode 100755 index 00000000..ad03536c --- /dev/null +++ b/src/freedombone-app-librevault @@ -0,0 +1,137 @@ +#!/bin/bash +# +# .---. . . +# | | | +# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-. +# | | (.-' (.-' ( | ( )| | | | )( )| | (.-' +# ' ' --' --' -' - -' ' ' -' -' -' ' - --' +# +# Freedom in the Cloud +# +# Librevault application +# +# License +# ======= +# +# Copyright (C) 2014-2016 Bob Mottram +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +VARIANTS='none' + +PROTOBUF_REPO="https://github.com/google/protobuf" +PROTOBUF_COMMIT='b97a4a53cdd55be74c30badefeb132a091764f53' + +LIBREVAULT_REPO="https://github.com/Librevault/librevault" +LIBREVAULT_COMMIT='86a6aefcb5cc458f4d42195368fbcff2871f98e3' +LIBREVAULT_PORT= + +function reconfigure_librevault { + echo -n '' + # TODO +} + +function upgrade_librevault { + echo -n '' + # TODO +} + +function backup_local_librevault { + # TODO +} + +function restore_local_librevault { + # TODO +} + +function backup_remote_librevault { + # TODO +} + +function restore_remote_librevault { + # TODO +} + +function remove_librevault { + if ! grep -Fxq "install_librevault" $COMPLETION_FILE; then + return + fi + iptables -D INPUT -p udp --dport $LIBREVAULT_PORT -j ACCEPT + iptables -D INPUT -p tcp --dport $LIBREVAULT_PORT -j ACCEPT + function_check save_firewall_settings + save_firewall_settings + + systemctl stop librevault + systemctl disable librevault + rm /etc/systemd/system/librevault.service + sed -i '/install_librevault/d' $COMPLETION_FILE + sed -i '/configure_firewall_for_librevault/d' $COMPLETION_FILE + systemctl restart cron +} + +function configure_firewall_for_librevault { + if grep -Fxq "configure_firewall_for_librevault" $COMPLETION_FILE; then + return + fi + iptables -A INPUT -p udp --dport $LIBREVAULT_PORT -j ACCEPT + iptables -A INPUT -p tcp --dport $LIBREVAULT_PORT -j ACCEPT + function_check save_firewall_settings + save_firewall_settings + + OPEN_PORTS+=("Librevault $LIBREVAULT_PORT") + echo 'configure_firewall_for_librevault' >> $COMPLETION_FILE +} + +function mesh_install_syncthing { +} + +function install_syncthing { + if [ $INSTALLING_MESH ]; then + mesh_install_librevault + return + fi + + if grep -Fxq "install_librevalut" $COMPLETION_FILE; then + return + fi + + apt-get -y install build-essential cmake libboost-all-dev libssl-dev + apt-get -y install qtbase5-dev libqt5svg5-dev libqt5websockets5-dev + apt-get -y install autoconf automake libtool curl make g++ unzip + + if [ ! -d $INSTALL_DIR ]; then + mkdir -p $INSTALL_DIR + fi + git_clone $PROTOBUF_REPO $INSTALL_DIR/protobuf + cd $INSTALL_DIR/protobuf + git checkout $PROTOBUF_COMMIT -b $PROTOBUF_COMMIT + ./autogen.sh + ./configure + make + make check + make install + ldconfig + + git_clone $LIBREVAULT_REPO $INSTALL_DIR/librevault + cd $INSTALL_DIR/librevault + git checkout $LIBREVAULT_COMMIT -b $LIBREVAULT_COMMIT + mkdir $INSTALL_DIR/librevault/build + cd $INSTALL_DIR/librevault/build + cmake .. + cmake --build . + + echo 'install_librevault' >> $COMPLETION_FILE +} + +# NOTE: deliberately no exit 0