2016-07-03 17:13:34 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# .---. . .
|
|
|
|
# | | |
|
|
|
|
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
|
|
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
|
|
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
|
|
#
|
|
|
|
# Freedom in the Cloud
|
|
|
|
#
|
|
|
|
# Mumble 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/>.
|
|
|
|
|
2016-10-12 11:49:12 +02:00
|
|
|
VARIANTS='full full-vim chat'
|
2016-07-06 17:47:55 +02:00
|
|
|
|
2016-10-19 22:52:59 +02:00
|
|
|
IN_DEFAULT_INSTALL=1
|
2016-10-19 22:23:11 +02:00
|
|
|
SHOW_ON_ABOUT=1
|
|
|
|
|
2016-10-01 21:39:57 +02:00
|
|
|
# Password used for mumble server
|
|
|
|
MUMBLE_SERVER_PASSWORD=
|
|
|
|
# Port on which mumble server listens
|
|
|
|
MUMBLE_PORT=64738
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-10-01 21:39:57 +02:00
|
|
|
# Location of mumble database and configuration
|
|
|
|
MUMBLE_DATABASE="mumble-server.sqlite"
|
|
|
|
MUMBLE_CONFIG_FILE="mumble-server.ini"
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-10-05 23:33:41 +02:00
|
|
|
mumble_variables=(MY_USERNAME
|
|
|
|
MUMBLE_PORT
|
|
|
|
MUMBLE_SERVER_PASSWORD
|
|
|
|
ONION_ONLY
|
|
|
|
ADMIN_USERNAME)
|
|
|
|
|
2016-09-30 12:34:39 +02:00
|
|
|
function install_interactive_mumble {
|
|
|
|
echo -n ''
|
2016-10-10 20:11:33 +02:00
|
|
|
APP_INSTALLED=1
|
2016-09-30 12:34:39 +02:00
|
|
|
}
|
|
|
|
|
2016-09-25 12:20:41 +02:00
|
|
|
function change_password_mumble {
|
|
|
|
echo -n ''
|
|
|
|
}
|
|
|
|
|
2016-07-09 12:36:12 +02:00
|
|
|
function reconfigure_mumble {
|
2016-09-25 12:20:41 +02:00
|
|
|
echo -n ''
|
2016-07-09 12:36:12 +02:00
|
|
|
}
|
|
|
|
|
2016-07-06 16:01:28 +02:00
|
|
|
function upgrade_mumble {
|
2016-09-25 12:20:41 +02:00
|
|
|
echo -n ''
|
2016-07-06 16:01:28 +02:00
|
|
|
}
|
|
|
|
|
2016-07-06 15:55:09 +02:00
|
|
|
function backup_local_mumble {
|
2016-09-25 12:20:41 +02:00
|
|
|
if [ -f /etc/mumble-server.ini ]; then
|
|
|
|
echo $"Backing up Mumble settings"
|
2016-10-01 21:39:57 +02:00
|
|
|
temp_backup_dir=/root/tempmumblebackup
|
2016-09-25 12:20:41 +02:00
|
|
|
if [ ! -d $temp_backup_dir ]; then
|
|
|
|
mkdir -p $temp_backup_dir
|
|
|
|
fi
|
|
|
|
cp -f /etc/mumble-server.ini $temp_backup_dir
|
|
|
|
cp -f /var/lib/mumble-server/mumble-server.sqlite $temp_backup_dir
|
2016-10-01 21:39:57 +02:00
|
|
|
backup_directory_to_usb $temp_backup_dir mumble
|
2016-09-25 12:20:41 +02:00
|
|
|
echo $"Mumble settings backup complete"
|
|
|
|
fi
|
2016-07-06 15:55:09 +02:00
|
|
|
}
|
|
|
|
|
2016-07-08 17:26:18 +02:00
|
|
|
function restore_local_mumble {
|
2016-10-01 21:39:57 +02:00
|
|
|
if [ -d $USB_MOUNT/backup/mumble ]; then
|
|
|
|
echo $"Restoring mumble settings"
|
|
|
|
temp_restore_dir=/root/tempmumble
|
2016-09-25 12:20:41 +02:00
|
|
|
function_check restore_directory_from_usb
|
2016-10-17 18:11:31 +02:00
|
|
|
restore_directory_from_usb $temp_restore_dir voip
|
2016-10-01 21:39:57 +02:00
|
|
|
restore_directory_from_usb $temp_restore_dir mumble
|
2016-09-25 12:20:41 +02:00
|
|
|
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
rm -rf $temp_restore_dir
|
|
|
|
function_check set_user_permissions
|
|
|
|
set_user_permissions
|
|
|
|
function_check backup_unmount_drive
|
|
|
|
backup_unmount_drive
|
|
|
|
exit 3679
|
|
|
|
fi
|
|
|
|
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
rm -rf $temp_restore_dir
|
|
|
|
function_check set_user_permissions
|
|
|
|
set_user_permissions
|
|
|
|
function_check backup_unmount_drive
|
|
|
|
backup_unmount_drive
|
|
|
|
exit 276
|
|
|
|
fi
|
|
|
|
rm -rf $temp_restore_dir
|
|
|
|
cp /etc/ssl/certs/mumble* /var/lib/mumble-server
|
|
|
|
cp /etc/ssl/private/mumble* /var/lib/mumble-server
|
|
|
|
chown -R mumble-server:mumble-server /var/lib/mumble-server
|
|
|
|
service mumble-server restart
|
|
|
|
fi
|
2016-07-08 17:26:18 +02:00
|
|
|
}
|
|
|
|
|
2016-07-06 15:55:09 +02:00
|
|
|
function backup_remote_mumble {
|
2016-09-25 12:20:41 +02:00
|
|
|
if [ -f /etc/mumble-server.ini ]; then
|
2016-10-01 21:39:57 +02:00
|
|
|
echo $"Backing up mumble settings"
|
|
|
|
if [ ! -d /root/tempmumblebackup ]; then
|
|
|
|
mkdir -p /root/tempmumblebackup
|
2016-09-25 12:20:41 +02:00
|
|
|
fi
|
2016-10-01 21:39:57 +02:00
|
|
|
cp -f /etc/mumble-server.ini /root/tempmumblebackup
|
|
|
|
cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempmumblebackup
|
|
|
|
backup_directory_to_friend /root/tempmumblebackup mumble
|
|
|
|
echo $"Backup of mumble settings complete"
|
2016-09-25 12:20:41 +02:00
|
|
|
fi
|
2016-07-08 17:26:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function restore_remote_mumble {
|
2016-10-01 21:39:57 +02:00
|
|
|
if [ -d $SERVER_DIRECTORY/backup/mumble ]; then
|
2016-09-25 12:20:41 +02:00
|
|
|
echo $"Restoring Mumble settings"
|
2016-10-01 21:39:57 +02:00
|
|
|
temp_restore_dir=/root/tempmumble
|
2016-09-25 12:20:41 +02:00
|
|
|
function_check restore_directory_from_friend
|
2016-10-01 21:39:57 +02:00
|
|
|
restore_directory_from_friend $temp_restore_dir mumble
|
2016-09-25 12:20:41 +02:00
|
|
|
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
rm -rf $temp_restore_dir
|
|
|
|
exit 7823
|
|
|
|
fi
|
|
|
|
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
rm -rf $temp_restore_dir
|
|
|
|
exit 7823
|
|
|
|
fi
|
|
|
|
cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
rm -rf $temp_restore_dir
|
|
|
|
exit 276
|
|
|
|
fi
|
|
|
|
rm -rf $temp_restore_dir
|
|
|
|
cp /etc/ssl/certs/mumble* /var/lib/mumble-server
|
|
|
|
cp /etc/ssl/private/mumble* /var/lib/mumble-server
|
|
|
|
chown -R mumble-server:mumble-server /var/lib/mumble-server
|
|
|
|
service mumble-server restart
|
|
|
|
echo $"Restore of Mumble complete"
|
|
|
|
fi
|
2016-07-04 22:02:22 +02:00
|
|
|
}
|
|
|
|
|
2016-07-03 23:30:26 +02:00
|
|
|
function remove_mumble {
|
2016-09-25 12:20:41 +02:00
|
|
|
apt-get -y remove --purge mumble-server
|
|
|
|
if [[ $ONION_ONLY == "no" ]]; then
|
2016-10-22 11:39:34 +02:00
|
|
|
firewall_remove ${MUMBLE_PORT}
|
2016-09-25 12:20:41 +02:00
|
|
|
fi
|
|
|
|
if [ -f /etc/mumble-server.ini ]; then
|
|
|
|
rm /etc/mumble-server.ini
|
|
|
|
fi
|
2016-10-20 23:02:16 +02:00
|
|
|
remove_certs mumble
|
2016-09-25 12:20:41 +02:00
|
|
|
function_check remove_onion_service
|
2016-10-01 21:39:57 +02:00
|
|
|
remove_onion_service mumble ${MUMBLE_PORT}
|
|
|
|
sed -i '/mumble/d' $COMPLETION_FILE
|
2016-07-03 23:30:26 +02:00
|
|
|
}
|
|
|
|
|
2016-10-01 21:39:57 +02:00
|
|
|
function get_mumble_server_password {
|
2016-09-25 12:20:41 +02:00
|
|
|
if [ -f /home/$MY_USERNAME/README ]; then
|
2016-10-02 13:33:56 +02:00
|
|
|
if grep -q "Mumble server password" /home/$MY_USERNAME/README; then
|
2016-10-01 21:39:57 +02:00
|
|
|
if [ ! $MUMBLE_SERVER_PASSWORD ]; then
|
2016-10-02 13:33:56 +02:00
|
|
|
MUMBLE_SERVER_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Mumble server password" | awk -F ':' '{print $2}' | sed 's/^ *//')
|
2016-09-25 12:20:41 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2016-07-03 17:13:34 +02:00
|
|
|
}
|
|
|
|
|
2016-10-01 21:39:57 +02:00
|
|
|
function configure_firewall_for_mumble {
|
2016-10-16 20:50:56 +02:00
|
|
|
if [[ $(is_completed $FUNCNAME) == "1" ]]; then
|
2016-09-25 12:20:41 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
if [[ $ONION_ONLY != "no" ]]; then
|
|
|
|
return
|
|
|
|
fi
|
2016-10-22 11:39:34 +02:00
|
|
|
firewall_add Mumble ${MUMBLE_PORT}
|
2016-10-16 20:50:56 +02:00
|
|
|
mark_completed $FUNCNAME
|
2016-07-03 19:52:57 +02:00
|
|
|
}
|
|
|
|
|
2016-07-03 17:13:34 +02:00
|
|
|
function install_mumble {
|
2016-09-25 12:20:41 +02:00
|
|
|
apt-get -y install mumble-server
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-10-01 21:39:57 +02:00
|
|
|
function_check get_mumble_server_password
|
|
|
|
get_mumble_server_password
|
|
|
|
if [ ! $MUMBLE_SERVER_PASSWORD ]; then
|
2016-09-25 12:20:41 +02:00
|
|
|
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
2016-10-01 21:39:57 +02:00
|
|
|
MUMBLE_SERVER_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
2016-09-25 12:20:41 +02:00
|
|
|
else
|
2016-10-01 21:39:57 +02:00
|
|
|
MUMBLE_SERVER_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
|
|
|
if [ ${#MUMBLE_SERVER_PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then
|
|
|
|
MUMBLE_SERVER_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
|
2016-09-25 12:20:41 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-09-25 12:20:41 +02:00
|
|
|
# Make an ssl cert for the server
|
|
|
|
if [ ! -f /etc/ssl/certs/mumble.dhparam ]; then
|
|
|
|
${PROJECT_NAME}-addcert -h mumble --dhkey $DH_KEYLENGTH
|
|
|
|
function_check check_certificates
|
|
|
|
check_certificates mumble
|
|
|
|
fi
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-09-25 12:20:41 +02:00
|
|
|
# Check that the cert was created
|
|
|
|
if [ ! -f /etc/ssl/certs/mumble.crt ]; then
|
2016-10-01 21:39:57 +02:00
|
|
|
echo $'mumble server certificate not created'
|
2016-09-25 12:20:41 +02:00
|
|
|
exit 57892
|
|
|
|
fi
|
|
|
|
if [ ! -f /etc/ssl/private/mumble.key ]; then
|
2016-10-01 21:39:57 +02:00
|
|
|
echo $'mumble server key not created'
|
2016-09-25 12:20:41 +02:00
|
|
|
exit 57893
|
|
|
|
fi
|
|
|
|
if [ ! -d /var/lib/mumble-server ]; then
|
|
|
|
mkdir /var/lib/mumble-server
|
|
|
|
fi
|
|
|
|
cp /etc/ssl/certs/mumble.* /var/lib/mumble-server
|
|
|
|
cp /etc/ssl/private/mumble.key /var/lib/mumble-server
|
|
|
|
chown -R mumble-server:mumble-server /var/lib/mumble-server
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-10-01 21:39:57 +02:00
|
|
|
sed -i "s|welcometext=.*|welcometext=\"<br />Welcome to $DEFAULT_DOMAIN_NAME <b>mumble</b>.<br />Chat freely!<br />\"|g" /etc/mumble-server.ini
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-10-08 20:32:04 +02:00
|
|
|
if [[ $MUMBLE_SERVER_PASSWORD ]]; then
|
2016-10-01 21:39:57 +02:00
|
|
|
sed -i "s|serverpassword=.*|serverpassword=$MUMBLE_SERVER_PASSWORD|g" /etc/mumble-server.ini
|
2016-09-25 12:20:41 +02:00
|
|
|
fi
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-09-25 12:20:41 +02:00
|
|
|
sed -i 's|#autobanAttempts.*|autobanAttempts = 10|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|#autobanTimeframe.*|autobanTimeframe = 120|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|#autobanTime.*|autobanTime = 300|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|#sendversion=.*|sendversion=False|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|sendversion=.*|sendversion=False|g' /etc/mumble-server.ini
|
|
|
|
if ! grep -q "allowping" /etc/mumble-server.ini; then
|
|
|
|
echo 'allowping=False' >> /etc/mumble-server.ini
|
|
|
|
fi
|
|
|
|
sed -i 's|allowping=.*|allowping=False|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|#sslCert=.*|sslCert=/var/lib/mumble-server/mumble.crt|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|#sslKey=.*|sslKey=/var/lib/mumble-server/mumble.key|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|#certrequired=.*|certrequired=True|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|users=100|users=10|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|#channelnestinglimit=10|channelnestinglimit=10|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|#textmessagelength=.*|textmessagelength=1000|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|textmessagelength=.*|textmessagelength=1000|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|#imagemessagelength=.*|imagemessagelength=131072|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|#allowhtml=.*|allowhtml=False|g' /etc/mumble-server.ini
|
|
|
|
sed -i 's|allowhtml=.*|allowhtml=False|g' /etc/mumble-server.ini
|
2016-10-01 21:39:57 +02:00
|
|
|
sed -i "s|port=.*|port=${MUMBLE_PORT}|g" /etc/mumble-server.ini
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-10-01 21:39:57 +02:00
|
|
|
MUMBLE_ONION_HOSTNAME=$(add_onion_service mumble ${MUMBLE_PORT} ${MUMBLE_PORT})
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-09-25 12:20:41 +02:00
|
|
|
systemctl restart mumble-server
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-09-25 12:20:41 +02:00
|
|
|
if ! grep -q $"Mumble Server" /home/$MY_USERNAME/README; then
|
|
|
|
echo '' >> /home/$MY_USERNAME/README
|
|
|
|
echo '' >> /home/$MY_USERNAME/README
|
|
|
|
echo $'Mumble Server' >> /home/$MY_USERNAME/README
|
|
|
|
echo '=============' >> /home/$MY_USERNAME/README
|
2016-10-01 21:39:57 +02:00
|
|
|
echo $"Mumble onion domain:$MUMBLE_ONION_HOSTNAME" >> /home/$MY_USERNAME/README
|
2016-09-25 12:20:41 +02:00
|
|
|
echo $'Mumble server username: mumble-server' >> /home/$MY_USERNAME/README
|
2016-10-08 20:32:04 +02:00
|
|
|
echo $"Mumble server password: $MUMBLE_SERVER_PASSWORD" >> /home/$MY_USERNAME/README
|
2016-09-25 12:20:41 +02:00
|
|
|
echo '' >> /home/$MY_USERNAME/README
|
|
|
|
echo $'To connect to the Mumble server use your username and the server password shown above.' >> /home/$MY_USERNAME/README
|
|
|
|
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
|
|
|
|
chmod 600 /home/$MY_USERNAME/README
|
|
|
|
fi
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-10-01 21:39:57 +02:00
|
|
|
function_check configure_firewall_for_mumble
|
|
|
|
configure_firewall_for_mumble
|
2016-10-10 20:11:33 +02:00
|
|
|
APP_INSTALLED=1
|
2016-07-03 17:13:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# NOTE: deliberately no exit 0
|