2015-01-16 20:46:15 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# .---. . .
|
|
|
|
# | | |
|
|
|
|
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
|
|
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
|
|
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
|
|
#
|
|
|
|
# Freedom in the Cloud
|
|
|
|
#
|
|
|
|
# This install script is intended for use with Debian Jessie
|
|
|
|
#
|
|
|
|
# License
|
|
|
|
# =======
|
|
|
|
#
|
2016-01-02 22:58:27 +01:00
|
|
|
# Copyright (C) 2014-2016 Bob Mottram <bob@robotics.uk.to>
|
2015-01-16 20:46:15 +01:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2016-02-13 23:09:27 +01:00
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
2015-01-16 20:46:15 +01:00
|
|
|
# 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
|
2016-02-13 23:09:27 +01:00
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
2015-01-16 20:46:15 +01:00
|
|
|
#
|
2016-02-13 23:09:27 +01:00
|
|
|
# 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/>.
|
2015-01-16 20:46:15 +01:00
|
|
|
|
2015-01-16 22:05:12 +01:00
|
|
|
NO_OF_ARGS=$#
|
|
|
|
|
2015-11-27 12:42:16 +01:00
|
|
|
PROJECT_NAME='freedombone'
|
|
|
|
|
|
|
|
export TEXTDOMAIN=$PROJECT_NAME
|
|
|
|
export TEXTDOMAINDIR="/usr/share/locale"
|
|
|
|
|
2015-12-02 21:25:48 +01:00
|
|
|
DEFAULT_LANGUAGE=$(echo $LANG)
|
2015-12-02 15:33:56 +01:00
|
|
|
|
2016-07-03 17:13:34 +02:00
|
|
|
PROJECT_INSTALL_DIR=/usr/local/bin
|
|
|
|
if [ -f /usr/bin/${PROJECT_NAME} ]; then
|
|
|
|
PROJECT_INSTALL_DIR=/usr/bin
|
2016-06-30 15:59:43 +02:00
|
|
|
fi
|
|
|
|
|
2015-11-29 15:54:30 +01:00
|
|
|
# username created by default within a debian image
|
|
|
|
GENERIC_IMAGE_USERNAME='fbone'
|
|
|
|
|
2015-01-20 22:18:24 +01:00
|
|
|
# Web site
|
2016-01-25 18:16:51 +01:00
|
|
|
PROJECT_WEBSITE="http://${PROJECT_NAME}.uk.to"
|
2015-01-20 22:18:24 +01:00
|
|
|
|
2015-11-26 10:46:20 +01:00
|
|
|
# Repo
|
2016-01-25 18:16:51 +01:00
|
|
|
PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
|
2015-11-26 10:46:20 +01:00
|
|
|
|
2015-01-16 20:46:15 +01:00
|
|
|
# Are we installing on a Beaglebone Black (BBB) or some other system?
|
|
|
|
INSTALLING_ON_BBB="no"
|
|
|
|
|
|
|
|
# Version number of this script
|
2015-07-09 19:59:43 +02:00
|
|
|
VERSION="1.01"
|
2015-01-16 20:46:15 +01:00
|
|
|
|
2015-11-30 15:25:09 +01:00
|
|
|
# if yes then this minimises the number of descisions presented during install
|
|
|
|
MINIMAL_INSTALL="yes"
|
|
|
|
|
2015-12-30 19:54:31 +01:00
|
|
|
# Whether web sites will be .onion addresses only
|
|
|
|
ONION_ONLY="no"
|
|
|
|
|
2015-02-01 22:18:25 +01:00
|
|
|
# whether the system is being installed from a pre-created configuration file
|
|
|
|
INSTALLING_FROM_CONFIGURATION_FILE="no"
|
|
|
|
|
2015-01-16 20:46:15 +01:00
|
|
|
# number of CPU cores
|
|
|
|
CPU_CORES=1
|
|
|
|
|
|
|
|
# whether to route outgoing traffic through Tor
|
|
|
|
ROUTE_THROUGH_TOR="no"
|
|
|
|
|
|
|
|
# Whether this system is being installed within a docker container
|
|
|
|
INSTALLED_WITHIN_DOCKER="no"
|
|
|
|
|
|
|
|
DEBIAN_VERSION="jessie"
|
|
|
|
|
2015-07-01 14:16:07 +02:00
|
|
|
# social key management
|
|
|
|
ENABLE_SOCIAL_KEY_MANAGEMENT="no"
|
|
|
|
|
2016-07-03 17:13:34 +02:00
|
|
|
# include utils
|
|
|
|
UTILS_FILES=$PROJECT_INSTALL_DIR/${PROJECT_NAME}-utils-*
|
|
|
|
for f in $UTILS_FILES
|
|
|
|
do
|
|
|
|
source $f
|
|
|
|
done
|
2016-06-18 15:14:54 +02:00
|
|
|
|
2016-07-03 17:13:34 +02:00
|
|
|
#include apps
|
|
|
|
APP_FILES=$PROJECT_INSTALL_DIR/${PROJECT_NAME}-app-*
|
|
|
|
for f in $UTILS_FILES
|
|
|
|
do
|
|
|
|
source $f
|
|
|
|
done
|
2016-06-18 15:14:54 +02:00
|
|
|
|
2016-07-03 17:13:34 +02:00
|
|
|
# optionally specify your name to appear on the blog
|
|
|
|
MY_NAME=$DEFAULT_DOMAIN_NAME
|
2015-01-17 23:03:17 +01:00
|
|
|
|
2015-11-30 15:25:09 +01:00
|
|
|
command_options=$1
|
|
|
|
|
2015-12-31 14:21:46 +01:00
|
|
|
if [[ $command_options == "menuconfig-full" ]]; then
|
2016-06-18 15:14:54 +02:00
|
|
|
MINIMAL_INSTALL="no"
|
|
|
|
command_options="menuconfig"
|
2015-11-30 15:25:09 +01:00
|
|
|
fi
|
|
|
|
|
2015-12-31 14:21:46 +01:00
|
|
|
if [[ $command_options == "menuconfig-onion" ]]; then
|
2016-06-18 15:14:54 +02:00
|
|
|
MINIMAL_INSTALL="yes"
|
|
|
|
ONION_ONLY="yes"
|
|
|
|
command_options="menuconfig"
|
2015-12-31 14:21:46 +01:00
|
|
|
fi
|
|
|
|
|
2015-11-30 15:25:09 +01:00
|
|
|
if [[ $command_options == "menuconfig" ]]; then
|
2016-06-18 15:14:54 +02:00
|
|
|
interactive_configuration
|
2015-01-17 23:03:17 +01:00
|
|
|
else
|
2016-06-18 15:14:54 +02:00
|
|
|
while [[ $# > 1 ]]
|
|
|
|
do
|
|
|
|
key="$1"
|
|
|
|
|
|
|
|
case $key in
|
|
|
|
-h|--help)
|
|
|
|
show_help
|
|
|
|
;;
|
|
|
|
# load a configuration file
|
|
|
|
-c|--config)
|
|
|
|
shift
|
|
|
|
CONFIGURATION_FILE="$1"
|
|
|
|
INSTALLING_FROM_CONFIGURATION_FILE="yes"
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
# username within /home
|
|
|
|
-u|--user)
|
|
|
|
shift
|
|
|
|
MY_USERNAME="$1"
|
|
|
|
;;
|
|
|
|
# microblog domain name
|
|
|
|
--microblogdomain)
|
|
|
|
shift
|
|
|
|
MICROBLOG_DOMAIN_NAME="$1"
|
|
|
|
;;
|
|
|
|
# wiki domain name
|
|
|
|
--wikidomain)
|
|
|
|
shift
|
|
|
|
WIKI_DOMAIN_NAME="$1"
|
|
|
|
;;
|
|
|
|
# blog domain name
|
|
|
|
--blogdomain)
|
|
|
|
shift
|
|
|
|
FULLBLOG_DOMAIN_NAME="$1"
|
|
|
|
;;
|
|
|
|
# hubzilla domain name
|
|
|
|
--hubzilladomain)
|
|
|
|
shift
|
|
|
|
HUBZILLA_DOMAIN_NAME="$1"
|
|
|
|
;;
|
|
|
|
# git hosting domain name
|
|
|
|
--gitdomain)
|
|
|
|
shift
|
|
|
|
GIT_DOMAIN_NAME="$1"
|
|
|
|
;;
|
|
|
|
# default domain name
|
|
|
|
-d|--domain)
|
|
|
|
shift
|
|
|
|
DEFAULT_DOMAIN_NAME="$1"
|
|
|
|
;;
|
|
|
|
# The type of system
|
|
|
|
-s|--system)
|
|
|
|
shift
|
|
|
|
SYSTEM_TYPE="$1"
|
|
|
|
;;
|
|
|
|
# The dynamic DNS provider
|
|
|
|
--ddns)
|
|
|
|
shift
|
|
|
|
DDNS_PROVIDER="$1"
|
|
|
|
;;
|
|
|
|
# Username for the synamic DNS provider
|
|
|
|
--ddnsuser)
|
|
|
|
shift
|
|
|
|
DDNS_USERNAME="$1"
|
|
|
|
;;
|
|
|
|
# Password for the synamic DNS provider
|
|
|
|
--ddnspass)
|
|
|
|
shift
|
|
|
|
DDNS_PASSWORD="$1"
|
|
|
|
;;
|
|
|
|
# Whether this installation is on a Beaglebone Black
|
|
|
|
--bbb)
|
|
|
|
INSTALLING_ON_BBB="yes"
|
|
|
|
;;
|
|
|
|
# Domain name to use as a TLS time source
|
|
|
|
-t|--time)
|
|
|
|
shift
|
|
|
|
TLS_TIME_SOURCE1="$1"
|
|
|
|
;;
|
|
|
|
# Static IP address for the system
|
|
|
|
--ip)
|
|
|
|
shift
|
|
|
|
LOCAL_NETWORK_STATIC_IP_ADDRESS=$1
|
|
|
|
;;
|
|
|
|
# IP address for the internet router
|
|
|
|
--iprouter)
|
|
|
|
shift
|
|
|
|
ROUTER_IP_ADDRESS=$1
|
|
|
|
;;
|
|
|
|
# ssh port
|
|
|
|
--ssh)
|
|
|
|
shift
|
|
|
|
SSH_PORT=$1
|
|
|
|
;;
|
|
|
|
# public mailing list name
|
|
|
|
--list)
|
|
|
|
shift
|
|
|
|
PUBLIC_MAILING_LIST="$1"
|
|
|
|
;;
|
|
|
|
# Number of CPU cores
|
|
|
|
--cores)
|
|
|
|
shift
|
|
|
|
CPU_CORES=$1
|
|
|
|
;;
|
|
|
|
# my name
|
|
|
|
--name)
|
|
|
|
shift
|
|
|
|
MY_NAME="$1"
|
|
|
|
;;
|
|
|
|
# my email address
|
|
|
|
--email)
|
|
|
|
shift
|
|
|
|
MY_EMAIL_ADDRESS="$1"
|
|
|
|
;;
|
|
|
|
# USB drive
|
|
|
|
--usb)
|
|
|
|
shift
|
|
|
|
USB_DRIVE=$1
|
|
|
|
;;
|
|
|
|
# Enable CJDNS
|
|
|
|
--cjdns)
|
|
|
|
shift
|
|
|
|
ENABLE_CJDNS="yes"
|
|
|
|
;;
|
|
|
|
# Enable B.A.T.M.A.N
|
|
|
|
--batman)
|
|
|
|
shift
|
|
|
|
ENABLE_BATMAN="yes"
|
|
|
|
;;
|
|
|
|
# Enable Babel
|
|
|
|
--babel)
|
|
|
|
shift
|
|
|
|
ENABLE_BABEL="yes"
|
|
|
|
;;
|
|
|
|
# VoIP server password
|
|
|
|
--vpass)
|
|
|
|
shift
|
|
|
|
VOIP_SERVER_PASSWORD=$1
|
|
|
|
;;
|
|
|
|
# VoIP server port
|
|
|
|
--vport)
|
|
|
|
shift
|
|
|
|
VOIP_PORT=$1
|
|
|
|
;;
|
|
|
|
# DNS Nameserver 1
|
|
|
|
--ns1)
|
|
|
|
shift
|
|
|
|
NAMESERVER1=$1
|
|
|
|
;;
|
|
|
|
# DNS Nameserver 2
|
|
|
|
--ns2)
|
|
|
|
shift
|
|
|
|
NAMESERVER2=$1
|
|
|
|
;;
|
|
|
|
# Debian repository
|
|
|
|
--repo)
|
|
|
|
shift
|
|
|
|
DEBIAN_REPO=$1
|
|
|
|
;;
|
|
|
|
# minimal install
|
|
|
|
--minimal)
|
|
|
|
shift
|
|
|
|
MINIMAL_INSTALL=$1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# unknown option
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2015-01-17 23:03:17 +01:00
|
|
|
fi
|
2015-01-16 22:05:12 +01:00
|
|
|
|
2015-01-16 20:46:15 +01:00
|
|
|
function parse_args {
|
2016-06-18 15:14:54 +02:00
|
|
|
if [[ $NO_OF_ARGS == 0 ]]; then
|
|
|
|
echo 'no_of_args = 0'
|
|
|
|
show_help
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d /home/$MY_USERNAME ]; then
|
|
|
|
echo $"There is no user '$MY_USERNAME' on the system. Use 'adduser $MY_USERNAME' to create the user."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ ! "$DEFAULT_DOMAIN_NAME" ]; then
|
|
|
|
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
|
|
|
|
echo 'No default domain specified'
|
|
|
|
show_help
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ ! $MY_USERNAME ]; then
|
|
|
|
echo 'No username specified'
|
|
|
|
show_help
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
|
|
|
|
if [[ $ONION_ONLY == "no" ]]; then
|
|
|
|
if [ ! $DDNS_USERNAME ]; then
|
|
|
|
echo $'Please provide the username for your dynamic DNS provider with the --ddnsuser option'
|
|
|
|
exit 7823
|
|
|
|
fi
|
|
|
|
if [ ! $DDNS_PASSWORD ]; then
|
|
|
|
echo $'Please provide the password for your dynamic DNS provider with the --ddnspass option'
|
|
|
|
exit 6382
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ ! $SYSTEM_TYPE ]; then
|
|
|
|
SYSTEM_TYPE=$VARIANT_FULL
|
|
|
|
fi
|
|
|
|
if [[ $SYSTEM_TYPE != $VARIANT_WRITER && $SYSTEM_TYPE != $VARIANT_CLOUD && $SYSTEM_TYPE != $VARIANT_CHAT && $SYSTEM_TYPE != $VARIANT_MAILBOX && $SYSTEM_TYPE != $VARIANT_NONMAILBOX && $SYSTEM_TYPE != $VARIANT_SOCIAL && $SYSTEM_TYPE != $VARIANT_MEDIA && $SYSTEM_TYPE != $VARIANT_DEVELOPER && $SYSTEM_TYPE != $VARIANT_MESH && $SYSTEM_TYPE != $VARIANT_FULL ]]; then
|
|
|
|
echo $"'$SYSTEM_TYPE' is an unrecognised ${PROJECT_NAME} variant."
|
|
|
|
exit 30
|
|
|
|
fi
|
2015-01-16 20:46:15 +01:00
|
|
|
}
|
|
|
|
|
2016-07-03 20:21:47 +02:00
|
|
|
setup_utils
|
2016-07-03 17:13:34 +02:00
|
|
|
setup_mesh
|
|
|
|
setup_email
|
|
|
|
setup_web
|
|
|
|
script_for_attaching_usb_drive
|
|
|
|
setup_apps
|
|
|
|
setup_final
|
2016-06-18 15:14:54 +02:00
|
|
|
|
2015-12-29 17:42:35 +01:00
|
|
|
echo "${PROJECT_NAME} installation is complete"
|
2015-01-16 20:46:15 +01:00
|
|
|
exit 0
|