freedombone/src/freedombone-app-librevault

183 lines
5.2 KiB
Plaintext
Raw Normal View History

2016-08-24 20:41:57 +02:00
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Librevault application
#
# License
# =======
#
# Copyright (C) 2014-2016 Bob Mottram <bob@robotics.uk.to>
#
# 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 <http://www.gnu.org/licenses/>.
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
2016-08-24 23:45:45 +02:00
if [ $LIBREVAULT_PORT ]; then
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
fi
2016-08-24 20:41:57 +02:00
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
}
function configure_firewall_for_librevault {
if grep -Fxq "configure_firewall_for_librevault" $COMPLETION_FILE; then
return
fi
2016-08-24 23:45:45 +02:00
if [ $LIBREVAULT_PORT ]; then
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")
fi
2016-08-24 20:41:57 +02:00
echo 'configure_firewall_for_librevault' >> $COMPLETION_FILE
}
2016-08-24 23:45:45 +02:00
function mesh_install_librevault {
install_tracker
chroot "$rootdir" apt-get -y -t jessie-backports install cmake
chroot "$rootdir" apt-get -y install bittornado nginx
chroot "$rootdir" apt-get -y install build-essential libboost-all-dev libssl-dev
chroot "$rootdir" apt-get -y install qtbase5-dev libqt5svg5-dev libqt5websockets5-dev
chroot "$rootdir" apt-get -y install autoconf automake libtool curl make g++ unzip
if [ ! -d $rootdir$INSTALL_DIR ]; then
chroot "$rootdir" mkdir -p $INSTALL_DIR
fi
chroot "$rootdir" git clone $PROTOBUF_REPO $rootdir$INSTALL_DIR/protobuf
cd $rootdir$INSTALL_DIR/protobuf
git checkout $PROTOBUF_COMMIT -b $PROTOBUF_COMMIT
cat <<EOF > $rootdir/root/install_protobuf
cd $INSTALL_DIR/protobuf
./autogen.sh
./configure
make
make install
ldconfig
EOF
chroot "$rootdir" chmod +x /root/install_protobuf
chroot "$rootdir" /root/install_protobuf
git_clone $LIBREVAULT_REPO $rootdir$INSTALL_DIR/librevault
cd $rootdir$INSTALL_DIR/librevault
git checkout $LIBREVAULT_COMMIT -b $LIBREVAULT_COMMIT
mkdir $rootdir$INSTALL_DIR/librevault/build
cat <<EOF > $rootdir/root/install_librevault
cd $INSTALL_DIR/librevault/build
cmake ..
cmake --build .
make install
EOF
chroot "$rootdir" chmod +x /root/install_librevault
chroot "$rootdir" /root/install_librevault
2016-08-24 20:41:57 +02:00
}
2016-08-24 23:45:45 +02:00
function install_librevault {
2016-08-24 20:41:57 +02:00
if [ $INSTALLING_MESH ]; then
mesh_install_librevault
return
fi
if grep -Fxq "install_librevalut" $COMPLETION_FILE; then
return
fi
2016-08-24 23:45:45 +02:00
install_tracker
apt-get -y -t jessie-backports install cmake
apt-get -y install build-essential libboost-all-dev libssl-dev
2016-08-24 20:41:57 +02:00
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 .
2016-08-24 23:45:45 +02:00
make install
2016-08-24 20:41:57 +02:00
echo 'install_librevault' >> $COMPLETION_FILE
}
# NOTE: deliberately no exit 0