2016-07-03 17:13:34 +02:00
|
|
|
#!/bin/bash
|
2018-04-08 14:30:21 +02:00
|
|
|
# _____ _ _
|
|
|
|
# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
|
|
|
|
# | __| _| -_| -_| . | . | | . | . | | -_|
|
|
|
|
# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
|
2016-07-03 17:13:34 +02:00
|
|
|
#
|
2018-04-08 14:30:21 +02:00
|
|
|
# Freedom in the Cloud
|
2016-07-03 17:13:34 +02:00
|
|
|
#
|
|
|
|
# XMPP functions
|
|
|
|
#
|
2018-01-25 12:40:19 +01:00
|
|
|
# The two directories for prosody modules seem necessary.
|
|
|
|
# Trying to remove /usr/lib/prosody/modules causes problems, and that's
|
|
|
|
# part of the package install.
|
|
|
|
#
|
2016-07-03 17:13:34 +02:00
|
|
|
# License
|
|
|
|
# =======
|
|
|
|
#
|
2018-01-25 13:17:37 +01:00
|
|
|
# Copyright (C) 2014-2018 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-07-03 17:13:34 +02:00
|
|
|
# Directory where XMPP settings are stored
|
|
|
|
XMPP_DIRECTORY="/var/lib/prosody"
|
|
|
|
XMPP_PASSWORD=
|
|
|
|
|
|
|
|
XMPP_CIPHERS='"EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA256:EECDH:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH:CAMELLIA128-SHA:AES128-SHA"'
|
|
|
|
XMPP_ECC_CURVE='"secp384r1"'
|
|
|
|
|
2016-12-07 10:16:38 +01:00
|
|
|
prosody_latest_version='0.10'
|
2018-05-31 20:46:46 +02:00
|
|
|
prosody_nightly=485
|
|
|
|
prosody_nightly_hash='1b1b6a0daf9fdd3a88c8762751f01f561714c0bd5d907af631d7d036c9e19d39'
|
2016-12-07 10:16:38 +01:00
|
|
|
prosody_filename=prosody-${prosody_latest_version}-1nightly${prosody_nightly}
|
2016-12-07 13:14:33 +01:00
|
|
|
prosody_nightly_url="https://prosody.im/nightly/${prosody_latest_version}/latest/${prosody_filename}.tar.gz"
|
2017-05-14 23:10:31 +02:00
|
|
|
|
|
|
|
# From https://hg.prosody.im/prosody-modules
|
2018-06-02 22:10:11 +02:00
|
|
|
prosody_modules_filename='prosody-modules-20180602.tar.gz'
|
|
|
|
prosody_modules_hash='c8ea99a3c9ed25e6471cd7de991a58715f1478e3bf3c5866b9f34a9ef8a863dd'
|
2018-04-25 11:04:02 +02:00
|
|
|
xmpp_encryption_warning=$"For security reasons, OMEMO or PGP encryption is required for conversations on this server."
|
2016-12-07 10:16:38 +01:00
|
|
|
|
2018-05-28 15:47:12 +02:00
|
|
|
XMPP_SHORT_DESCRIPTION=$'Chat system'
|
|
|
|
XMPP_DESCRIPTION=$'Chat system'
|
2018-05-25 18:27:55 +02:00
|
|
|
XMPP_MOBILE_APP_URL='https://f-droid.org/packages/eu.siacs.conversations'
|
|
|
|
|
2016-10-05 23:33:41 +02:00
|
|
|
xmpp_variables=(ONION_ONLY
|
|
|
|
INSTALLED_WITHIN_DOCKER
|
|
|
|
XMPP_CIPHERS
|
|
|
|
XMPP_ECC_CURVE
|
|
|
|
XMPP_ECC_CURVE
|
|
|
|
MY_USERNAME
|
2018-03-07 11:52:18 +01:00
|
|
|
MY_EMAIL_ADDRESS
|
2016-10-26 13:51:37 +02:00
|
|
|
DEFAULT_DOMAIN_NAME
|
|
|
|
XMPP_DOMAIN_CODE)
|
2016-10-05 23:33:41 +02:00
|
|
|
|
2018-04-25 13:55:35 +02:00
|
|
|
function xmpp_update_e2e_policy {
|
|
|
|
filename="$1"
|
|
|
|
|
|
|
|
read_config_param DEFAULT_DOMAIN_NAME
|
|
|
|
read_config_param ONION_ONLY
|
|
|
|
|
|
|
|
if ! grep -q "e2e_policy_muc" "$filename"; then
|
|
|
|
echo "e2e_policy_muc = \"none\"" >> "$filename"
|
|
|
|
else
|
|
|
|
sed -i 's|e2e_policy_muc.*|e2e_policy_muc = "none"|g' "$filename"
|
|
|
|
fi
|
|
|
|
if ! grep -q "e2e_policy_chat" "$filename"; then
|
|
|
|
echo "e2e_policy_chat = \"required\"" >> "$filename"
|
|
|
|
else
|
|
|
|
sed -i 's|e2e_policy_chat.*|e2e_policy_chat = "required"|g' "$filename"
|
|
|
|
fi
|
|
|
|
if ! grep -q "e2e_policy_message_required_chat" "$filename"; then
|
2018-04-25 14:12:37 +02:00
|
|
|
echo "e2e_policy_message_required_chat = \"$xmpp_encryption_warning\"" >> "$filename"
|
2018-04-25 13:55:35 +02:00
|
|
|
else
|
2018-04-25 14:12:37 +02:00
|
|
|
sed -i "s|e2e_policy_message_required_chat.*|e2e_policy_message_required_chat = \"$xmpp_encryption_warning\"|g" "$filename"
|
2018-04-25 13:55:35 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$ONION_ONLY" != 'no' ]]; then
|
|
|
|
XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
|
2018-04-25 13:57:55 +02:00
|
|
|
sed -i "s|VirtualHost \".*.onion.*|VirtualHost \"${XMPP_ONION_HOSTNAME}\"|g" "$filename"
|
2018-04-25 13:55:35 +02:00
|
|
|
# TLS is not strictly needed for onion transport security
|
2018-04-25 13:57:55 +02:00
|
|
|
sed -i 's|c2s_require_encryption =.*|c2s_require_encryption = false|g' "$filename"
|
|
|
|
sed -i 's|s2s_require_encryption =.*|s2s_require_encryption = false|g' "$filename"
|
2018-04-25 13:55:35 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-07-01 20:14:28 +02:00
|
|
|
function logging_on_xmpp {
|
2017-07-01 21:20:57 +02:00
|
|
|
if [ -d /etc/prosody ]; then
|
|
|
|
if [ ! -d /var/log/prosody ]; then
|
|
|
|
mkdir /var/log/prosody
|
|
|
|
chown root:adm /var/log/prosody
|
|
|
|
fi
|
2017-08-06 00:30:38 +02:00
|
|
|
if ! grep -q "/var/log/prosody/prosody.log" /etc/prosody/prosody.cfg.lua; then
|
|
|
|
sed -i 's|info = "/dev/null";|info = "/var/log/prosody/prosody.log";|g' /etc/prosody/prosody.cfg.lua
|
|
|
|
sed -i 's|error = "/dev/null";|error = "/var/log/prosody/prosody.err";|g' /etc/prosody/prosody.cfg.lua
|
|
|
|
sed -i 's|levels = { "error" }; to = "/dev/null";|levels = { "error" }; to = "syslog";|g' /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
2017-07-01 21:20:57 +02:00
|
|
|
fi
|
2017-07-01 20:14:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function logging_off_xmpp {
|
2017-07-01 21:20:57 +02:00
|
|
|
if [ -d /etc/prosody ]; then
|
2017-08-06 00:30:38 +02:00
|
|
|
if grep -q "/var/log/prosody/prosody.log" /etc/prosody/prosody.cfg.lua; then
|
|
|
|
sed -i 's|info = "/var/log/prosody/prosody.log";|info = "/dev/null";|g' /etc/prosody/prosody.cfg.lua
|
|
|
|
sed -i 's|error = "/var/log/prosody/prosody.err";|error = "/dev/null";|g' /etc/prosody/prosody.cfg.lua
|
|
|
|
sed -i 's|levels = { "error" }; to = "syslog";|levels = { "error" }; to = "/dev/null";|g' /etc/prosody/prosody.cfg.lua
|
|
|
|
$REMOVE_FILES_COMMAND /var/log/prosody/*
|
|
|
|
rm -rf /var/log/prosody
|
|
|
|
fi
|
2017-07-01 21:20:57 +02:00
|
|
|
fi
|
2017-07-01 20:14:28 +02:00
|
|
|
}
|
|
|
|
|
2017-01-29 14:37:13 +01:00
|
|
|
function xmpp_add_onion_address {
|
|
|
|
domain_name="$1"
|
|
|
|
onion_address="$2"
|
|
|
|
if [ ${#domain_name} -eq 0 ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
if [ ${#onion_address} -eq 0 ]; then
|
|
|
|
return
|
|
|
|
fi
|
2017-08-07 19:15:36 +02:00
|
|
|
if ! grep "${onion_address}" /etc/prosody/prosody.cfg.lua; then
|
2017-08-06 15:34:48 +02:00
|
|
|
if grep -q "[\"${domain_name}\"]" /etc/prosody/prosody.cfg.lua; then
|
|
|
|
sed -i "s|[\"${domain_name}\"].*|[\"${domain_name}\"] = \"${onion_address}\";|g" /etc/prosody/prosody.cfg.lua
|
|
|
|
else
|
|
|
|
sed -i "/onions_map = {/a [\"${domain_name}\"] = \"${onion_address}\";" /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
|
|
|
systemctl restart prosody
|
2017-01-29 14:37:13 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function xmpp_add_onion_address_interactive {
|
2018-03-02 20:17:02 +01:00
|
|
|
data=$(mktemp 2>/dev/null)
|
2017-01-29 14:37:13 +01:00
|
|
|
dialog --backtitle $"Freedombone Control Panel" \
|
|
|
|
--title $"Add an ICANN to Onion domain mapping" \
|
2018-03-02 20:17:02 +01:00
|
|
|
--form $"Sepecify an ICANN domain name and its equivalent onion address\\n" 9 50 2 \
|
2017-01-29 14:37:13 +01:00
|
|
|
$"Domain:" 1 1 "" 1 18 26 25 \
|
|
|
|
$"Onion address:" 2 1 "" 2 18 26 25 \
|
2018-03-02 20:17:02 +01:00
|
|
|
2> "$data"
|
2017-01-29 14:37:13 +01:00
|
|
|
sel=$?
|
|
|
|
case $sel in
|
2018-03-02 20:17:02 +01:00
|
|
|
1) rm -f "$data"
|
|
|
|
return;;
|
|
|
|
255) rm -f "$data"
|
|
|
|
return;;
|
2017-01-29 14:37:13 +01:00
|
|
|
esac
|
2018-03-02 20:17:02 +01:00
|
|
|
domain_name=$(sed -n 1p < "$data")
|
|
|
|
onion_address=$(sed -n 2p < "$data")
|
|
|
|
rm -f "$data"
|
2017-01-29 14:37:13 +01:00
|
|
|
if [[ "$onion_address" != *".onion" ]]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
if [[ "$domain_name" != *"."* ]]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
xmpp_add_onion_address "$domain_name" "$onion_address"
|
|
|
|
|
|
|
|
dialog --title $"Add an ICANN to Onion domain mapping" \
|
|
|
|
--msgbox $"${domain_name} -> ${onion_address} added" 6 70
|
|
|
|
}
|
|
|
|
|
|
|
|
function xmpp_remove_onion_address {
|
|
|
|
domain_name="$1"
|
|
|
|
if [ ${#domain_name} -eq 0 ]; then
|
|
|
|
return
|
|
|
|
fi
|
2017-08-07 19:15:36 +02:00
|
|
|
xmpp_changed=
|
2017-01-29 14:37:13 +01:00
|
|
|
if grep -q "[\"${domain_name}\"]" /etc/prosody/prosody.cfg.lua; then
|
|
|
|
sed -i "/[\"${domain_name}\"]/d" /etc/prosody/prosody.cfg.lua
|
2017-08-07 19:15:36 +02:00
|
|
|
xmpp_changed=1
|
2017-01-29 14:37:13 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if grep -q "= \"${domain_name}\";" /etc/prosody/prosody.cfg.lua; then
|
|
|
|
sed -i "/= \"${domain_name}\";/d" /etc/prosody/prosody.cfg.lua
|
2017-08-07 19:15:36 +02:00
|
|
|
xmpp_changed=1
|
|
|
|
fi
|
|
|
|
if [ $xmpp_changed ]; then
|
|
|
|
systemctl restart prosody
|
2017-01-29 14:37:13 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function xmpp_remove_onion_address_interactive {
|
2018-03-02 20:17:02 +01:00
|
|
|
data=$(mktemp 2>/dev/null)
|
2017-01-29 14:37:13 +01:00
|
|
|
dialog --title $"Remove ICANN to Onion domain mapping" \
|
|
|
|
--backtitle $"Freedombone Control Panel" \
|
2018-03-02 20:17:02 +01:00
|
|
|
--inputbox $'Enter the domain name or onion address to be removed' 8 60 2>"$data"
|
2017-01-29 14:37:13 +01:00
|
|
|
sel=$?
|
|
|
|
case $sel in
|
2018-03-02 20:17:02 +01:00
|
|
|
0) domain_name=$(<"$data")
|
2017-01-29 14:37:13 +01:00
|
|
|
if [[ "$domain_name" != *"."* ]]; then
|
2018-03-02 20:17:02 +01:00
|
|
|
rm -f "$data"
|
2017-01-29 14:37:13 +01:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
xmpp_remove_onion_address "$domain_name"
|
|
|
|
dialog --title $"Remove an ICANN to Onion domain mapping" \
|
|
|
|
--msgbox $"${domain_name} removed" 6 70
|
|
|
|
;;
|
|
|
|
esac
|
2018-03-02 20:17:02 +01:00
|
|
|
rm -f "$data"
|
2017-01-29 14:37:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function configure_interactive_xmpp {
|
2018-04-04 14:20:20 +02:00
|
|
|
W=(1 $"Add an ICANN to onion domain mapping"
|
|
|
|
2 $"Remove an ICANN to onion domain mapping")
|
|
|
|
|
2017-01-29 14:37:13 +01:00
|
|
|
while true
|
|
|
|
do
|
2018-04-04 14:20:20 +02:00
|
|
|
# shellcheck disable=SC2068
|
|
|
|
selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"XMPP" --menu $"Choose an operation, or ESC to exit:" 10 60 2 "${W[@]}" 3>&2 2>&1 1>&3)
|
|
|
|
|
|
|
|
if [ ! "$selection" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
case $selection in
|
2017-01-29 14:37:13 +01:00
|
|
|
1) xmpp_add_onion_address_interactive;;
|
|
|
|
2) xmpp_remove_onion_address_interactive;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-10-02 12:17:01 +02:00
|
|
|
function remove_user_xmpp {
|
|
|
|
remove_username="$1"
|
2018-02-21 12:15:13 +01:00
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
"${PROJECT_NAME}-pass" -u "$remove_username" --rmapp xmpp
|
|
|
|
if [[ "$ONION_ONLY" != "no" ]]; then
|
2018-02-21 12:15:13 +01:00
|
|
|
DOMAIN=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
|
2017-03-24 20:57:14 +01:00
|
|
|
else
|
2018-02-21 12:15:13 +01:00
|
|
|
DOMAIN=${HOSTNAME}
|
2017-03-24 20:57:14 +01:00
|
|
|
fi
|
2018-02-21 12:15:13 +01:00
|
|
|
prosodyctl deluser "${remove_username}@${DOMAIN}"
|
2016-10-02 12:17:01 +02:00
|
|
|
}
|
2016-10-02 00:39:56 +02:00
|
|
|
|
2017-05-16 21:49:39 +02:00
|
|
|
function add_user_xmpp_client {
|
|
|
|
new_username="$1"
|
|
|
|
new_user_password="$2"
|
|
|
|
|
|
|
|
if [ -f /usr/local/bin/profanity ]; then
|
|
|
|
XMPP_CLIENT_DIR=/home/$new_username/.local/share/profanity
|
|
|
|
XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ ! -d "$XMPP_CLIENT_DIR" ]; then
|
|
|
|
mkdir -p "$XMPP_CLIENT_DIR"
|
2017-05-16 21:49:39 +02:00
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ ! -d "/home/$new_username/.config/profanity" ]; then
|
|
|
|
mkdir -p "/home/$new_username/.config/profanity"
|
2017-05-16 21:49:39 +02:00
|
|
|
fi
|
|
|
|
MY_GPG_PUBLIC_KEY_ID=$(gpg_pubkey_from_email "$new_username" "$new_username@$HOSTNAME")
|
2018-03-02 20:17:02 +01:00
|
|
|
{ echo "[${new_username}@${HOSTNAME}]";
|
|
|
|
echo 'enabled=true';
|
|
|
|
echo "jid=${new_username}@${HOSTNAME}";
|
|
|
|
echo "server=$XMPP_ONION_HOSTNAME";
|
|
|
|
echo "pgp.keyid=$MY_GPG_PUBLIC_KEY_ID";
|
|
|
|
echo 'resource=profanity';
|
|
|
|
echo "muc.service=conference.${HOSTNAME}";
|
|
|
|
echo "muc.nick=${new_username}";
|
|
|
|
echo 'presence.last=online';
|
|
|
|
echo 'presence.login=online';
|
|
|
|
echo 'priority.online=0';
|
|
|
|
echo 'priority.chat=0';
|
|
|
|
echo 'priority.away=0';
|
|
|
|
echo 'priority.xa=0';
|
|
|
|
echo 'priority.dnd=0'; } > "$XMPP_CLIENT_ACCOUNTS"
|
|
|
|
|
|
|
|
echo '[connection]' > "/home/$new_username/.config/profanity/profrc"
|
2017-05-16 21:49:39 +02:00
|
|
|
if [[ $ONION_ONLY != "no" ]]; then
|
2018-03-02 20:17:02 +01:00
|
|
|
echo "account=${new_username}@${XMPP_ONION_HOSTNAME}" >> "/home/$new_username/.config/profanity/profrc"
|
2017-05-16 21:49:39 +02:00
|
|
|
else
|
2018-03-02 20:17:02 +01:00
|
|
|
echo "account=${new_username}@${HOSTNAME}" >> "/home/$new_username/.config/profanity/profrc"
|
2017-05-16 21:49:39 +02:00
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
{ echo '';
|
|
|
|
echo '[plugins]';
|
|
|
|
echo 'load=prof_omemo_plugin.py;';
|
|
|
|
echo '';
|
|
|
|
echo '[otr]';
|
|
|
|
echo 'policy=opportunistic';
|
|
|
|
echo 'log=off';
|
|
|
|
echo '';
|
|
|
|
echo '[pgp]';
|
|
|
|
echo 'log=off';
|
|
|
|
echo '';
|
|
|
|
echo '[ui]';
|
|
|
|
echo 'enc.warn=true'; } >> "/home/$new_username/.config/profanity/profrc"
|
|
|
|
|
|
|
|
chown -R "$new_username":"$new_username" "/home/$new_username/.local"
|
|
|
|
chown -R "$new_username":"$new_username" "/home/$new_username/.config"
|
2017-05-16 21:49:39 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-10-02 12:17:01 +02:00
|
|
|
function add_user_xmpp {
|
2016-10-02 00:39:56 +02:00
|
|
|
new_username="$1"
|
|
|
|
new_user_password="$2"
|
|
|
|
|
2017-03-24 20:57:14 +01:00
|
|
|
XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
|
2018-03-02 20:17:02 +01:00
|
|
|
"${PROJECT_NAME}-pass" -u "$new_username" -a xmpp -p "$new_user_password"
|
2016-11-19 20:17:33 +01:00
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
if [[ "$ONION_ONLY" != "no" ]]; then
|
2018-02-21 12:02:56 +01:00
|
|
|
DOMAIN_NAME=$XMPP_ONION_HOSTNAME
|
2017-03-24 20:57:14 +01:00
|
|
|
else
|
2018-02-21 12:02:56 +01:00
|
|
|
DOMAIN_NAME=$HOSTNAME
|
2017-03-24 20:57:14 +01:00
|
|
|
fi
|
2018-02-21 12:02:56 +01:00
|
|
|
EMAIL_ADDRESS="$new_username@$DOMAIN_NAME"
|
|
|
|
|
|
|
|
if [ ${#new_user_password} -eq 0 ]; then
|
2018-03-02 20:17:02 +01:00
|
|
|
prosodyctl adduser "$EMAIL_ADDRESS"
|
2018-02-21 12:02:56 +01:00
|
|
|
else
|
2018-03-02 20:17:02 +01:00
|
|
|
if ! prosodyctl register "$new_username" "$DOMAIN_NAME" "$new_user_password"; then
|
2018-02-21 12:02:56 +01:00
|
|
|
exit 653456375
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# add the xmpp address to email headers
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "/home/$new_username/.muttrc" ]; then
|
|
|
|
if ! grep -q "Jabber-ID" "/home/$new_username/.muttrc"; then
|
|
|
|
echo "my_hdr Jabber-ID: $EMAIL_ADDRESS" >> "/home/$new_username/.muttrc"
|
2018-02-21 12:02:56 +01:00
|
|
|
else
|
2018-03-02 20:17:02 +01:00
|
|
|
sed -i "s|my_hdr Jabber-ID.*|my_hdr Jabber-ID: $EMAIL_ADDRESS|g" "/home/$new_username/.muttrc"
|
2018-02-21 12:02:56 +01:00
|
|
|
fi
|
2016-10-02 00:39:56 +02:00
|
|
|
fi
|
|
|
|
|
2017-05-16 21:49:39 +02:00
|
|
|
add_user_xmpp_client "$new_username" "$new_user_password"
|
2016-10-02 00:39:56 +02:00
|
|
|
echo '0'
|
|
|
|
}
|
|
|
|
|
2016-09-30 12:34:39 +02:00
|
|
|
function install_interactive_xmpp {
|
|
|
|
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_xmpp {
|
2016-11-20 12:23:56 +01:00
|
|
|
curr_username="$1"
|
|
|
|
new_user_password="$2"
|
|
|
|
|
|
|
|
read_config_param DEFAULT_DOMAIN_NAME
|
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
"${PROJECT_NAME}-pass" -u "$curr_username" -a xmpp -p "$new_user_password"
|
2016-11-20 12:23:56 +01:00
|
|
|
|
|
|
|
# TODO: this is currently interactive. Really there needs to be a
|
|
|
|
# non-interactive password change option for prosodyctl
|
|
|
|
clear
|
|
|
|
echo ''
|
|
|
|
echo $'Currently Prosody requires password changes to be done interactively'
|
2018-03-02 20:17:02 +01:00
|
|
|
prosodyctl passwd "${curr_username}@${DEFAULT_DOMAIN_NAME}"
|
2016-12-19 16:40:35 +01:00
|
|
|
|
2017-05-16 21:49:39 +02:00
|
|
|
if [ -f /usr/local/bin/profanity ]; then
|
|
|
|
XMPP_CLIENT_DIR=/home/$curr_username/.local/share/profanity
|
|
|
|
XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "$XMPP_CLIENT_ACCOUNTS" ]; then
|
|
|
|
sed -i "s|password=.*|password=$new_user_password|g" "$XMPP_CLIENT_ACCOUNTS"
|
2017-05-16 21:49:39 +02:00
|
|
|
fi
|
2016-12-19 16:40:35 +01:00
|
|
|
fi
|
2016-09-25 12:20:41 +02:00
|
|
|
}
|
|
|
|
|
2016-07-09 12:36:12 +02:00
|
|
|
function reconfigure_xmpp {
|
2016-08-28 10:55:47 +02:00
|
|
|
echo -n ''
|
2016-07-09 12:36:12 +02:00
|
|
|
}
|
|
|
|
|
2016-07-06 16:40:09 +02:00
|
|
|
function update_prosody_modules {
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ ! "$1" ]; then
|
2017-05-14 23:10:31 +02:00
|
|
|
if [ ! -d /var/lib/prosody/prosody-modules ]; then
|
|
|
|
return
|
|
|
|
fi
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
|
|
|
if [ ! -d /usr/lib/prosody ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ ! -f "$INSTALL_DIR/$prosody_modules_filename" ]; then
|
2017-05-14 23:10:31 +02:00
|
|
|
# Obtain the modules
|
2018-05-02 12:22:36 +02:00
|
|
|
if [ -f "$HOME/${PROJECT_NAME}/image_build/$prosody_modules_filename" ]; then
|
|
|
|
cp "$HOME/${PROJECT_NAME}/image_build/$prosody_modules_filename" "$INSTALL_DIR"
|
2017-05-14 23:10:31 +02:00
|
|
|
else
|
2018-05-02 12:22:36 +02:00
|
|
|
if [ -f "/home/$MY_USERNAME/${PROJECT_NAME}/image_build/$prosody_modules_filename" ]; then
|
|
|
|
cp "/home/$MY_USERNAME/${PROJECT_NAME}/image_build/$prosody_modules_filename" "$INSTALL_DIR"
|
2017-05-14 23:10:31 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "$INSTALL_DIR/$prosody_modules_filename" ]; then
|
|
|
|
cd "$INSTALL_DIR" || exit 246824684
|
2017-05-14 23:10:31 +02:00
|
|
|
|
|
|
|
# Check the hash
|
2018-03-02 20:17:02 +01:00
|
|
|
curr_hash=$(sha256sum "$INSTALL_DIR/$prosody_modules_filename" | awk -F ' ' '{print $1}')
|
2017-05-14 23:10:31 +02:00
|
|
|
if [[ "$curr_hash" != "$prosody_modules_hash" ]]; then
|
|
|
|
echo $'Prosody modules hash does not match'
|
2017-05-17 22:41:35 +02:00
|
|
|
exit 83562
|
2017-05-14 23:10:31 +02:00
|
|
|
else
|
|
|
|
# Extract the modules
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -d "$INSTALL_DIR/prosody-modules" ]; then
|
|
|
|
rm -rf "$INSTALL_DIR/prosody-modules"
|
2017-05-14 23:10:31 +02:00
|
|
|
fi
|
|
|
|
tar -xzvf $prosody_modules_filename
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -d "$INSTALL_DIR/prosody-modules" ]; then
|
2017-05-14 23:46:15 +02:00
|
|
|
systemctl stop prosody
|
2017-05-15 18:53:46 +02:00
|
|
|
if [ ! -d /var/lib/prosody/prosody-modules ]; then
|
2017-05-17 22:41:35 +02:00
|
|
|
mkdir -p /var/lib/prosody/prosody-modules
|
2017-05-15 18:53:46 +02:00
|
|
|
fi
|
2018-03-03 12:49:17 +01:00
|
|
|
cp -r "$INSTALL_DIR/prosody-modules/"* /var/lib/prosody/prosody-modules/
|
|
|
|
cp -r "$INSTALL_DIR/prosody-modules/"* /usr/lib/prosody/modules/
|
2017-05-14 23:10:31 +02:00
|
|
|
chown -R prosody:prosody /var/lib/prosody/prosody-modules
|
2017-08-11 11:37:11 +02:00
|
|
|
chown -R prosody:prosody /usr/lib/prosody/modules
|
2017-05-14 23:46:15 +02:00
|
|
|
systemctl start prosody
|
2017-05-17 23:02:04 +02:00
|
|
|
else
|
|
|
|
echo $'Prosody modules not extracted'
|
|
|
|
exit 72524
|
2017-05-14 23:10:31 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2017-04-14 20:32:52 +02:00
|
|
|
fi
|
|
|
|
|
2017-06-28 14:52:14 +02:00
|
|
|
if ! grep -q '"vcard"' /etc/prosody/prosody.cfg.lua; then
|
2017-05-14 23:46:15 +02:00
|
|
|
systemctl stop prosody
|
2017-04-14 20:32:52 +02:00
|
|
|
sed -i '/"pep"/a "vcard";' /etc/prosody/prosody.cfg.lua
|
2017-05-14 23:46:15 +02:00
|
|
|
systemctl start prosody
|
2017-01-07 13:00:33 +01:00
|
|
|
fi
|
2018-01-04 17:55:15 +01:00
|
|
|
if ! grep -q "omemo_all_access" /etc/prosody/prosody.cfg.lua; then
|
|
|
|
sed -i '/"pep";/a "omemo_all_access"; -- Fix for PEP with OMEMO' /etc/prosody/prosody.cfg.lua
|
|
|
|
sed -i 's|"omemo_all_access";| "omemo_all_access";|g' /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep -q "omemo_all_access" /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
|
|
|
sed -i '/"pep";/a "omemo_all_access"; -- Fix for PEP with OMEMO' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
sed -i 's|"omemo_all_access";| "omemo_all_access";|g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
fi
|
2018-06-02 22:03:27 +02:00
|
|
|
|
|
|
|
if ! grep -q "block_strangers" /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
|
|
|
sed -i '/"pep";/a "block_strangers"; -- Dont allow messages from strangers' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
sed -i 's|"block_strangers";| "block_strangers";|g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
fi
|
|
|
|
if ! grep -q "block_strangers" /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
|
|
|
sed -i '/"pep";/a "block_strangers"; -- Dont allow messages from strangers' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
sed -i 's|"block_strangers";| "block_strangers";|g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
fi
|
2016-07-06 16:40:09 +02:00
|
|
|
}
|
|
|
|
|
2017-12-20 14:44:27 +01:00
|
|
|
function prosody_daemon_restart_script {
|
|
|
|
# On rare occasions the daemon appears to get stuck
|
|
|
|
# i.e. still active, but not accepting connections
|
|
|
|
# This ensures that it will unstick itself at least once per day
|
2018-03-22 11:52:41 +01:00
|
|
|
if [ -f /etc/cron.daily/prosody ]; then
|
|
|
|
rm /etc/cron.daily/prosody
|
|
|
|
fi
|
|
|
|
if [ ! -f /etc/cron.hourly/prosody ]; then
|
2018-03-23 18:19:30 +01:00
|
|
|
{ echo '#!/bin/bash';
|
|
|
|
echo "is_active=\$(systemctl is-active prosody)";
|
|
|
|
echo "if [[ \"\$is_active\" != 'active' ]]; then";
|
|
|
|
echo ' systemctl restart prosody'
|
|
|
|
echo 'fi'; } > /etc/cron.hourly/prosody
|
2018-03-22 11:52:41 +01:00
|
|
|
chmod +x /etc/cron.hourly/prosody
|
2017-12-20 14:44:27 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-05-16 21:49:39 +02:00
|
|
|
function upgrade_xmpp {
|
2017-05-07 11:52:00 +02:00
|
|
|
if [ -d /etc/letsencrypt ]; then
|
2017-08-07 22:40:19 +02:00
|
|
|
prosody_groups=$(groups prosody)
|
|
|
|
if [[ "$prosody_groups" != *'ssl-cert'* ]]; then
|
|
|
|
usermod -a -G ssl-cert prosody
|
|
|
|
fi
|
2017-05-07 11:52:00 +02:00
|
|
|
fi
|
2018-04-25 13:55:35 +02:00
|
|
|
|
|
|
|
xmpp_update_e2e_policy /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
xmpp_update_e2e_policy /etc/prosody/prosody.cfg.lua
|
|
|
|
|
2017-12-20 14:44:27 +01:00
|
|
|
prosody_daemon_restart_script
|
2016-08-28 10:55:47 +02:00
|
|
|
function_check update_prosody_modules
|
|
|
|
update_prosody_modules
|
2017-12-15 18:08:40 +01:00
|
|
|
xmpp_onion_addresses /etc/prosody/prosody.cfg.lua
|
2018-03-07 11:52:18 +01:00
|
|
|
xmpp_contact_info /etc/prosody/prosody.cfg.lua
|
2016-12-07 10:16:38 +01:00
|
|
|
|
2018-01-21 01:09:20 +01:00
|
|
|
if grep -q "/etc/ssl/certs/xmpp.dhparam" /etc/prosody/prosody.cfg.lua; then
|
|
|
|
cp /etc/ssl/certs/xmpp.dhparam /etc/prosody/xmpp.dhparam
|
|
|
|
chown prosody:prosody /etc/prosody/xmpp.dhparam
|
|
|
|
sed -i 's|/etc/ssl/certs/xmpp.dhparam|/etc/prosody/xmpp.dhparam|g' /etc/prosody/prosody.cfg.lua
|
|
|
|
sed -i 's|/etc/ssl/certs/xmpp.dhparam|/etc/prosody/xmpp.dhparam|g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
fi
|
|
|
|
|
|
|
|
if grep -q "/etc/ssl/private/xmpp.key" /etc/prosody/prosody.cfg.lua; then
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "/etc/letsencrypt/live/${DEFAULT_DOMAIN_NAME}/privkey.pem" ]; then
|
2018-01-21 01:09:20 +01:00
|
|
|
sed -i "s|/etc/ssl/private/xmpp.key|/etc/letsencrypt/live/${DEFAULT_DOMAIN_NAME}/privkey.pem|g" /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if grep -q "/etc/ssl/certs/xmpp.crt" /etc/prosody/prosody.cfg.lua; then
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "/etc/letsencrypt/live/${DEFAULT_DOMAIN_NAME}/fullchain.pem" ]; then
|
2018-01-21 01:09:20 +01:00
|
|
|
sed -i "s|/etc/ssl/certs/xmpp.crt|/etc/letsencrypt/live/${DEFAULT_DOMAIN_NAME}/fullchain.pem|g" /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
curr_prosody_filename=$(grep "prosody_filename" "$COMPLETION_FILE" | awk -F ':' '{print $2}')
|
2017-03-11 17:14:24 +01:00
|
|
|
if [[ "$curr_prosody_filename" != "$prosody_filename" ]]; then
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -d "${INSTALL_DIR}/${prosody_filename}" ]; then
|
2017-03-11 17:14:24 +01:00
|
|
|
# ensure that the binaries have not been overwritten
|
|
|
|
# by an operating system upgrade
|
2018-03-02 20:17:02 +01:00
|
|
|
cd "${INSTALL_DIR}/${prosody_filename}" || exit 462846284
|
2017-03-11 17:14:24 +01:00
|
|
|
make prefix=/usr install
|
2017-01-16 16:38:08 +01:00
|
|
|
else
|
2018-03-02 20:17:02 +01:00
|
|
|
cd "$INSTALL_DIR" || exit 23681468
|
2017-03-11 17:14:24 +01:00
|
|
|
# Try to get the source from the project repo
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "/root/${PROJECT_NAME}/image_build/${prosody_filename}.tar.gz" ]; then
|
|
|
|
cp "/root/${PROJECT_NAME}/image_build/${prosody_filename}.tar.gz" .
|
2017-01-16 16:38:08 +01:00
|
|
|
else
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "/home/${MY_USERNAME}/${PROJECT_NAME}/image_build/${prosody_filename}.tar.gz" ]; then
|
|
|
|
cp "/home/${MY_USERNAME}/${PROJECT_NAME}/image_build/${prosody_filename}.tar.gz" .
|
2017-03-11 17:14:24 +01:00
|
|
|
else
|
|
|
|
wget $prosody_nightly_url
|
|
|
|
fi
|
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ ! -f "${INSTALL_DIR}/${prosody_filename}.tar.gz" ]; then
|
2017-03-11 17:14:24 +01:00
|
|
|
echo $"Failed to download prosody nightly $prosody_nightly_url"
|
|
|
|
return
|
2017-01-16 16:38:08 +01:00
|
|
|
fi
|
2016-12-07 13:14:33 +01:00
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
hash_value=$(sha256sum "${INSTALL_DIR}/${prosody_filename}.tar.gz" | awk -F ' ' '{print $1}')
|
2017-03-11 17:14:24 +01:00
|
|
|
if [[ "$hash_value" != "$prosody_nightly_hash" ]]; then
|
2018-03-02 20:17:02 +01:00
|
|
|
rm "${INSTALL_DIR}/${prosody_filename}.tar.gz"
|
2017-03-11 17:14:24 +01:00
|
|
|
echo $'Unexpected hash value for prosody nightly download'
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
tar -xzvf "${INSTALL_DIR}/${prosody_filename}.tar.gz"
|
|
|
|
cd "${INSTALL_DIR}/${prosody_filename}" || exit 246872468246
|
2017-03-11 17:14:24 +01:00
|
|
|
./configure --ostype=debian --prefix=/usr
|
|
|
|
make prefix=/usr
|
|
|
|
make prefix=/usr install
|
|
|
|
if [ -f /usr/local/bin/prosody ]; then
|
|
|
|
echo $'Failed to build prosody nightly to /usr/bin'
|
2018-03-02 20:17:02 +01:00
|
|
|
rm "${INSTALL_DIR}/${prosody_filename}.tar.gz"
|
|
|
|
rm -rf "${INSTALL_DIR:?}/${prosody_filename}"
|
2017-03-11 17:14:24 +01:00
|
|
|
return
|
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
rm "${INSTALL_DIR:?}/${prosody_filename}.tar.gz"
|
2016-12-07 13:14:33 +01:00
|
|
|
fi
|
|
|
|
|
2017-03-11 17:14:24 +01:00
|
|
|
# add onion addresses for known servers
|
|
|
|
if ! grep -q "onions_map =" /etc/prosody/prosody.cfg.lua; then
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
xmpp_onion_addresses /etc/prosody/prosody.cfg.lua
|
2016-12-07 13:14:33 +01:00
|
|
|
fi
|
2017-01-29 14:37:13 +01:00
|
|
|
|
2017-03-11 17:14:24 +01:00
|
|
|
set_completion_param "prosody_filename" "${prosody_filename}"
|
2017-01-29 14:37:13 +01:00
|
|
|
fi
|
|
|
|
|
2018-03-03 12:49:17 +01:00
|
|
|
cp -r "$INSTALL_DIR/prosody-modules/"* /var/lib/prosody/prosody-modules/
|
2017-07-10 17:36:14 +02:00
|
|
|
chown -R prosody:prosody /var/lib/prosody/prosody-modules
|
|
|
|
|
2016-12-07 13:02:15 +01:00
|
|
|
systemctl restart prosody
|
2016-12-19 20:18:44 +01:00
|
|
|
}
|
2016-12-19 16:40:35 +01:00
|
|
|
|
2016-07-06 15:55:09 +02:00
|
|
|
function backup_local_xmpp {
|
2016-11-08 23:13:50 +01:00
|
|
|
source_directory=/var/lib/prosody
|
2016-08-28 10:55:47 +02:00
|
|
|
if [ -d $source_directory ]; then
|
|
|
|
dest_directory=xmpp
|
|
|
|
function_check backup_directory_to_usb
|
|
|
|
backup_directory_to_usb $source_directory $dest_directory
|
|
|
|
fi
|
2016-07-06 15:55:09 +02:00
|
|
|
}
|
|
|
|
|
2016-07-09 11:54:41 +02:00
|
|
|
function restore_local_xmpp {
|
2016-08-28 10:55:47 +02:00
|
|
|
if [ -d /var/lib/prosody ]; then
|
2016-10-01 21:20:02 +02:00
|
|
|
echo $"Restoring xmpp settings"
|
2016-08-28 10:55:47 +02:00
|
|
|
temp_restore_dir=/root/tempxmpp
|
|
|
|
function_check restore_directory_from_usb
|
|
|
|
restore_directory_from_usb $temp_restore_dir xmpp
|
2017-08-25 18:35:33 +02:00
|
|
|
if [ -d $temp_restore_dir/var/lib/prosody ]; then
|
|
|
|
cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
|
|
|
|
else
|
|
|
|
cp -r $temp_restore_dir/* /var/lib/prosody/
|
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
# shellcheck disable=SC2181
|
2016-08-28 10:55:47 +02:00
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
function_check set_user_permissions
|
|
|
|
set_user_permissions
|
|
|
|
function_check backup_unmount_drive
|
|
|
|
backup_unmount_drive
|
|
|
|
exit 725
|
|
|
|
fi
|
|
|
|
rm -rf $temp_restore_dir
|
2017-06-01 14:01:37 +02:00
|
|
|
systemctl restart prosody
|
2016-08-28 10:55:47 +02:00
|
|
|
chown -R prosody:prosody /var/lib/prosody/*
|
2016-10-01 21:20:02 +02:00
|
|
|
echo $"Restore of xmpp settings complete"
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
2016-07-09 11:54:41 +02:00
|
|
|
}
|
|
|
|
|
2016-07-06 15:55:09 +02:00
|
|
|
function backup_remote_xmpp {
|
2016-08-28 10:55:47 +02:00
|
|
|
if [ -d /var/lib/prosody ]; then
|
2016-10-01 21:20:02 +02:00
|
|
|
echo $"Backing up the xmpp settings"
|
2016-08-28 10:55:47 +02:00
|
|
|
backup_directory_to_friend /var/lib/prosody xmpp
|
2016-10-01 21:20:02 +02:00
|
|
|
echo $"Backup of xmpp settings complete"
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
2016-07-04 22:02:22 +02:00
|
|
|
}
|
|
|
|
|
2016-07-09 11:54:41 +02:00
|
|
|
function restore_remote_xmpp {
|
2016-08-28 10:55:47 +02:00
|
|
|
if [ -d /var/lib/prosody ]; then
|
2016-10-01 21:20:02 +02:00
|
|
|
echo $"Restoring xmpp settings"
|
2016-08-28 10:55:47 +02:00
|
|
|
temp_restore_dir=/root/tempxmpp
|
|
|
|
function_check restore_directory_from_friend
|
|
|
|
restore_directory_from_friend $temp_restore_dir xmpp
|
2017-08-25 18:35:33 +02:00
|
|
|
if [ -d $temp_restore_dir/var/lib/prosody ]; then
|
|
|
|
cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
|
|
|
|
else
|
|
|
|
cp -r $temp_restore_dir/* /var/lib/prosody/
|
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
# shellcheck disable=SC2181
|
2016-08-28 10:55:47 +02:00
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
exit 725
|
|
|
|
fi
|
|
|
|
rm -rf $temp_restore_dir
|
2017-06-01 14:01:37 +02:00
|
|
|
systemctl restart prosody
|
2016-08-28 10:55:47 +02:00
|
|
|
chown -R prosody:prosody /var/lib/prosody/*
|
2016-10-01 21:20:02 +02:00
|
|
|
echo $"Restore of xmpp settings complete"
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
2016-07-09 11:54:41 +02:00
|
|
|
}
|
|
|
|
|
2016-07-03 19:52:57 +02:00
|
|
|
function configure_firewall_for_xmpp {
|
2016-08-28 10:55:47 +02:00
|
|
|
if [ ! -d /etc/prosody ]; then
|
|
|
|
return
|
|
|
|
fi
|
2018-02-25 13:50:46 +01:00
|
|
|
if [[ $(is_completed "${FUNCNAME[0]}") == "1" ]]; then
|
2016-08-28 10:55:47 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
|
|
|
|
# docker does its own firewalling
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
if [[ $ONION_ONLY != "no" ]]; then
|
|
|
|
return
|
|
|
|
fi
|
2016-10-22 11:39:34 +02:00
|
|
|
firewall_add XMPP 5222 tcp
|
|
|
|
firewall_add XMPP 5223 tcp
|
|
|
|
firewall_add XMPP 5269 tcp
|
|
|
|
firewall_add XMPP 5280 tcp
|
|
|
|
firewall_add XMPP 5281 tcp
|
2018-02-25 13:50:46 +01:00
|
|
|
mark_completed "${FUNCNAME[0]}"
|
2016-07-03 17:13:34 +02:00
|
|
|
}
|
|
|
|
|
2016-07-04 20:36:56 +02:00
|
|
|
function remove_xmpp {
|
2017-05-16 22:26:24 +02:00
|
|
|
remove_profanity
|
2017-05-19 16:55:38 +02:00
|
|
|
remove_movim
|
2016-10-22 11:39:34 +02:00
|
|
|
firewall_remove 5222 tcp
|
|
|
|
firewall_remove 5223 tcp
|
|
|
|
firewall_remove 5269 tcp
|
|
|
|
firewall_remove 5280 tcp
|
|
|
|
firewall_remove 5281 tcp
|
2016-08-28 10:55:47 +02:00
|
|
|
|
|
|
|
function_check remove_onion_service
|
|
|
|
remove_onion_service xmpp 5222 5223 5269
|
|
|
|
|
2018-03-28 13:34:17 +02:00
|
|
|
apt-mark -q unhold prosody
|
2016-12-03 18:25:18 +01:00
|
|
|
apt-get -yq remove --purge prosody
|
2017-12-20 14:33:36 +01:00
|
|
|
rm /etc/cron.daily/prosody
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "$INSTALL_DIR/$prosody_modules_filename" ]; then
|
|
|
|
rm "$INSTALL_DIR/$prosody_modules_filename"
|
2017-05-17 23:02:04 +02:00
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -d "$INSTALL_DIR/prosody-modules" ]; then
|
|
|
|
rm -rf "$INSTALL_DIR/prosody-modules"
|
2017-05-17 23:02:04 +02:00
|
|
|
fi
|
2016-08-28 10:55:47 +02:00
|
|
|
if [ -d /etc/prosody ]; then
|
|
|
|
rm -rf /etc/prosody
|
|
|
|
fi
|
2016-10-30 00:44:57 +02:00
|
|
|
if [ -d /var/lib/prosody ]; then
|
|
|
|
rm -rf /var/lib/prosody
|
|
|
|
fi
|
2016-12-03 19:00:14 +01:00
|
|
|
if [ -d /usr/lib/prosody ]; then
|
|
|
|
rm -rf /usr/lib/prosody
|
|
|
|
fi
|
2016-12-03 19:17:41 +01:00
|
|
|
if [ -f /usr/local/bin/prosody ]; then
|
|
|
|
rm /usr/local/bin/prosody
|
|
|
|
fi
|
|
|
|
if [ -f /usr/local/bin/prosodyctl ]; then
|
|
|
|
rm /usr/local/bin/prosodyctl
|
|
|
|
fi
|
2016-12-03 12:40:11 +01:00
|
|
|
groupdel prosody
|
2016-08-28 10:55:47 +02:00
|
|
|
|
2016-10-17 15:44:49 +02:00
|
|
|
remove_completion_param install_xmpp
|
2018-03-02 20:17:02 +01:00
|
|
|
sed -i '/xmpp/d' "$COMPLETION_FILE"
|
|
|
|
sed -i '/prosody/d' "$COMPLETION_FILE"
|
2018-01-30 11:18:03 +01:00
|
|
|
|
|
|
|
rm /etc/avahi/services/xmpp.service
|
|
|
|
rm /etc/avahi/services/xmpp-server.service
|
|
|
|
systemctl restart avahi-daemon
|
2016-08-28 10:55:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function xmpp_email_headers {
|
|
|
|
for d in /home/*/ ; do
|
|
|
|
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
2016-10-01 11:48:07 +02:00
|
|
|
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "/home/$USERNAME/.muttrc" ]; then
|
|
|
|
if ! grep -q "Jabber-ID" "/home/$USERNAME/.muttrc"; then
|
|
|
|
echo "my_hdr Jabber-ID: ${USERNAME}@${HOSTNAME}" >> "/home/$USERNAME/.muttrc"
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2016-07-04 20:36:56 +02:00
|
|
|
}
|
|
|
|
|
2018-03-07 11:52:18 +01:00
|
|
|
function xmpp_contact_info {
|
|
|
|
filename="$1"
|
|
|
|
|
|
|
|
if grep -q "contact_info =" "$filename"; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2018-03-23 18:19:30 +01:00
|
|
|
{ echo 'contact_info = {';
|
|
|
|
echo "abuse = { \"mailto:${MY_EMAIL_ADDRESS}\", \"xmpp:${MY_USERNAME}@${HOSTNAME}\" };";
|
|
|
|
echo "admin = { \"mailto:${MY_EMAIL_ADDRESS}\", \"xmpp:${MY_USERNAME}@${HOSTNAME}\" };";
|
|
|
|
echo "feedback = { \"mailto:${MY_EMAIL_ADDRESS}\", \"xmpp:${MY_USERNAME}@${HOSTNAME}\" };";
|
|
|
|
echo "security = { \"xmpp:${MY_USERNAME}@${HOSTNAME}\" };";
|
|
|
|
echo "support = { \"xmpp:${MY_USERNAME}@${HOSTNAME}\" };";
|
|
|
|
echo '};'; } >> "$filename"
|
2018-03-07 11:52:18 +01:00
|
|
|
}
|
|
|
|
|
2016-12-03 12:18:19 +01:00
|
|
|
function xmpp_modules {
|
2018-03-02 20:17:02 +01:00
|
|
|
filename="$1"
|
|
|
|
|
|
|
|
{ echo 'modules_enabled = {';
|
2018-03-07 11:52:18 +01:00
|
|
|
echo ' "server_contact_info";';
|
2018-03-02 20:17:02 +01:00
|
|
|
echo ' "pubsub";';
|
|
|
|
echo ' "pubsub_hub";';
|
|
|
|
echo ' "dialback"; -- s2s dialback support';
|
|
|
|
echo ' "disco"; -- Service discovery';
|
|
|
|
echo ' "private"; -- Private XML storage (for room bookmarks, etc.)';
|
|
|
|
echo ' "version"; -- Replies to server version requests';
|
|
|
|
echo ' "uptime"; -- Report how long server has been running';
|
|
|
|
echo ' "time"; -- Let others know the time here on this server';
|
|
|
|
echo ' "ping"; -- Replies to XMPP pings with pongs';
|
|
|
|
echo ' "admin_adhoc"; -- Allows administration via an XMPP client that supports ad-hoc commands';
|
|
|
|
echo ' "posix"; -- POSIX functionality, sends server to background, enables syslog, etc.';
|
|
|
|
echo ' "bosh"; -- Enable mod_bosh';
|
|
|
|
echo ' "tls"; -- Enable mod_tls';
|
|
|
|
echo ' "saslauth"; -- Enable mod_saslauth';
|
|
|
|
echo ' "onions"; -- Enable chat via onion service';
|
|
|
|
echo ' "mam"; -- Message archive management';
|
|
|
|
echo ' "csi"; -- Client state indication';
|
|
|
|
echo ' "carbons"; -- Message carbons';
|
|
|
|
echo ' "carbons_adhoc"; -- Message carbons';
|
|
|
|
echo ' "carbons_copies"; -- Message carbons';
|
|
|
|
echo ' "smacks"; -- Stream management';
|
|
|
|
echo ' "smacks_offline"; -- Stream management';
|
|
|
|
echo ' "pep"; -- Personal Eventing Protocol (to support OMEMO)';
|
|
|
|
echo ' "omemo_all_access"; -- Fix for PEP with OMEMO';
|
|
|
|
echo ' "vcard"; -- Personal Eventing Protocol (to support OMEMO)';
|
|
|
|
echo ' "e2e_policy"; -- To support OMEMO';
|
|
|
|
echo ' "pep_vcard_avatar"; -- Personal Eventing Protocol (to support OMEMO)';
|
|
|
|
echo ' "blocklist"; -- Privacy lists';
|
|
|
|
echo ' "privacy_lists"; -- Privacy lists';
|
|
|
|
echo ' "blocking"; -- Blocking command';
|
2018-06-02 22:03:27 +02:00
|
|
|
echo ' "block_strangers"; -- Dont allow messages from strangers';
|
2018-03-02 20:17:02 +01:00
|
|
|
echo ' "roster"; -- Roster versioning';
|
|
|
|
echo ' "offline_email"; -- If offline send to email';
|
|
|
|
echo ' "offline"; -- Store offline messages';
|
|
|
|
echo ' "http";';
|
|
|
|
echo ' "http_upload";';
|
|
|
|
echo ' "websocket";';
|
|
|
|
echo ' "throttle_presence"; -- Reduce battery and bandwidth usage';
|
|
|
|
echo ' "filter_chatstates"; -- Reduce battery and bandwidth usage';
|
|
|
|
echo '};'; } >> "$filename"
|
2016-12-03 12:18:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-29 14:37:13 +01:00
|
|
|
function xmpp_onion_addresses {
|
2018-03-02 20:17:02 +01:00
|
|
|
filename="$1"
|
|
|
|
|
2018-03-07 11:57:26 +01:00
|
|
|
sed -i '/onions_map = {/,/};/d' "$filename"
|
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
{ echo 'onions_map = {';
|
|
|
|
echo ' ["anonymitaet-im-inter.net"] = "rwf5skuv5vqzcdit.onion";';
|
|
|
|
echo ' ["autistici.org"] = "wi7qkxyrdpu5cmvr.onion";';
|
|
|
|
echo ' ["jabber.calyxinstitute.org"] = "ijeeynrc6x2uy5ob.onion";';
|
|
|
|
echo ' ["jabber.ccc.de"] = "okj7xc6j2szr2y75.onion";';
|
|
|
|
echo ' ["cloak.dk"] = "m2dsl4banuimpm6c.onion";';
|
|
|
|
echo ' ["jabber.cryptoparty.is"] = "cryjabkbdljzohnp.onion";';
|
|
|
|
echo ' ["daemons.cf"] = "daemon4jidu2oig6.onion";';
|
|
|
|
echo ' ["dukgo.com"] = "wlcpmruglhxp6quz.onion";';
|
|
|
|
echo ' ["evil.im"] = "evilxro6nvjuvxqo.onion";';
|
|
|
|
echo ' ["xmpp.evil.im"] = "evilxro6nvjuvxqo.onion";';
|
|
|
|
echo ' ["inventati.org"] = "wi7qkxyrdpu5cmvr.onion";';
|
|
|
|
echo ' ["jabber.ipredator.se"] = "3iffdebkzzkpgipa.onion";';
|
|
|
|
echo ' ["jabber-germany.de"] = "dbbrphko5tqcpar3.onion";';
|
|
|
|
echo ' ["kode.im"] = "ihkw7qy3tok45dun.onion";';
|
|
|
|
echo ' ["im.koderoot.net"] = "ihkw7qy3tok45dun.onion";';
|
|
|
|
echo ' ["adb-centralen.se"] = "qai7jjjnhbrdiexf.onion";';
|
|
|
|
echo ' ["joelpurra.se"] = "37x6i3wgr2jyublb.onion";';
|
|
|
|
echo ' ["nordberg.se"] = "qai7jjjnhbrdiexf.onion";';
|
|
|
|
echo ' ["jabber.lqdn.fr"] = "jabber63t4r2qi57.onion";';
|
|
|
|
echo ' ["jabber.otr.im"] = "5rgdtlawqkcplz75.onion";';
|
|
|
|
echo ' ["otromundo.cf"] = "arauemwe2utqqzye.onion";';
|
|
|
|
echo ' ["patchcord.be"] = "xsydhi3dnbjuatpz.onion";';
|
|
|
|
echo ' ["riseup.net"] = "4cjw6cwpeaeppfqz.onion";';
|
|
|
|
echo ' ["xmpp.riseup.net"] = "4cjw6cwpeaeppfqz.onion";';
|
|
|
|
echo ' ["rows.io"] = "yz6yiv2hxyagvwy6.onion";';
|
|
|
|
echo ' ["xmpp.rows.io"] = "yz6yiv2hxyagvwy6.onion";';
|
|
|
|
echo ' ["securejabber.me"] = "giyvshdnojeivkom.onion";';
|
|
|
|
echo ' ["so36.net"] = "s4fgy24e2b5weqdb.onion";';
|
|
|
|
echo ' ["jabber.so36.net"] = "s4fgy24e2b5weqdb.onion";';
|
|
|
|
echo ' ["jabber.systemli.org"] = "x5tno6mwkncu5m3h.onion";';
|
|
|
|
echo ' ["taolo.ga"] = "l3ybpw4vs6ie5rv2.onion";';
|
|
|
|
echo ' ["tchncs.de"] = "duvfmyqmdlyvc3mi.onion";';
|
|
|
|
echo ' ["wtfismyip.com"] = "ofkztxcohimx34la.onion";';
|
|
|
|
echo ' ["prosody.xmpp.is"] = "y2qmqomqpszzryei.onion";';
|
|
|
|
echo ' ["xndr.de"] = "trcubpttd6zkc3tf.onion";';
|
|
|
|
echo ' ["jabber.cat"] = "sybzodlxacch7st7.onion";';
|
|
|
|
echo ' ["trashserver.net"] = "m4c722bvc2r7brnn.onion";';
|
|
|
|
echo '};'; } >> "$filename"
|
2017-01-29 14:37:13 +01:00
|
|
|
}
|
|
|
|
|
2016-12-03 12:18:19 +01:00
|
|
|
function xmpp_create_config {
|
|
|
|
echo "admins = { \"$MY_USERNAME@$DEFAULT_DOMAIN_NAME\" }" > /etc/prosody/prosody.cfg.lua
|
2016-12-03 18:13:43 +01:00
|
|
|
echo 'plugin_paths = { "/var/lib/prosody/prosody-modules" }' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
xmpp_modules /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
2017-01-29 14:37:13 +01:00
|
|
|
xmpp_onion_addresses /etc/prosody/prosody.cfg.lua
|
2018-03-07 11:52:18 +01:00
|
|
|
xmpp_contact_info /etc/prosody/prosody.cfg.lua
|
2018-03-02 20:17:02 +01:00
|
|
|
{ echo '';
|
|
|
|
echo 'allow_registration = false;';
|
|
|
|
echo '';
|
|
|
|
echo 'daemonize = true;';
|
|
|
|
echo '';
|
|
|
|
echo 'pidfile = "/var/run/prosody/prosody.pid";';
|
|
|
|
echo '';
|
|
|
|
echo 'https_ports = { 5281 }';
|
|
|
|
echo 'https_interfaces = { "*" }';
|
|
|
|
echo 'https_ssl = {'; } >> /etc/prosody/prosody.cfg.lua
|
|
|
|
if [ -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem" ]; then
|
2017-05-07 11:52:00 +02:00
|
|
|
echo " certificate = \"/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem\";" >> /etc/prosody/prosody.cfg.lua
|
2017-05-17 20:08:21 +02:00
|
|
|
echo " key = \"/etc/ssl/private/${DEFAULT_DOMAIN_NAME}.key\";" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 19:40:48 +01:00
|
|
|
else
|
2017-05-17 20:08:21 +02:00
|
|
|
echo " certificate = \"/etc/ssl/certs/xmpp.crt\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo " key = \"/etc/ssl/private/xmpp.key\";" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 19:40:48 +01:00
|
|
|
fi
|
2018-03-02 21:25:09 +01:00
|
|
|
{ echo " curve = $XMPP_ECC_CURVE;";
|
|
|
|
echo " ciphers = $XMPP_CIPHERS;";
|
|
|
|
echo ' options = {"no_sslv2", "no_sslv3" };'; } >> /etc/prosody/prosody.cfg.lua
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem" ]; then
|
2017-05-17 22:41:35 +02:00
|
|
|
echo " dhparam = \"/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.dhparam\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
else
|
|
|
|
echo " dhparam = \"/etc/ssl/certs/xmpp.dhparam\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
{ echo "}";
|
|
|
|
echo '';
|
|
|
|
echo 'ssl = {'; } >> /etc/prosody/prosody.cfg.lua
|
|
|
|
if [ -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem" ]; then
|
2017-05-07 11:52:00 +02:00
|
|
|
echo " certificate = \"/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem\";" >> /etc/prosody/prosody.cfg.lua
|
2017-05-17 20:08:21 +02:00
|
|
|
echo " key = \"/etc/ssl/private/${DEFAULT_DOMAIN_NAME}.key\";" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 19:40:48 +01:00
|
|
|
else
|
2017-05-17 20:08:21 +02:00
|
|
|
echo " certificate = \"/etc/ssl/certs/xmpp.crt\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo " key = \"/etc/ssl/private/xmpp.key\";" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 19:40:48 +01:00
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
{ echo " curve = $XMPP_ECC_CURVE;";
|
|
|
|
echo ' depth = "2";';
|
|
|
|
echo " ciphers = $XMPP_CIPHERS;";
|
|
|
|
echo ' options = {"no_sslv2", "no_sslv3" };'; } >> /etc/prosody/prosody.cfg.lua
|
|
|
|
if [ -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem" ]; then
|
2017-05-17 22:41:35 +02:00
|
|
|
echo " dhparam = \"/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.dhparam\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
else
|
|
|
|
echo " dhparam = \"/etc/ssl/certs/xmpp.dhparam\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
2018-04-25 11:04:02 +02:00
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
{ echo '}';
|
|
|
|
echo '';
|
|
|
|
echo 'c2s_require_encryption = true';
|
|
|
|
echo 's2s_require_encryption = true';
|
|
|
|
echo '';
|
2018-04-25 11:04:02 +02:00
|
|
|
echo 'e2e_policy_muc = "none"';
|
|
|
|
echo 'e2e_policy_chat = "required"';
|
|
|
|
echo "e2e_policy_message_required_chat = \"$xmpp_encryption_warning\"";
|
|
|
|
echo '';
|
2018-03-02 20:17:02 +01:00
|
|
|
echo 's2s_secure_auth = false';
|
|
|
|
echo '';
|
|
|
|
echo 'authentication = "internal_hashed"';
|
|
|
|
echo '';
|
|
|
|
echo 'storage = "sql"';
|
|
|
|
echo 'sql = { driver = "SQLite3", database = "prosody.sqlite" }';
|
|
|
|
echo '';
|
|
|
|
echo 'log = {';
|
|
|
|
echo ' info = "/dev/null";';
|
|
|
|
echo ' error = "/dev/null";';
|
|
|
|
echo ' { levels = { "error" }; to = "/dev/null"; };';
|
|
|
|
echo '}';
|
|
|
|
echo ''; } >> /etc/prosody/prosody.cfg.lua
|
|
|
|
if [[ "$ONION_ONLY" != 'no' ]]; then
|
2017-03-24 21:43:14 +01:00
|
|
|
echo "VirtualHost \"${XMPP_ONION_HOSTNAME}\"" >> /etc/prosody/prosody.cfg.lua
|
2018-04-25 11:04:02 +02:00
|
|
|
# TLS is not needed for onion transport security
|
|
|
|
sed -i 's|s2s_require_encryption =.*|s2s_require_encryption = false|g' /etc/prosody/prosody.cfg.lua
|
|
|
|
sed -i 's|c2s_require_encryption =.*|c2s_require_encryption = false|g' /etc/prosody/prosody.cfg.lua
|
2017-03-24 21:43:14 +01:00
|
|
|
else
|
|
|
|
echo "VirtualHost \"${DEFAULT_DOMAIN_NAME}\"" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
2016-12-03 12:18:19 +01:00
|
|
|
echo ' ssl = {' >> /etc/prosody/prosody.cfg.lua
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem" ]; then
|
2017-05-17 20:05:32 +02:00
|
|
|
echo " certificate = \"/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem\";" >> /etc/prosody/prosody.cfg.lua
|
2017-05-17 22:41:35 +02:00
|
|
|
echo " key = \"/etc/ssl/private/${DEFAULT_DOMAIN_NAME}.key\";" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 19:40:48 +01:00
|
|
|
else
|
2017-05-17 20:08:21 +02:00
|
|
|
echo " certificate = \"/etc/ssl/certs/xmpp.crt\";" >> /etc/prosody/prosody.cfg.lua
|
2017-05-17 22:41:35 +02:00
|
|
|
echo " key = \"/etc/ssl/private/xmpp.key\";" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 19:40:48 +01:00
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
{ echo " curve = $XMPP_ECC_CURVE;";
|
|
|
|
echo ' depth = "2";';
|
|
|
|
echo " ciphers = $XMPP_CIPHERS;";
|
|
|
|
echo ' options = {"no_sslv2", "no_sslv3" };'; } >> /etc/prosody/prosody.cfg.lua
|
|
|
|
if [ -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem" ]; then
|
2017-05-17 22:41:35 +02:00
|
|
|
echo " dhparam = \"/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.dhparam\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
else
|
|
|
|
echo " dhparam = \"/etc/ssl/certs/xmpp.dhparam\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
{ echo ' }';
|
|
|
|
echo '';
|
|
|
|
echo 'Include "conf.d/*.cfg.lua"';
|
|
|
|
echo 'http_upload_path = "/var/lib/prosody/http_uploads"';
|
|
|
|
echo 'http_upload_file_size_limit = 307200';
|
|
|
|
echo '';
|
|
|
|
echo "Component \"chat.${DEFAULT_DOMAIN_NAME}\" \"muc\"";
|
2018-03-23 11:23:25 +01:00
|
|
|
echo ' restrict_room_creation = true';
|
2018-03-02 20:17:02 +01:00
|
|
|
echo ' name = "Chatrooms"';
|
|
|
|
echo ' modules_enabled = {';
|
|
|
|
echo ' "muc_limits";';
|
|
|
|
echo ' "muc_log";';
|
|
|
|
echo ' "mam_muc";';
|
|
|
|
echo ' "muc_log_http";';
|
|
|
|
echo ' }';
|
|
|
|
echo 'storage = { muc_log = "sql"; }';
|
|
|
|
echo 'sql = { driver = "SQLite3", database = "prosody.sqlite" }';
|
|
|
|
echo 'muc_event_rate = 0.5;';
|
|
|
|
echo 'muc_burst_factor = 10;';
|
|
|
|
echo 'muc_log_by_default = false;';
|
|
|
|
echo 'muc_log_all_rooms = false;';
|
|
|
|
echo 'max_archive_query_results = 10;';
|
|
|
|
echo 'max_history_messages = 10;'; } >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
}
|
|
|
|
|
2016-12-03 23:20:28 +01:00
|
|
|
function install_xmpp_nightly {
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ ! -d "$INSTALL_DIR" ]; then
|
|
|
|
mkdir -p "$INSTALL_DIR"
|
2016-12-03 23:20:28 +01:00
|
|
|
fi
|
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
cd "$INSTALL_DIR" || exit 2468274
|
2017-01-16 16:38:08 +01:00
|
|
|
|
|
|
|
# Try to get the source from the project repo
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "/root/${PROJECT_NAME}/image_build/${prosody_filename}.tar.gz" ]; then
|
|
|
|
cp "/root/${PROJECT_NAME}/image_build/${prosody_filename}.tar.gz" .
|
2017-01-16 16:38:08 +01:00
|
|
|
else
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "/home/${MY_USERNAME}/${PROJECT_NAME}/image_build/${prosody_filename}.tar.gz" ]; then
|
|
|
|
cp "/home/${MY_USERNAME}/${PROJECT_NAME}/image_build/${prosody_filename}.tar.gz" .
|
2017-01-16 16:38:08 +01:00
|
|
|
else
|
2018-03-02 20:17:02 +01:00
|
|
|
wget "$prosody_nightly_url"
|
2017-01-16 16:38:08 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ ! -f "${INSTALL_DIR}/${prosody_filename}.tar.gz" ]; then
|
2016-12-07 13:14:33 +01:00
|
|
|
echo $"Failed to download prosody nightly $prosody_nightly_url"
|
2016-12-03 23:20:28 +01:00
|
|
|
exit 78352
|
|
|
|
fi
|
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
hash_value=$(sha256sum "${INSTALL_DIR}/${prosody_filename}.tar.gz" | awk -F ' ' '{print $1}')
|
2016-12-03 23:20:28 +01:00
|
|
|
if [[ "$hash_value" != "$prosody_nightly_hash" ]]; then
|
2018-03-02 20:17:02 +01:00
|
|
|
rm "${INSTALL_DIR}/${prosody_filename}.tar.gz"
|
2016-12-03 23:20:28 +01:00
|
|
|
echo $'Unexpected hash value for prosody nightly download'
|
|
|
|
exit 68224283
|
|
|
|
fi
|
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
tar -xzvf "${INSTALL_DIR}/${prosody_filename}.tar.gz"
|
|
|
|
cd "${INSTALL_DIR}/${prosody_filename}" || exit 7246284245
|
2016-12-04 00:13:19 +01:00
|
|
|
./configure --ostype=debian --prefix=/usr
|
|
|
|
make prefix=/usr
|
|
|
|
make prefix=/usr install
|
2016-12-04 00:01:58 +01:00
|
|
|
if [ -f /usr/local/bin/prosody ]; then
|
|
|
|
echo $'Failed to build prosody nightly to /usr/bin'
|
2018-03-02 20:17:02 +01:00
|
|
|
rm "${INSTALL_DIR}/${prosody_filename}.tar.gz"
|
|
|
|
rm -rf "${INSTALL_DIR:?}/${prosody_filename}"
|
2016-12-03 23:20:28 +01:00
|
|
|
exit 628732
|
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
rm "${INSTALL_DIR}/${prosody_filename}.tar.gz"
|
2017-03-11 17:14:24 +01:00
|
|
|
|
|
|
|
set_completion_param "prosody_filename" "${prosody_filename}"
|
2016-12-03 23:20:28 +01:00
|
|
|
}
|
|
|
|
|
2017-05-16 21:49:39 +02:00
|
|
|
function install_xmpp {
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ ! -d "$INSTALL_DIR" ]; then
|
|
|
|
mkdir -p "$INSTALL_DIR"
|
2017-05-17 23:05:05 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# remove any existing install attempt
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "$INSTALL_DIR/$prosody_modules_filename" ]; then
|
|
|
|
rm "$INSTALL_DIR/$prosody_modules_filename"
|
2017-05-17 23:05:05 +02:00
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -d "$INSTALL_DIR/prosody-modules" ]; then
|
|
|
|
rm -rf "$INSTALL_DIR/prosody-modules"
|
2017-05-17 23:05:05 +02:00
|
|
|
fi
|
|
|
|
|
2016-08-28 10:55:47 +02:00
|
|
|
update_prosody_modules
|
|
|
|
|
2017-05-21 21:12:01 +02:00
|
|
|
# obtain a cert for the default domain
|
2018-03-02 20:17:02 +01:00
|
|
|
if [[ "$(cert_exists "${DEFAULT_DOMAIN_NAME}" pem)" == "0" ]]; then
|
|
|
|
create_site_certificate "${DEFAULT_DOMAIN_NAME}" 'yes'
|
|
|
|
if [[ "$ONION_ONLY" == 'no' ]]; then
|
|
|
|
if [[ "$(cert_exists "${DEFAULT_DOMAIN_NAME}" pem)" == "0" ]]; then
|
2017-05-21 21:12:01 +02:00
|
|
|
echo $'LetsEncrypt cert could not be obtained for xmpp'
|
|
|
|
exit 72342
|
|
|
|
fi
|
2016-10-26 22:16:52 +02:00
|
|
|
fi
|
2016-10-26 17:10:46 +02:00
|
|
|
fi
|
|
|
|
|
2016-12-03 18:13:43 +01:00
|
|
|
apt-get -yq install lua-sec lua-bitop lua5.1 liblua5.1-dev
|
|
|
|
apt-get -yq install libidn11-dev libssl-dev lua-dbi-sqlite3
|
2017-03-24 20:13:39 +01:00
|
|
|
apt-get -yq install mercurial
|
2016-12-03 18:20:59 +01:00
|
|
|
apt-get -yq install prosody
|
2016-08-28 10:55:47 +02:00
|
|
|
|
2017-03-24 20:11:23 +01:00
|
|
|
if [ ! -f /usr/bin/hg ]; then
|
|
|
|
echo $"Couldn't install mercurial"
|
|
|
|
exit 52825
|
|
|
|
fi
|
|
|
|
|
2016-08-28 10:55:47 +02:00
|
|
|
if [ ! -d /etc/prosody ]; then
|
|
|
|
echo $"ERROR: prosody does not appear to have installed. $CHECK_MESSAGE"
|
2016-10-26 13:51:37 +02:00
|
|
|
exit 52367
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
|
|
|
|
2016-12-03 12:40:11 +01:00
|
|
|
groupadd prosody
|
|
|
|
|
2016-12-03 18:13:43 +01:00
|
|
|
if [ ! -d /var/lib/prosody/http_uploads ]; then
|
|
|
|
mkdir -p /var/lib/prosody/http_uploads
|
2016-12-03 12:40:11 +01:00
|
|
|
fi
|
2016-12-03 12:43:01 +01:00
|
|
|
if [ ! -d /etc/prosody/conf.d ]; then
|
2017-05-17 20:45:22 +02:00
|
|
|
mkdir -p /etc/prosody/conf.d
|
2016-12-03 12:43:01 +01:00
|
|
|
fi
|
2016-12-03 12:40:11 +01:00
|
|
|
|
2016-12-03 18:13:43 +01:00
|
|
|
chmod -R 700 /etc/prosody/conf.d
|
|
|
|
chown -R prosody /var/lib/prosody
|
|
|
|
chown -R prosody /etc/prosody/conf.d
|
|
|
|
|
2017-05-14 23:10:31 +02:00
|
|
|
# install modules
|
|
|
|
update_prosody_modules initial
|
2017-05-15 18:53:46 +02:00
|
|
|
if [ ! -d /var/lib/prosody/prosody-modules ]; then
|
|
|
|
echo $'No prosody modules available'
|
2017-05-17 22:10:32 +02:00
|
|
|
exit 82634
|
2017-05-15 18:53:46 +02:00
|
|
|
fi
|
2016-08-28 10:55:47 +02:00
|
|
|
|
|
|
|
# create a certificate
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ ! -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem" ]; then
|
2017-05-16 17:09:57 +02:00
|
|
|
if [ ! -f /etc/ssl/certs/xmpp.crt ]; then
|
2018-03-02 20:17:02 +01:00
|
|
|
"${PROJECT_NAME}-addcert" -h xmpp --dhkey "${DH_KEYLENGTH}"
|
2018-03-03 23:36:56 +01:00
|
|
|
CHECK_HOSTNAME=xmpp
|
2016-10-26 13:51:37 +02:00
|
|
|
check_certificates xmpp
|
2017-05-16 17:09:57 +02:00
|
|
|
if [ ! -f /etc/ssl/certs/xmpp.crt ]; then
|
|
|
|
echo $'Failed to create xmpp certificate'
|
|
|
|
exit 72352
|
|
|
|
fi
|
|
|
|
if [ ! -f /etc/ssl/private/xmpp.key ]; then
|
|
|
|
echo $'Failed to create xmpp private certificate'
|
|
|
|
exit 36829
|
|
|
|
fi
|
2017-05-17 22:41:35 +02:00
|
|
|
chmod g=rX /etc/ssl/private/xmpp.key
|
|
|
|
chmod g=rX /etc/ssl/certs/xmpp.*
|
2016-10-26 13:51:37 +02:00
|
|
|
fi
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
2016-10-26 22:16:52 +02:00
|
|
|
|
|
|
|
groupadd default
|
2016-11-29 16:00:40 +01:00
|
|
|
chmod 600 /etc/shadow
|
|
|
|
chmod 600 /etc/gshadow
|
2016-10-26 22:16:52 +02:00
|
|
|
usermod -g default prosody
|
2016-11-29 16:00:40 +01:00
|
|
|
chmod 0000 /etc/shadow
|
|
|
|
chmod 0000 /etc/gshadow
|
2016-10-26 22:16:52 +02:00
|
|
|
|
|
|
|
chown root:default /etc/ssl/private/xmpp.*
|
|
|
|
chown root:default /etc/ssl/certs/xmpp.*
|
2018-03-02 20:17:02 +01:00
|
|
|
chown root:default "/etc/ssl/private/${DEFAULT_DOMAIN_NAME}.*"
|
|
|
|
chown root:default "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.*"
|
2016-10-26 20:58:48 +02:00
|
|
|
|
2016-08-28 10:55:47 +02:00
|
|
|
cp -a /etc/prosody/conf.avail/example.com.cfg.lua /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
if [[ "$(cert_exists "${DEFAULT_DOMAIN_NAME}" pem)" == "1" ]]; then
|
2017-05-17 21:16:28 +02:00
|
|
|
sed -i "s|key =.*|key = \"/etc/ssl/private/${DEFAULT_DOMAIN_NAME}.key\";|g" /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
sed -i "s|certificate =.*|certificate = \"/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem\";|g" /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-10-26 13:51:37 +02:00
|
|
|
else
|
2017-05-17 22:41:35 +02:00
|
|
|
sed -i "s|key =.*|key = \"/etc/ssl/private/xmpp.key\";|g" /etc/prosody/conf.avail/xmpp.cfg.lua
|
2017-05-17 21:16:28 +02:00
|
|
|
sed -i "s|certificate =.*|certificate = \"/etc/ssl/certs/xmpp.crt\";|g" /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-10-26 13:51:37 +02:00
|
|
|
fi
|
2016-08-28 10:55:47 +02:00
|
|
|
if ! grep -q "xmpp.dhparam" /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
2018-03-02 20:17:02 +01:00
|
|
|
if [[ "$(cert_exists "${DEFAULT_DOMAIN_NAME}")" == "1" ]]; then
|
|
|
|
sed -i "/certificate =/a\\ dhparam = \"/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.dhparam\";" /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-10-26 13:51:37 +02:00
|
|
|
else
|
2018-03-02 20:17:02 +01:00
|
|
|
sed -i '/certificate =/a\\ dhparam = "/etc/ssl/certs/xmpp.dhparam";' /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-10-26 13:51:37 +02:00
|
|
|
fi
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
2017-05-07 12:33:34 +02:00
|
|
|
if ! grep -q 'options = {"no_sslv2", "no_sslv3" }' /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
|
|
|
sed -i '/certificate =/a\ options = {"no_sslv2", "no_sslv3" };' /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
|
|
|
if ! grep -q 'ciphers =' /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
2018-03-02 20:17:02 +01:00
|
|
|
sed -i "/certificate =/a\\ ciphers = $XMPP_CIPHERS;" /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
2017-05-07 12:17:21 +02:00
|
|
|
if ! grep -q 'depth = "2";' /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
|
|
|
sed -i '/certificate =/a\ depth = "2";' /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
|
|
|
if ! grep -q 'curve =' /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
2018-03-02 20:17:02 +01:00
|
|
|
sed -i "/certificate =/a\\ curve = $XMPP_ECC_CURVE;" /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
sed -i "s/example.com/$DEFAULT_DOMAIN_NAME/g" /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
sed -i 's/enabled = false -- Remove this line to enable this host//g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
|
|
|
|
if ! grep -q "modules_enabled" /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
|
|
|
echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
xmpp_modules /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
fi
|
|
|
|
echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
if ! grep -q "c2s_require_encryption" /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
2016-08-28 10:55:47 +02:00
|
|
|
echo 'c2s_require_encryption = true' >> /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
else
|
|
|
|
sed -i 's|c2s_require_encryption.*|c2s_require_encryption = true|g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
fi
|
|
|
|
if ! grep -q "s2s_require_encryption" /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
2016-08-28 10:55:47 +02:00
|
|
|
echo 's2s_require_encryption = true' >> /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
else
|
|
|
|
sed -i 's|s2s_require_encryption.*|s2s_require_encryption = true|g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
fi
|
2018-04-25 13:55:35 +02:00
|
|
|
|
|
|
|
if [[ "$ONION_ONLY" != 'no' ]]; then
|
|
|
|
sed -i 's|c2s_require_encryption.*|c2s_require_encryption = false|g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
sed -i 's|s2s_require_encryption.*|s2s_require_encryption = false|g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
fi
|
|
|
|
|
|
|
|
xmpp_update_e2e_policy /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
|
2016-12-03 12:18:19 +01:00
|
|
|
if ! grep -q "allow_unencrypted_plain_auth" /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
2016-08-28 10:55:47 +02:00
|
|
|
echo 'allow_unencrypted_plain_auth = false' >> /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
else
|
|
|
|
sed -i 's|allow_unencrypted_plain_auth.*|allow_unencrypted_plain_auth = false|g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
|
|
|
ln -sf /etc/prosody/conf.avail/xmpp.cfg.lua /etc/prosody/conf.d/xmpp.cfg.lua
|
|
|
|
|
|
|
|
if [ ! -d /var/lib/tor ]; then
|
2016-10-01 21:20:02 +02:00
|
|
|
echo $'No Tor installation found. xmpp onion site cannot be configured.'
|
2016-08-28 10:55:47 +02:00
|
|
|
exit 877367
|
|
|
|
fi
|
2018-05-01 17:19:40 +02:00
|
|
|
if ! grep -q "hidden_service_xmpp" "$ONION_SERVICES_FILE"; then
|
2018-03-02 20:17:02 +01:00
|
|
|
{ echo 'HiddenServiceDir /var/lib/tor/hidden_service_xmpp/';
|
2018-05-19 11:01:38 +02:00
|
|
|
echo 'HiddenServiceVersion 3';
|
2018-03-02 20:17:02 +01:00
|
|
|
echo "HiddenServicePort 5222 127.0.0.1:5222";
|
2018-05-01 17:19:40 +02:00
|
|
|
echo "HiddenServicePort 5269 127.0.0.1:5269"; } >> "$ONION_SERVICES_FILE"
|
2016-10-01 21:20:02 +02:00
|
|
|
echo $'Added onion site for xmpp chat'
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
|
|
|
|
2016-10-18 11:48:57 +02:00
|
|
|
onion_update
|
2016-08-28 10:55:47 +02:00
|
|
|
wait_for_onion_service 'xmpp'
|
|
|
|
|
|
|
|
if [ ! -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
|
2016-10-01 21:20:02 +02:00
|
|
|
echo $'xmpp onion site hostname not found'
|
2016-08-28 10:55:47 +02:00
|
|
|
exit 65349
|
|
|
|
fi
|
|
|
|
XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
|
|
|
|
if ! grep -q "${XMPP_ONION_HOSTNAME}" /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
2018-03-02 20:17:02 +01:00
|
|
|
{ echo '';
|
|
|
|
echo "VirtualHost \"${XMPP_ONION_HOSTNAME}\"";
|
|
|
|
echo ' modules_enabled = { "onions" };'; } >> /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
2016-10-16 20:50:56 +02:00
|
|
|
set_completion_param "xmpp onion domain" "${XMPP_ONION_HOSTNAME}"
|
2016-08-28 10:55:47 +02:00
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
|
|
|
XMPP_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
2016-11-19 20:17:33 +01:00
|
|
|
else
|
2016-08-28 10:55:47 +02:00
|
|
|
if [ ${#XMPP_PASSWORD} -lt 8 ]; then
|
2018-03-02 20:17:02 +01:00
|
|
|
XMPP_PASSWORD="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
|
|
|
fi
|
2016-12-03 12:40:11 +01:00
|
|
|
|
2016-08-28 10:55:47 +02:00
|
|
|
function_check configure_firewall_for_xmpp
|
|
|
|
configure_firewall_for_xmpp
|
|
|
|
xmpp_email_headers
|
|
|
|
|
2016-11-22 12:02:50 +01:00
|
|
|
update_default_domain
|
|
|
|
|
2016-12-03 12:18:19 +01:00
|
|
|
xmpp_create_config
|
|
|
|
|
2016-12-03 23:20:28 +01:00
|
|
|
# TODO comment this out after debian supports prosody 0.10 or later
|
|
|
|
install_xmpp_nightly
|
|
|
|
|
2016-12-03 23:42:40 +01:00
|
|
|
chown -R prosody /etc/prosody
|
|
|
|
chown -R prosody /var/lib/prosody
|
|
|
|
chown -R prosody /usr/lib/prosody
|
|
|
|
chmod -R 700 /etc/prosody/conf.d
|
2017-05-17 22:41:35 +02:00
|
|
|
usermod -a -G www-data prosody
|
2016-12-03 23:42:40 +01:00
|
|
|
|
2018-01-20 10:58:43 +01:00
|
|
|
# Avoid STIG failures
|
|
|
|
if [ -f /usr/lib/ssl/private/xmpp.key ]; then
|
|
|
|
chown root:root /usr/lib/ssl/private/xmpp.key
|
|
|
|
fi
|
|
|
|
if [ -f /usr/lib/ssl/certs/xmpp.crt ]; then
|
|
|
|
chown root:root /usr/lib/ssl/certs/xmpp.crt
|
|
|
|
fi
|
|
|
|
if [ -f /usr/lib/ssl/certs/xmpp.dhparam ]; then
|
|
|
|
chown root:root /usr/lib/ssl/certs/xmpp.dhparam
|
|
|
|
fi
|
|
|
|
|
2017-05-07 11:52:00 +02:00
|
|
|
if [ -d /etc/letsencrypt ]; then
|
|
|
|
usermod -a -G ssl-cert prosody
|
|
|
|
fi
|
2018-01-21 01:09:20 +01:00
|
|
|
|
|
|
|
if [ -f /etc/ssl/certs/xmpp.dhparam ]; then
|
|
|
|
cp /etc/ssl/certs/xmpp.dhparam /etc/prosody/xmpp.dhparam
|
|
|
|
chown prosody:prosody /etc/prosody/xmpp.dhparam
|
|
|
|
sed -i 's|/etc/ssl/certs/xmpp.dhparam|/etc/prosody/xmpp.dhparam|g' /etc/prosody/prosody.cfg.lua
|
|
|
|
sed -i 's|/etc/ssl/certs/xmpp.dhparam|/etc/prosody/xmpp.dhparam|g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
fi
|
|
|
|
|
2017-08-11 11:38:40 +02:00
|
|
|
apt-mark -q hold prosody
|
2016-11-22 12:02:50 +01:00
|
|
|
systemctl restart prosody
|
|
|
|
|
2017-03-24 20:57:14 +01:00
|
|
|
if [[ $ONION_ONLY != 'no' ]]; then
|
2018-03-02 20:17:02 +01:00
|
|
|
prosodyctl register "$MY_USERNAME" "$XMPP_ONION_HOSTNAME" "$XMPP_PASSWORD"
|
2017-03-24 20:57:14 +01:00
|
|
|
else
|
2018-03-02 20:17:02 +01:00
|
|
|
prosodyctl register "$MY_USERNAME" "$DEFAULT_DOMAIN_NAME" "$XMPP_PASSWORD"
|
2017-03-24 20:57:14 +01:00
|
|
|
fi
|
2018-03-02 20:17:02 +01:00
|
|
|
# shellcheck disable=SC2181
|
2016-12-03 18:18:19 +01:00
|
|
|
if [ ! "$?" = "0" ]; then
|
2016-12-04 00:01:58 +01:00
|
|
|
echo ''
|
|
|
|
echo ''
|
|
|
|
systemctl status prosody -l
|
2016-12-03 23:38:35 +01:00
|
|
|
echo ''
|
|
|
|
echo ''
|
|
|
|
which prosody
|
|
|
|
which prosodyctl
|
2016-12-03 23:33:48 +01:00
|
|
|
echo ''
|
|
|
|
echo ''
|
|
|
|
cat /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ''
|
|
|
|
echo ''
|
2016-12-03 23:38:35 +01:00
|
|
|
cat /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
echo ''
|
|
|
|
echo ''
|
2017-05-17 21:09:09 +02:00
|
|
|
#remove_xmpp
|
2016-12-03 18:18:19 +01:00
|
|
|
echo $'Unable to register prosody user'
|
|
|
|
exit 347682
|
|
|
|
fi
|
|
|
|
|
2017-12-20 14:44:27 +01:00
|
|
|
prosody_daemon_restart_script
|
2017-12-20 14:33:36 +01:00
|
|
|
|
2018-03-02 20:17:02 +01:00
|
|
|
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a xmpp -p "$XMPP_PASSWORD"
|
2016-12-03 18:18:19 +01:00
|
|
|
|
2018-01-30 11:18:03 +01:00
|
|
|
# Add avahi services
|
2018-03-02 20:17:02 +01:00
|
|
|
{ echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->';
|
|
|
|
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">';
|
|
|
|
echo '<service-group>';
|
|
|
|
echo ' <name replace-wildcards="yes">%h XMPP</name>';
|
|
|
|
echo ' <service>';
|
|
|
|
echo ' <type>_xmpp._tcp</type>';
|
|
|
|
echo " <port>5222</port>";
|
|
|
|
echo ' </service>';
|
|
|
|
echo ' <service>';
|
|
|
|
echo ' <type>_xmpp-server._tcp</type>';
|
|
|
|
echo " <port>5269</port>";
|
|
|
|
echo ' </service>';
|
|
|
|
echo '</service-group>'; } > /etc/avahi/services/xmpp.service
|
2018-01-30 11:18:03 +01:00
|
|
|
|
|
|
|
systemctl restart avahi-daemon
|
|
|
|
|
2016-10-10 20:11:33 +02:00
|
|
|
APP_INSTALLED=1
|
2016-07-05 22:50:11 +02:00
|
|
|
}
|
|
|
|
|
2016-07-03 17:13:34 +02:00
|
|
|
# NOTE: deliberately no exit 0
|