2016-07-03 17:13:34 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# .---. . .
|
|
|
|
# | | |
|
|
|
|
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
|
|
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
|
|
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
|
|
#
|
|
|
|
# Freedom in the Cloud
|
|
|
|
#
|
|
|
|
# Mumble application
|
|
|
|
#
|
|
|
|
# License
|
|
|
|
# =======
|
|
|
|
#
|
2016-10-31 17:24:49 +01:00
|
|
|
# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
|
2016-07-03 17:13:34 +02:00
|
|
|
#
|
|
|
|
# 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-11-20 22:14:37 +01:00
|
|
|
IN_DEFAULT_INSTALL=0
|
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
|
|
|
|
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 {
|
2016-11-20 13:37:13 +01:00
|
|
|
new_mumble_password="$2"
|
|
|
|
|
|
|
|
# Change the password for all users
|
|
|
|
for d in /home/*/ ; do
|
|
|
|
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
|
|
|
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
|
|
|
|
${PROJECT_NAME}-pass -u "$USERNAME" -a mumble -p "$new_mumble_password"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
sed -i "s|serverpassword=.*|serverpassword=$new_mumble_password|g" /etc/mumble-server.ini
|
|
|
|
systemctl restart mumble-server
|
2016-09-25 12:20:41 +02:00
|
|
|
}
|
|
|
|
|
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
|
2016-11-20 13:37:13 +01:00
|
|
|
systemctl restart mumble-server
|
2016-09-25 12:20:41 +02:00
|
|
|
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
|
2016-11-20 13:37:13 +01:00
|
|
|
systemctl restart mumble-server
|
2016-09-25 12:20:41 +02:00
|
|
|
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-10-23 20:38:14 +02:00
|
|
|
apt-get -yq remove --purge mumble-server
|
2016-09-25 12:20:41 +02:00
|
|
|
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-10-28 14:20:53 +02:00
|
|
|
if [ -d /var/lib/mumble-server ]; then
|
|
|
|
rm -rf /var/lib/mumble-server
|
|
|
|
fi
|
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 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-10-23 20:38:14 +02:00
|
|
|
apt-get -yq install mumble-server
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-11-19 20:17:33 +01:00
|
|
|
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
|
|
|
MUMBLE_SERVER_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
|
|
|
else
|
|
|
|
if [ ! $MUMBLE_SERVER_PASSWORD ]; then
|
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
|
2016-10-28 14:19:08 +02:00
|
|
|
if [ ! -f /var/lib/mumble-server/mumble.pem ]; then
|
|
|
|
mv /var/lib/mumble-server/mumble.crt /var/lib/mumble-server/mumble.pem
|
|
|
|
fi
|
2016-09-25 12:20:41 +02:00
|
|
|
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
|
2016-10-28 14:19:08 +02:00
|
|
|
sed -i 's|#sslCert=.*|sslCert=/var/lib/mumble-server/mumble.pem|g' /etc/mumble-server.ini
|
2016-09-25 12:20:41 +02:00
|
|
|
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-11-18 15:43:19 +01:00
|
|
|
# turn off logs by default
|
|
|
|
sed -i 's|logfile=.*|logfile=/dev/null|g' /etc/mumble-server.ini
|
|
|
|
|
2016-10-28 14:19:08 +02:00
|
|
|
update_default_domain
|
2016-09-25 12:20:41 +02:00
|
|
|
systemctl restart mumble-server
|
2016-07-03 17:13:34 +02:00
|
|
|
|
2016-11-20 14:07:33 +01:00
|
|
|
# Change the password for all users
|
|
|
|
for d in /home/*/ ; do
|
|
|
|
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
|
|
|
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
|
|
|
|
${PROJECT_NAME}-pass -u "$USERNAME" -a mumble -p "$MUMBLE_SERVER_PASSWORD"
|
|
|
|
fi
|
|
|
|
done
|
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
|