freedombone/src/freedombone

371 lines
9.7 KiB
Plaintext
Raw Permalink Normal View History

2015-01-16 20:46:15 +01:00
#!/bin/bash
2018-04-08 14:30:21 +02:00
# _____ _ _
# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
# | __| _| -_| -_| . | . | | . | . | | -_|
# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
2015-01-16 20:46:15 +01:00
#
2018-04-08 14:30:21 +02:00
# Freedom in the Cloud
2015-01-16 20:46:15 +01:00
#
# This install script is intended for use with Debian Jessie
#
# License
# =======
#
2018-01-25 19:35:39 +01:00
# Copyright (C) 2014-2018 Bob Mottram <bob@freedombone.net>
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"
2016-07-03 17:13:34 +02:00
PROJECT_INSTALL_DIR=/usr/local/bin
if [ -f /usr/bin/${PROJECT_NAME} ]; then
2016-09-29 10:59:19 +02:00
PROJECT_INSTALL_DIR=/usr/bin
2016-06-30 15:59:43 +02:00
fi
2016-07-05 16:48:36 +02:00
source $PROJECT_INSTALL_DIR/${PROJECT_NAME}-vars
2015-01-16 20:46:15 +01:00
2018-02-26 14:50:40 +01:00
UTILS_FILES="/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*"
2016-10-08 13:47:07 +02:00
for f in $UTILS_FILES
do
2018-02-26 14:50:40 +01:00
source "$f"
2016-10-08 13:47:07 +02:00
done
2015-01-16 20:46:15 +01:00
2018-02-26 14:50:40 +01:00
APP_FILES="/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*"
2016-10-08 13:47:07 +02:00
for f in $APP_FILES
do
2018-02-26 14:50:40 +01:00
source "$f"
2016-10-08 13:47:07 +02:00
done
2015-01-17 23:03:17 +01:00
2018-02-26 14:50:40 +01:00
command_options="$1"
2018-02-26 14:50:40 +01:00
if [[ "$command_options" == "menuconfig-full" ]]; then
2016-08-06 17:06:45 +02:00
MINIMAL_INSTALL="no"
fi
2018-02-26 14:50:40 +01:00
if [[ "$command_options" == "menuconfig-onion" ]]; then
2016-08-06 17:06:45 +02:00
MINIMAL_INSTALL="yes"
ONION_ONLY="yes"
2015-12-31 14:21:46 +01:00
fi
2018-02-26 14:50:40 +01:00
if [[ "$command_options" == "menuconfig-gnusocial" ]]; then
2017-06-16 16:39:48 +02:00
MINIMAL_INSTALL="yes"
ONION_ONLY="no"
SOCIALINSTANCE='gnusocial'
fi
2018-02-26 14:50:40 +01:00
if [[ "$command_options" == "menuconfig-postactiv" ]]; then
2017-06-16 16:39:48 +02:00
MINIMAL_INSTALL="yes"
ONION_ONLY="no"
SOCIALINSTANCE='postactiv'
fi
2018-03-12 11:36:13 +01:00
if [[ "$command_options" == "menuconfig-pleroma" ]]; then
MINIMAL_INSTALL="yes"
ONION_ONLY="no"
SOCIALINSTANCE='pleroma'
fi
2018-02-26 14:50:40 +01:00
if [ ! "$CONFIGURATION_FILE" ]; then
CONFIGURATION_FILE="$HOME/${PROJECT_NAME}.cfg"
2016-10-15 17:33:13 +02:00
fi
2018-02-26 14:50:40 +01:00
if [ ! "$COMPLETION_FILE" ]; then
COMPLETION_FILE="$HOME/${PROJECT_NAME}-completed.txt"
2016-10-15 17:33:13 +02:00
fi
# before the interactive config so that wifi adaptors may be detected
setup_wifi_atheros
2018-02-26 14:50:40 +01:00
if [[ "$command_options" == "menuconfig"* ]]; then
2016-10-15 18:13:22 +02:00
if [[ "$2" == "--reset" ]]; then
2018-02-26 14:50:40 +01:00
if [ -f "$CONFIGURATION_FILE" ]; then
rm "$CONFIGURATION_FILE"
fi
2018-02-26 14:50:40 +01:00
if [ -f "$COMPLETION_FILE" ]; then
rm "$COMPLETION_FILE"
fi
2018-02-26 14:50:40 +01:00
if [ -f "/usr/share/${PROJECT_NAME}/installed.txt" ]; then
rm "/usr/share/${PROJECT_NAME}/installed.txt"
2016-10-17 19:13:28 +02:00
fi
if [ -f /root/removed ]; then
rm /root/removed
fi
fi
# clear the interactive file which indicates configuration success
2018-02-26 14:50:40 +01:00
interactive_file="$HOME/.${PROJECT_NAME}-interactive"
if [ -f "$interactive_file" ]; then
rm "$interactive_file"
fi
2016-09-29 10:59:19 +02:00
interactive_configuration
# check that the interactive file was created
2018-02-26 14:50:40 +01:00
if [ ! -f "$interactive_file" ]; then
exit 6393562
fi
2018-02-26 14:50:40 +01:00
rm "$interactive_file"
2015-01-17 23:03:17 +01:00
else
2018-02-25 12:04:13 +01:00
while [ $# -gt 1 ]
2016-08-06 17:06:45 +02:00
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"
;;
# 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"
;;
# Static IP address for the system
--ip)
shift
2018-02-26 14:50:40 +01:00
LOCAL_NETWORK_STATIC_IP_ADDRESS="$1"
2016-08-06 17:06:45 +02:00
;;
# IP address for the internet router
--iprouter)
shift
2018-02-26 14:50:40 +01:00
ROUTER_IP_ADDRESS="$1"
2016-08-06 17:06:45 +02:00
;;
# 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 B.A.T.M.A.N
--batman)
shift
ENABLE_BATMAN="yes"
;;
# Mumble server password
2016-09-29 10:59:19 +02:00
--vpass)
shift
2018-02-26 14:50:40 +01:00
MUMBLE_SERVER_PASSWORD="$1"
2016-09-29 10:59:19 +02:00
;;
# Mumble server port
2016-09-29 10:59:19 +02:00
--vport)
shift
2018-02-26 14:50:40 +01:00
MUMBLE_PORT="$1"
2016-08-06 17:06:45 +02:00
;;
# DNS Nameserver 1
--ns1)
shift
2018-02-26 14:50:40 +01:00
NAMESERVER1="$1"
2016-08-06 17:06:45 +02:00
;;
# DNS Nameserver 2
--ns2)
shift
2018-02-26 14:50:40 +01:00
NAMESERVER2="$1"
2016-08-06 17:06:45 +02:00
;;
2016-12-07 17:57:57 +01:00
# DNS Nameserver 3
--ns3)
shift
2018-02-26 14:50:40 +01:00
NAMESERVER3="$1"
2016-12-07 17:57:57 +01:00
;;
# DNS Nameserver 4
--ns4)
shift
2018-02-26 14:50:40 +01:00
NAMESERVER4="$1"
2016-12-07 17:57:57 +01:00
;;
# DNS Nameserver 5
--ns5)
shift
2018-02-26 14:50:40 +01:00
NAMESERVER5="$1"
2016-12-07 17:57:57 +01:00
;;
# DNS Nameserver 6
--ns6)
shift
2018-02-26 14:50:40 +01:00
NAMESERVER6="$1"
2016-12-07 17:57:57 +01:00
;;
2016-08-06 17:06:45 +02:00
# Debian repository
--repo)
shift
2018-02-26 14:50:40 +01:00
DEBIAN_REPO="$1"
2016-08-06 17:06:45 +02:00
;;
2016-10-15 17:33:13 +02:00
# clear the config file
--reset)
2018-02-26 14:50:40 +01:00
if [ -f "$CONFIGURATION_FILE" ]; then
rm "$CONFIGURATION_FILE"
2016-10-15 17:33:13 +02:00
fi
2018-02-26 14:50:40 +01:00
if [ -f "$COMPLETION_FILE" ]; then
rm "$COMPLETION_FILE"
2016-10-15 17:33:13 +02:00
fi
;;
2016-08-06 17:06:45 +02:00
# minimal install
--minimal)
shift
2018-02-26 14:50:40 +01:00
MINIMAL_INSTALL="$1"
2016-08-06 17:06:45 +02:00
;;
*)
# 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-08-06 17:06:45 +02:00
if [[ $NO_OF_ARGS == 0 ]]; then
echo 'no_of_args = 0'
show_help
exit 0
fi
2016-10-08 13:47:07 +02:00
read_config_param 'DEFAULT_DOMAIN_NAME'
read_config_param 'MY_USERNAME'
read_config_param 'SYSTEM_TYPE'
2016-10-08 19:21:43 +02:00
read_config_param 'ONION_ONLY'
read_config_param 'DDNS_PROVIDER'
read_config_param 'DDNS_USERNAME'
read_config_param 'DDNS_PASSWORD'
2016-10-08 13:47:07 +02:00
2018-02-26 14:50:40 +01:00
if [ ! -d "/home/$MY_USERNAME" ]; then
2016-08-06 17:06:45 +02:00
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
2016-10-08 20:32:04 +02:00
if [[ $SYSTEM_TYPE != "mesh"* ]]; then
2016-08-06 17:06:45 +02:00
echo 'No default domain specified'
show_help
exit 2
fi
fi
2018-02-26 14:50:40 +01:00
if [ ! "$MY_USERNAME" ]; then
2016-08-06 17:06:45 +02:00
echo 'No username specified'
show_help
exit 3
fi
2016-10-08 20:32:04 +02:00
if [[ $SYSTEM_TYPE != "mesh"* ]]; then
2017-05-21 11:20:45 +02:00
if [[ "$DDNS_PROVIDER" != 'none' ]]; then
if [[ $ONION_ONLY == "no" ]]; then
2018-02-26 14:50:40 +01:00
if [ ! "$DDNS_USERNAME" ]; then
echo $'Please provide the username for your dynamic DNS provider with the --ddnsuser option'
exit 7823
fi
2018-02-26 14:50:40 +01:00
if [ ! "$DDNS_PASSWORD" ]; then
echo $'Please provide the password for your dynamic DNS provider with the --ddnspass option'
exit 6382
fi
2016-08-06 17:06:45 +02:00
fi
fi
fi
2016-10-08 20:32:04 +02:00
2018-02-26 14:50:40 +01:00
if [ ! "$SYSTEM_TYPE" ]; then
2016-10-08 20:32:04 +02:00
SYSTEM_TYPE=$'full'
2016-10-09 12:02:11 +02:00
write_config_param "SYSTEM_TYPE" "$SYSTEM_TYPE"
2016-09-29 10:59:19 +02:00
fi
2016-10-08 20:32:04 +02:00
if [[ $(is_valid_variant) == "0" ]]; then
2016-10-08 20:55:21 +02:00
echo $"'$SYSTEM_TYPE' is an unrecognised ${PROJECT_NAME} variant. Possible variants are:"
show_available_variants
2016-10-08 20:32:04 +02:00
exit 367245
2016-09-29 10:59:19 +02:00
fi
2015-01-16 20:46:15 +01:00
}
# run some initial tests
2016-10-20 10:40:07 +02:00
clear
2018-02-26 14:50:40 +01:00
if ! "${PROJECT_NAME}-tests"; then
2016-09-29 10:59:19 +02:00
exit 768252
fi
2016-10-20 10:40:07 +02:00
clear
echo ''
echo $'Setting up the base installation'
echo ''
2016-10-23 20:38:14 +02:00
export DEBIAN_FRONTEND=noninteractive
2015-01-16 20:46:15 +01:00
2016-09-29 10:59:19 +02:00
upgrade_installation_from_previous_versions
2016-07-03 20:21:47 +02:00
setup_utils
2016-07-03 17:13:34 +02:00
setup_email
setup_web
2018-02-26 14:50:40 +01:00
setup_apps "$command_options"
2016-07-03 17:13:34 +02:00
setup_final
2015-01-16 20:46:15 +01:00
echo ''
echo $"${PROJECT_NAME} installation is complete."
echo ''
echo $'The default fbone user will be deleted when the system restarts.'
echo $'Next time you login use the username you gave during the install.'
echo ''
2015-01-16 20:46:15 +01:00
exit 0