2016-07-03 17:13:34 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# .---. . .
|
|
|
|
# | | |
|
|
|
|
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
|
|
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
|
|
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
|
|
#
|
|
|
|
# Freedom in the Cloud
|
|
|
|
#
|
|
|
|
# XMPP functions
|
|
|
|
#
|
|
|
|
# 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-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'
|
2017-01-16 16:15:30 +01:00
|
|
|
prosody_nightly=333
|
2017-01-16 16:38:08 +01:00
|
|
|
prosody_nightly_hash='a104a1b211eeff88247f1b98d7897c96b9d2f76a12b6d738a4c955e569821363'
|
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"
|
2016-12-07 10:16:38 +01:00
|
|
|
|
2016-12-19 16:40:35 +01:00
|
|
|
LIBMESODE_REPO="https://github.com/boothj5/libmesode"
|
|
|
|
LIBMESODE_COMMIT='e3db0e9bfba61b2d82193874343a94a88f910800'
|
|
|
|
|
|
|
|
PROFANITY_REPO="https://github.com/boothj5/profanity"
|
2017-02-09 19:20:17 +01:00
|
|
|
PROFANITY_COMMIT='1242fb7f71e32426e09e9c1dcb61aa398fc41209'
|
2016-12-19 16:40:35 +01:00
|
|
|
|
|
|
|
PROFANITY_OMEMO_PLUGIN_REPO="https://github.com/ReneVolution/profanity-omemo-plugin"
|
2017-02-09 19:20:17 +01:00
|
|
|
PROFANITY_OMEMO_PLUGIN_COMMIT='3ec8ec173656bed9761b740b086123e07c749548'
|
2016-12-19 16:40:35 +01:00
|
|
|
|
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
|
2016-10-26 13:51:37 +02:00
|
|
|
DEFAULT_DOMAIN_NAME
|
|
|
|
XMPP_DOMAIN_CODE)
|
2016-10-05 23:33:41 +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
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
function xmpp_add_onion_address_interactive {
|
|
|
|
data=$(tempfile 2>/dev/null)
|
|
|
|
trap "rm -f $data" 0 1 2 5 15
|
|
|
|
dialog --backtitle $"Freedombone Control Panel" \
|
|
|
|
--title $"Add an ICANN to Onion domain mapping" \
|
|
|
|
--form $"Sepecify an ICANN domain name and its equivalent onion address\n" 9 50 2 \
|
|
|
|
$"Domain:" 1 1 "" 1 18 26 25 \
|
|
|
|
$"Onion address:" 2 1 "" 2 18 26 25 \
|
|
|
|
2> $data
|
|
|
|
sel=$?
|
|
|
|
case $sel in
|
|
|
|
1) return;;
|
|
|
|
255) return;;
|
|
|
|
esac
|
|
|
|
domain_name=$(cat $data | sed -n 1p)
|
|
|
|
onion_address=$(cat $data | sed -n 2p)
|
|
|
|
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
|
|
|
|
if grep -q "[\"${domain_name}\"]" /etc/prosody/prosody.cfg.lua; then
|
|
|
|
sed -i "/[\"${domain_name}\"]/d" /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
|
|
|
|
|
|
|
if grep -q "= \"${domain_name}\";" /etc/prosody/prosody.cfg.lua; then
|
|
|
|
sed -i "/= \"${domain_name}\";/d" /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
|
|
|
systemctl restart prosody
|
|
|
|
}
|
|
|
|
|
|
|
|
function xmpp_remove_onion_address_interactive {
|
|
|
|
data=$(tempfile 2>/dev/null)
|
|
|
|
trap "rm -f $data" 0 1 2 5 15
|
|
|
|
dialog --title $"Remove ICANN to Onion domain mapping" \
|
|
|
|
--backtitle $"Freedombone Control Panel" \
|
|
|
|
--inputbox $'Enter the domain name or onion address to be removed' 8 60 2>$data
|
|
|
|
sel=$?
|
|
|
|
case $sel in
|
|
|
|
0) domain_name=$(<$data)
|
|
|
|
if [[ "$domain_name" != *"."* ]]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
xmpp_remove_onion_address "$domain_name"
|
|
|
|
dialog --title $"Remove an ICANN to Onion domain mapping" \
|
|
|
|
--msgbox $"${domain_name} removed" 6 70
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
function configure_interactive_xmpp {
|
|
|
|
while true
|
|
|
|
do
|
|
|
|
data=$(tempfile 2>/dev/null)
|
|
|
|
trap "rm -f $data" 0 1 2 5 15
|
|
|
|
dialog --backtitle $"Freedombone Control Panel" \
|
|
|
|
--title $"XMPP" \
|
|
|
|
--radiolist $"Choose an operation:" 12 70 3 \
|
|
|
|
1 $"Add an ICANN to onion domain mapping" off \
|
|
|
|
2 $"Remove an ICANN to onion domain mapping" off \
|
2017-01-29 14:46:57 +01:00
|
|
|
3 $"Return to administrator control panel" on 2> $data
|
2017-01-29 14:37:13 +01:00
|
|
|
sel=$?
|
|
|
|
case $sel in
|
|
|
|
1) return;;
|
|
|
|
255) return;;
|
|
|
|
esac
|
|
|
|
case $(cat $data) in
|
|
|
|
1) xmpp_add_onion_address_interactive;;
|
|
|
|
2) xmpp_remove_onion_address_interactive;;
|
|
|
|
3) break;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-10-02 12:17:01 +02:00
|
|
|
function remove_user_xmpp {
|
|
|
|
remove_username="$1"
|
2016-11-19 20:17:33 +01:00
|
|
|
${PROJECT_NAME}-pass -u $remove_username --rmapp xmpp
|
2017-03-24 20:57:14 +01:00
|
|
|
XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
|
|
|
|
if [[ $ONION_ONLY != "no" ]]; then
|
|
|
|
${PROJECT_NAME}-rmxmpp -e "${remove_username}@${XMPP_ONION_HOSTNAME}"
|
|
|
|
else
|
|
|
|
${PROJECT_NAME}-rmxmpp -e "${remove_username}@${HOSTNAME}"
|
|
|
|
fi
|
2016-10-02 12:17:01 +02:00
|
|
|
}
|
2016-10-02 00:39:56 +02:00
|
|
|
|
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)
|
2016-11-19 20:17:33 +01:00
|
|
|
${PROJECT_NAME}-pass -u $new_username -a xmpp -p "$new_user_password"
|
|
|
|
|
2017-03-24 20:57:14 +01:00
|
|
|
if [[ $ONION_ONLY != "no" ]]; then
|
|
|
|
${PROJECT_NAME}-addxmpp -e "$new_username@$XMPP_ONION_HOSTNAME" -p "$new_user_password"
|
|
|
|
else
|
|
|
|
${PROJECT_NAME}-addxmpp -e "$new_username@$HOSTNAME" -p "$new_user_password"
|
|
|
|
fi
|
2016-10-02 00:39:56 +02:00
|
|
|
if [ ! "$?" = "0" ]; then
|
2016-10-02 12:17:01 +02:00
|
|
|
echo '1'
|
2016-10-02 00:39:56 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
XMPP_CLIENT_DIR=/home/$new_username/.local/share/profanity
|
|
|
|
XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
|
|
|
|
if [ ! -d $XMPP_CLIENT_DIR ]; then
|
|
|
|
mkdir -p $XMPP_CLIENT_DIR
|
|
|
|
fi
|
|
|
|
if [ ! -d /home/$new_username/.config/profanity ]; then
|
|
|
|
mkdir -p /home/$new_username/.config/profanity
|
|
|
|
fi
|
2017-02-09 19:17:54 +01:00
|
|
|
GPG_PUBLIC_KEY_ID=$(su -c "gpg --list-keys $new_username@$HOSTNAME | grep 'pub '" - $new_username | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
2016-10-02 00:39:56 +02:00
|
|
|
echo "[${new_username}@${HOSTNAME}]" > $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo "jid=${new_username}@${HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
|
2017-02-09 17:10:58 +01:00
|
|
|
echo "server=$XMPP_ONION_HOSTNAME" >> $XMPP_CLIENT_ACCOUNTS
|
2017-02-09 19:17:54 +01:00
|
|
|
echo "pgp.keyid=$GPG_PUBLIC_KEY_ID" >> $XMPP_CLIENT_ACCOUNTS
|
2016-10-02 00:39:56 +02:00
|
|
|
echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo "muc.service=conference.${HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo "muc.nick=${new_username}" >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.online=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.chat=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
|
|
|
|
echo '[connection]' > /home/$new_username/.config/profanity/profrc
|
2017-03-24 20:57:14 +01:00
|
|
|
if [[ $ONION_ONLY != "no" ]]; then
|
|
|
|
echo "account=${new_username}@${XMPP_ONION_HOSTNAME}" >> /home/$new_username/.config/profanity/profrc
|
|
|
|
else
|
|
|
|
echo "account=${new_username}@${HOSTNAME}" >> /home/$new_username/.config/profanity/profrc
|
|
|
|
fi
|
2017-02-09 22:41:38 +01:00
|
|
|
echo '' >> /home/$new_username/.config/profanity/profrc
|
|
|
|
echo '[plugins]' >> /home/$new_username/.config/profanity/profrc
|
|
|
|
echo 'load=prof_omemo_plugin.py;' >> /home/$new_username/.config/profanity/profrc
|
2017-02-11 00:16:33 +01:00
|
|
|
echo '' >> /home/$new_username/.config/profanity/profrc
|
|
|
|
echo '[otr]' >> /home/$new_username/.config/profanity/profrc
|
|
|
|
echo 'policy=opportunistic' >> /home/$new_username/.config/profanity/profrc
|
2017-02-11 00:24:18 +01:00
|
|
|
echo 'log=off' >> /home/$new_username/.config/profanity/profrc
|
2017-02-11 00:25:13 +01:00
|
|
|
echo '' >> /home/$new_username/.config/profanity/profrc
|
|
|
|
echo '[pgp]' >> /home/$new_username/.config/profanity/profrc
|
|
|
|
echo 'log=off' >> /home/$new_username/.config/profanity/profrc
|
2017-02-11 00:26:22 +01:00
|
|
|
echo '' >> /home/$new_username/.config/profanity/profrc
|
|
|
|
echo '[ui]' >> /home/$new_username/.config/profanity/profrc
|
|
|
|
echo 'enc.warn=true' >> /home/$new_username/.config/profanity/profrc
|
2016-10-02 00:39:56 +02:00
|
|
|
|
|
|
|
chown -R $new_username:$new_username /home/$new_username/.local
|
|
|
|
chown -R $new_username:$new_username /home/$new_username/.config
|
|
|
|
echo '0'
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:59:37 +02:00
|
|
|
function run_client_xmpp {
|
|
|
|
torify profanity
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
|
${PROJECT_NAME}-pass -u $curr_username -a xmpp -p "$new_user_password"
|
|
|
|
|
|
|
|
# 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'
|
|
|
|
prosodyctl passwd ${curr_username}@${DEFAULT_DOMAIN_NAME}
|
2016-12-19 16:40:35 +01:00
|
|
|
|
|
|
|
XMPP_CLIENT_DIR=/home/$curr_username/.local/share/profanity
|
|
|
|
XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
|
|
|
|
if [ -f $XMPP_CLIENT_ACCOUNTS ]; then
|
|
|
|
sed -i "s|password=.*|password=$new_user_password|g" $XMPP_CLIENT_ACCOUNTS
|
|
|
|
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 {
|
2016-12-03 18:13:43 +01:00
|
|
|
if [ ! -d /var/lib/prosody/prosody-modules ]; then
|
2016-08-28 10:55:47 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
if [ ! -d /usr/lib/prosody ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2016-12-03 18:13:43 +01:00
|
|
|
cd /var/lib/prosody/prosody-modules
|
2016-08-28 10:55:47 +02:00
|
|
|
hg pull
|
|
|
|
hg update
|
2017-01-07 13:00:33 +01:00
|
|
|
|
|
|
|
# change to using profile rather than pep and vcard modules
|
|
|
|
if grep '"pep"' /etc/prosody/prosody.cfg.lua; then
|
|
|
|
if grep '"vcard"' /etc/prosody/prosody.cfg.lua; then
|
|
|
|
sed -i 's|"pep"|"profile"|g' /etc/prosody/prosody.cfg.lua
|
|
|
|
sed -i '/"vcard"/d' /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
|
|
|
fi
|
2016-07-06 16:40:09 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 20:18:44 +01:00
|
|
|
function upgrade_xmpp_server {
|
2016-08-28 10:55:47 +02:00
|
|
|
function_check update_prosody_modules
|
|
|
|
update_prosody_modules
|
2016-12-07 10:16:38 +01:00
|
|
|
|
2017-03-11 17:14:24 +01:00
|
|
|
curr_prosody_filename=$(cat $COMPLETION_FILE | grep "prosody_filename" | awk -F ':' '{print $2}')
|
|
|
|
if [[ "$curr_prosody_filename" != "$prosody_filename" ]]; then
|
|
|
|
if [ -d ${INSTALL_DIR}/${prosody_filename} ]; then
|
|
|
|
# ensure that the binaries have not been overwritten
|
|
|
|
# by an operating system upgrade
|
|
|
|
cd ${INSTALL_DIR}/${prosody_filename}
|
|
|
|
make prefix=/usr install
|
2017-01-16 16:38:08 +01:00
|
|
|
else
|
2017-03-11 17:14:24 +01:00
|
|
|
cd $INSTALL_DIR
|
|
|
|
# Try to get the source from the project repo
|
|
|
|
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
|
2017-03-11 17:14:24 +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 .
|
|
|
|
else
|
|
|
|
wget $prosody_nightly_url
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ ! -f ${INSTALL_DIR}/${prosody_filename}.tar.gz ]; then
|
|
|
|
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
|
|
|
|
2017-03-11 17:14:24 +01:00
|
|
|
hash_value=$(sha256sum ${INSTALL_DIR}/${prosody_filename}.tar.gz | awk -F ' ' '{print $1}')
|
|
|
|
if [[ "$hash_value" != "$prosody_nightly_hash" ]]; then
|
|
|
|
rm ${INSTALL_DIR}/${prosody_filename}.tar.gz
|
|
|
|
echo $'Unexpected hash value for prosody nightly download'
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
tar -xzvf ${INSTALL_DIR}/${prosody_filename}.tar.gz
|
|
|
|
cd ${INSTALL_DIR}/${prosody_filename}
|
|
|
|
./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'
|
|
|
|
rm ${INSTALL_DIR}/${prosody_filename}.tar.gz
|
|
|
|
rm -rf ${INSTALL_DIR}/${prosody_filename}
|
|
|
|
return
|
|
|
|
fi
|
2016-12-07 13:14:33 +01:00
|
|
|
rm ${INSTALL_DIR}/${prosody_filename}.tar.gz
|
|
|
|
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
|
|
|
|
|
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-12-19 20:18:44 +01:00
|
|
|
function upgrade_xmpp_client {
|
2016-12-19 16:40:35 +01:00
|
|
|
# update profanity client
|
2016-12-19 16:42:38 +01:00
|
|
|
if [ -f /usr/bin/profanity ]; then
|
|
|
|
apt-get -y remove --purge profanity
|
|
|
|
fi
|
|
|
|
|
2017-01-03 15:24:31 +01:00
|
|
|
rm -rf /tmp/*
|
|
|
|
|
2017-03-11 17:14:24 +01:00
|
|
|
CURR_LIBMESODE_COMMIT=$(cat $COMPLETION_FILE | grep "libmesode commit" | awk -F ':' '{print $2}')
|
|
|
|
if [[ "$CURR_LIBMESODE_COMMIT" != "$LIBMESODE_COMMIT" ]]; then
|
|
|
|
function_check set_repo_commit
|
|
|
|
set_repo_commit $INSTALL_DIR/libmesode "libmesode commit" "$LIBMESODE_COMMIT" $LIBMESODE_REPO
|
|
|
|
cd $INSTALL_DIR/libmesode
|
|
|
|
./bootstrap.sh
|
|
|
|
./configure
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cp /usr/local/lib/libmesode* /usr/lib
|
|
|
|
fi
|
2016-12-19 16:40:35 +01:00
|
|
|
|
2017-01-03 15:24:31 +01:00
|
|
|
rm -rf /tmp/*
|
|
|
|
|
2017-03-11 17:14:24 +01:00
|
|
|
CURR_PROFANITY_COMMIT=$(cat $COMPLETION_FILE | grep "profanity commit" | awk -F ':' '{print $2}')
|
|
|
|
if [[ "$CURR_PROFANITY_COMMIT" != "$PROFANITY_COMMIT" ]]; then
|
|
|
|
function_check set_repo_commit
|
|
|
|
set_repo_commit $INSTALL_DIR/profanity "profanity commit" "$PROFANITY_COMMIT" $PROFANITY_REPO
|
|
|
|
cd $INSTALL_DIR/profanity
|
|
|
|
./bootstrap.sh
|
|
|
|
./configure --disable-notifications --disable-icons --enable-otr --enable-pgp --enable-plugins --enable-c-plugins --enable-python-plugins --without-xscreensaver
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
fi
|
|
|
|
|
|
|
|
CURR_PROFANITY_OMEMO_PLUGIN_COMMIT=$(cat $COMPLETION_FILE | grep "profanity omemo plugin commit" | awk -F ':' '{print $2}')
|
|
|
|
if [[ "$CURR_PROFANITY_OMEMO_PLUGIN_COMMIT" != "$PROFANITY_OMEMO_PLUGIN_COMMIT" ]]; then
|
|
|
|
# upgrade omemo plugins for all users
|
|
|
|
set_repo_commit $INSTALL_DIR/profanity-omemo-plugin "profanity omemo plugin commit" "$PROFANITY_OMEMO_PLUGIN_COMMIT" $PROFANITY_OMEMO_PLUGIN_REPO
|
|
|
|
cd $INSTALL_DIR/profanity-omemo-plugin
|
|
|
|
sed -i 's|python setup.py|python2.7 setup.py|g' $INSTALL_DIR/profanity-omemo-plugin/install.sh
|
|
|
|
pip uninstall -y profanity-omemo-plugin
|
|
|
|
./install.sh
|
|
|
|
for d in /home/*/ ; do
|
|
|
|
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
|
|
|
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
|
|
|
|
if [ ! -d /home/$USERNAME/.local/share/profanity/plugins ]; then
|
|
|
|
mkdir -p /home/$USERNAME/.local/share/profanity/plugins
|
|
|
|
fi
|
|
|
|
if [ -f $INSTALL_DIR/profanity-omemo-plugin/omemo.py ]; then
|
|
|
|
rm $INSTALL_DIR/profanity-omemo-plugin/omemo.*
|
|
|
|
fi
|
|
|
|
cp $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py /home/$USERNAME/.local/share/profanity/plugins
|
|
|
|
chown -R $USERNAME:$USERNAME /home/$USERNAME/.local
|
2017-02-09 22:41:38 +01:00
|
|
|
fi
|
2017-03-11 17:14:24 +01:00
|
|
|
done
|
|
|
|
if [ -f /etc/skel/.local/share/profanity/plugins/omemo.py ]; then
|
|
|
|
rm /etc/skel/.local/share/profanity/plugins/omemo.*
|
2016-12-19 16:40:35 +01:00
|
|
|
fi
|
2017-03-11 17:14:24 +01:00
|
|
|
cp $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py /etc/skel/.local/share/profanity/plugins
|
2017-02-09 22:41:38 +01:00
|
|
|
fi
|
2017-03-18 12:30:08 +01:00
|
|
|
|
|
|
|
chmod -R 700 /root/.local/lib/python3.4/site-packages/python_axolotl_*
|
2016-07-06 16:01:28 +02:00
|
|
|
}
|
|
|
|
|
2016-12-19 20:18:44 +01:00
|
|
|
function upgrade_xmpp {
|
|
|
|
upgrade_xmpp_server
|
|
|
|
upgrade_xmpp_client
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
|
|
|
|
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
|
|
|
|
service prosody restart
|
|
|
|
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
|
|
|
|
cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
exit 725
|
|
|
|
fi
|
|
|
|
rm -rf $temp_restore_dir
|
|
|
|
service prosody restart
|
|
|
|
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
|
2016-10-16 20:50:56 +02:00
|
|
|
if [[ $(is_completed $FUNCNAME) == "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
|
2016-10-16 20:50:56 +02:00
|
|
|
mark_completed $FUNCNAME
|
2016-07-03 17:13:34 +02:00
|
|
|
}
|
|
|
|
|
2016-07-04 20:36:56 +02:00
|
|
|
function remove_xmpp_client {
|
2016-10-23 20:38:14 +02:00
|
|
|
apt-get -yq remove --purge profanity
|
2016-10-17 15:44:49 +02:00
|
|
|
remove_completion_param install_xmpp_client
|
2016-10-20 23:02:16 +02:00
|
|
|
remove_certs xmpp
|
2016-07-04 20:36:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function remove_xmpp {
|
2016-08-28 10:55:47 +02:00
|
|
|
remove_xmpp_client
|
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
|
|
|
|
|
2016-12-03 18:25:18 +01:00
|
|
|
apt-get -yq remove --purge prosody
|
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
|
2016-10-28 10:39:26 +02:00
|
|
|
sed -i '/xmpp/d' $COMPLETION_FILE
|
2017-03-11 17:14:24 +01:00
|
|
|
sed -i '/prosody/d' $COMPLETION_FILE
|
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
|
2016-08-28 10:55:47 +02: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
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2016-07-04 20:36:56 +02:00
|
|
|
}
|
|
|
|
|
2016-12-03 12:18:19 +01:00
|
|
|
function xmpp_modules {
|
|
|
|
filename=$1
|
|
|
|
echo 'modules_enabled = {' >> $filename
|
2016-12-03 13:55:08 +01:00
|
|
|
echo ' "pubsub";' >> $filename
|
2016-12-03 12:18:19 +01:00
|
|
|
echo ' "dialback"; -- s2s dialback support' >> $filename
|
|
|
|
echo ' "disco"; -- Service discovery' >> $filename
|
|
|
|
echo ' "private"; -- Private XML storage (for room bookmarks, etc.)' >> $filename
|
|
|
|
echo ' "version"; -- Replies to server version requests' >> $filename
|
|
|
|
echo ' "uptime"; -- Report how long server has been running' >> $filename
|
|
|
|
echo ' "time"; -- Let others know the time here on this server' >> $filename
|
|
|
|
echo ' "ping"; -- Replies to XMPP pings with pongs' >> $filename
|
|
|
|
echo ' "admin_adhoc"; -- Allows administration via an XMPP client that supports ad-hoc commands' >> $filename
|
|
|
|
echo ' "posix"; -- POSIX functionality, sends server to background, enables syslog, etc.' >> $filename
|
|
|
|
echo ' "bosh"; -- Enable mod_bosh' >> $filename
|
|
|
|
echo ' "tls"; -- Enable mod_tls' >> $filename
|
|
|
|
echo ' "saslauth"; -- Enable mod_saslauth' >> $filename
|
|
|
|
echo ' "onions"; -- Enable chat via onion service' >> $filename
|
|
|
|
echo ' "mam"; -- Message archive management' >> $filename
|
|
|
|
echo ' "csi"; -- Client state indication' >> $filename
|
|
|
|
echo ' "carbons"; -- Message carbons' >> $filename
|
2016-12-03 18:13:43 +01:00
|
|
|
echo ' "carbons_adhoc"; -- Message carbons' >> $filename
|
|
|
|
echo ' "carbons_copies"; -- Message carbons' >> $filename
|
2016-12-03 12:18:19 +01:00
|
|
|
echo ' "smacks"; -- Stream management' >> $filename
|
|
|
|
echo ' "smacks_offline"; -- Stream management' >> $filename
|
2017-01-07 12:56:07 +01:00
|
|
|
echo ' "profile"; -- Personal Eventing Protocol (to support OMEMO)' >> $filename
|
|
|
|
echo ' "e2e_policy"; -- To support OMEMO' >> $filename
|
2016-12-03 18:13:43 +01:00
|
|
|
echo ' "pep_vcard_avatar"; -- Personal Eventing Protocol (to support OMEMO)' >> $filename
|
2016-12-06 16:43:35 +01:00
|
|
|
echo ' "blocklist"; -- Privacy lists' >> $filename
|
2016-12-03 12:18:19 +01:00
|
|
|
echo ' "privacy_lists"; -- Privacy lists' >> $filename
|
|
|
|
echo ' "blocking"; -- Blocking command' >> $filename
|
|
|
|
echo ' "roster"; -- Roster versioning' >> $filename
|
|
|
|
echo ' "offline_email"; -- If offline send to email' >> $filename
|
|
|
|
echo ' "offline"; -- Store offline messages' >> $filename
|
2016-12-03 18:13:43 +01:00
|
|
|
echo ' "http";' >> $filename
|
|
|
|
echo ' "http_upload";' >> $filename
|
|
|
|
echo ' "websocket";' >> $filename
|
2016-12-03 12:18:19 +01:00
|
|
|
echo '};' >> $filename
|
|
|
|
}
|
|
|
|
|
2017-01-29 14:37:13 +01:00
|
|
|
function xmpp_onion_addresses {
|
|
|
|
filename=$1
|
|
|
|
echo 'onions_map = {' >> $filename
|
|
|
|
echo ' ["anonymitaet-im-inter.net"] = "rwf5skuv5vqzcdit.onion";' >> $filename
|
|
|
|
echo ' ["autistici.org"] = "wi7qkxyrdpu5cmvr.onion";' >> $filename
|
|
|
|
echo ' ["jabber.calyxinstitute.org"] = "ijeeynrc6x2uy5ob.onion";' >> $filename
|
|
|
|
echo ' ["jabber.ccc.de"] = "okj7xc6j2szr2y75.onion";' >> $filename
|
|
|
|
echo ' ["cloak.dk"] = "m2dsl4banuimpm6c.onion";' >> $filename
|
|
|
|
echo ' ["jabber.cryptoparty.is"] = "cryjabkbdljzohnp.onion";' >> $filename
|
|
|
|
echo ' ["daemons.cf"] = "daemon4jidu2oig6.onion";' >> $filename
|
|
|
|
echo ' ["dukgo.com"] = "wlcpmruglhxp6quz.onion";' >> $filename
|
|
|
|
echo ' ["evil.im"] = "evilxro6nvjuvxqo.onion";' >> $filename
|
|
|
|
echo ' ["xmpp.evil.im"] = "evilxro6nvjuvxqo.onion";' >> $filename
|
|
|
|
echo ' ["inventati.org"] = "wi7qkxyrdpu5cmvr.onion";' >> $filename
|
|
|
|
echo ' ["jabber.ipredator.se"] = "3iffdebkzzkpgipa.onion";' >> $filename
|
|
|
|
echo ' ["jabber-germany.de"] = "dbbrphko5tqcpar3.onion";' >> $filename
|
|
|
|
echo ' ["kode.im"] = "ihkw7qy3tok45dun.onion";' >> $filename
|
|
|
|
echo ' ["im.koderoot.net"] = "ihkw7qy3tok45dun.onion";' >> $filename
|
2017-01-31 21:42:48 +01:00
|
|
|
echo ' ["adb-centralen.se"] = "37x6i3wgr2jyublb.onion";' >> $filename
|
|
|
|
echo ' ["joelpurra.se"] = "37x6i3wgr2jyublb.onion";' >> $filename
|
|
|
|
echo ' ["nordberg.se"] = "37x6i3wgr2jyublb.onion";' >> $filename
|
2017-01-29 14:37:13 +01:00
|
|
|
echo ' ["jabber.lqdn.fr"] = "jabber63t4r2qi57.onion";' >> $filename
|
|
|
|
echo ' ["jabber.otr.im"] = "5rgdtlawqkcplz75.onion";' >> $filename
|
|
|
|
echo ' ["otromundo.cf"] = "arauemwe2utqqzye.onion";' >> $filename
|
|
|
|
echo ' ["patchcord.be"] = "xsydhi3dnbjuatpz.onion";' >> $filename
|
|
|
|
echo ' ["riseup.net"] = "4cjw6cwpeaeppfqz.onion";' >> $filename
|
|
|
|
echo ' ["xmpp.riseup.net"] = "4cjw6cwpeaeppfqz.onion";' >> $filename
|
|
|
|
echo ' ["rows.io"] = "yz6yiv2hxyagvwy6.onion";' >> $filename
|
|
|
|
echo ' ["xmpp.rows.io"] = "yz6yiv2hxyagvwy6.onion";' >> $filename
|
|
|
|
echo ' ["securejabber.me"] = "giyvshdnojeivkom.onion";' >> $filename
|
|
|
|
echo ' ["so36.net"] = "s4fgy24e2b5weqdb.onion";' >> $filename
|
|
|
|
echo ' ["jabber.so36.net"] = "s4fgy24e2b5weqdb.onion";' >> $filename
|
|
|
|
echo ' ["jabber.systemli.org"] = "x5tno6mwkncu5m3h.onion";' >> $filename
|
|
|
|
echo ' ["taolo.ga"] = "l3ybpw4vs6ie5rv2.onion";' >> $filename
|
|
|
|
echo ' ["tchncs.de"] = "duvfmyqmdlyvc3mi.onion";' >> $filename
|
|
|
|
echo ' ["wtfismyip.com"] = "ofkztxcohimx34la.onion";' >> $filename
|
|
|
|
echo ' ["prosody.xmpp.is"] = "y2qmqomqpszzryei.onion";' >> $filename
|
|
|
|
echo ' ["xndr.de"] = "trcubpttd6zkc3tf.onion";' >> $filename
|
2017-01-29 19:35:08 +01:00
|
|
|
echo ' ["trashserver.net"] = "m4c722bvc2r7brnn.onion";' >> $filename
|
2017-01-29 14:37:13 +01:00
|
|
|
echo '};' >> $filename
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
echo 'allow_registration = false;' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 'daemonize = true;' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 'pidfile = "/var/run/prosody/prosody.pid";' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 18:13:43 +01:00
|
|
|
echo 'https_ports = { 5281 }' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 18:24:17 +01:00
|
|
|
echo 'https_interfaces = { "*" }' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 18:13:43 +01:00
|
|
|
echo 'https_ssl = {' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 19:40:48 +01:00
|
|
|
if [ -f /etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.pem ]; then
|
|
|
|
echo " certificate = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.pem\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
else
|
|
|
|
echo " certificate = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.crt\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
2016-12-03 18:13:43 +01:00
|
|
|
echo " key = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.key\";" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 19:35:30 +01:00
|
|
|
echo " curve = $XMPP_ECC_CURVE;" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo " ciphers = $XMPP_CIPHERS;" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' options = {"no_sslv2", "no_sslv3" };' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo " dhparam = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.dhparam\";" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 18:13:43 +01:00
|
|
|
echo "}" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
echo 'ssl = {' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo " key = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.key\";" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 19:40:48 +01:00
|
|
|
if [ -f /etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.pem ]; then
|
|
|
|
echo " certificate = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.pem\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
else
|
|
|
|
echo " certificate = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.crt\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
2016-12-03 12:21:33 +01:00
|
|
|
echo " curve = $XMPP_ECC_CURVE;" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
echo ' depth = "1";' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 12:21:33 +01:00
|
|
|
echo " ciphers = $XMPP_CIPHERS;" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
echo ' options = {"no_sslv2", "no_sslv3" };' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo " dhparam = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.dhparam\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '}' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 'c2s_require_encryption = true' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 's2s_require_encryption = true' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 's2s_secure_auth = false' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 'authentication = "internal_hashed"' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 19:45:39 +01:00
|
|
|
echo 'storage = "sql"' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 'sql = { driver = "SQLite3", database = "prosody.sqlite" }' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
echo 'log = {' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' info = "/dev/null";' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' error = "/dev/null";' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' { levels = { "error" }; to = "/dev/null"; };' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '}' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 12:26:56 +01:00
|
|
|
echo "VirtualHost \"${DEFAULT_DOMAIN_NAME}\"" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
echo ' ssl = {' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo " key = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.key\";" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 19:40:48 +01:00
|
|
|
if [ -f /etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.pem ]; then
|
|
|
|
echo " certificate = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.pem\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
else
|
|
|
|
echo " certificate = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.crt\";" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
|
|
|
echo " curve = $XMPP_ECC_CURVE;" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' depth = "1";' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo " ciphers = $XMPP_CIPHERS;" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' options = {"no_sslv2", "no_sslv3" };' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo " dhparam = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.dhparam\";" >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 12:18:19 +01:00
|
|
|
echo ' }' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 'Include "conf.d/*.cfg.lua"' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 18:13:43 +01:00
|
|
|
echo 'http_upload_path = "/var/lib/prosody/http_uploads"' >> /etc/prosody/prosody.cfg.lua
|
2016-12-06 17:22:01 +01:00
|
|
|
echo 'http_upload_file_size_limit = 307200' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 20:13:35 +01:00
|
|
|
echo '' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo "Component \"chat.${DEFAULT_DOMAIN_NAME}\" \"muc\"" >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' name = "Chatrooms"' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' modules_enabled = {' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' "muc_limits";' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' "muc_log";' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' "mam_muc";' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' "muc_log_http";' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo ' }' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 'storage = { muc_log = "sql"; }' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 'sql = { driver = "SQLite3", database = "prosody.sqlite" }' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 'muc_event_rate = 0.5;' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 'muc_burst_factor = 10;' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 'muc_log_by_default = false;' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
echo 'muc_log_all_rooms = false;' >> /etc/prosody/prosody.cfg.lua
|
2016-12-03 20:43:52 +01:00
|
|
|
echo 'max_archive_query_results = 10;' >> /etc/prosody/prosody.cfg.lua
|
|
|
|
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 {
|
|
|
|
if [ ! -d $INSTALL_DIR ]; then
|
|
|
|
mkdir -p $INSTALL_DIR
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $INSTALL_DIR
|
2017-01-16 16:38:08 +01:00
|
|
|
|
|
|
|
# Try to get the source from the project repo
|
|
|
|
if [ -f /root/${PROJECT_NAME}/image_build/${prosody_filename}.tar.gz ]; then
|
|
|
|
cp /root/${PROJECT_NAME}/image_build/${prosody_filename}.tar.gz .
|
|
|
|
else
|
|
|
|
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 .
|
|
|
|
else
|
|
|
|
wget $prosody_nightly_url
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2016-12-07 13:14:33 +01:00
|
|
|
if [ ! -f ${INSTALL_DIR}/${prosody_filename}.tar.gz ]; then
|
|
|
|
echo $"Failed to download prosody nightly $prosody_nightly_url"
|
2016-12-03 23:20:28 +01:00
|
|
|
exit 78352
|
|
|
|
fi
|
|
|
|
|
2016-12-07 13:14:33 +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
|
2016-12-07 13:14:33 +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
|
|
|
|
|
2016-12-03 23:29:16 +01:00
|
|
|
tar -xzvf ${INSTALL_DIR}/${prosody_filename}.tar.gz
|
|
|
|
cd ${INSTALL_DIR}/${prosody_filename}
|
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'
|
2016-12-03 23:29:16 +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
|
2016-12-03 23:29:16 +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
|
|
|
}
|
|
|
|
|
2016-07-05 22:50:11 +02:00
|
|
|
function install_xmpp_main {
|
2016-08-28 10:55:47 +02:00
|
|
|
update_prosody_modules
|
|
|
|
|
2016-10-01 20:52:39 +02:00
|
|
|
if [[ $(app_is_installed xmpp_main) == "1" ]]; then
|
2016-08-28 10:55:47 +02:00
|
|
|
return
|
|
|
|
fi
|
2016-10-26 17:10:46 +02:00
|
|
|
|
2016-10-26 22:16:52 +02:00
|
|
|
if [[ $ONION_ONLY == 'no' ]]; then
|
|
|
|
# obtain a cert for the default domain
|
2016-10-30 20:59:40 +01:00
|
|
|
if [[ "$(cert_exists ${DEFAULT_DOMAIN_NAME} pem)" == "0" ]]; then
|
2016-10-26 22:16:52 +02:00
|
|
|
echo $'Obtaining certificate for the main domain'
|
|
|
|
create_site_certificate ${DEFAULT_DOMAIN_NAME} 'yes'
|
|
|
|
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
|
|
|
|
mkdir /etc/prosody/conf.d
|
|
|
|
fi
|
2016-12-03 12:40:11 +01:00
|
|
|
|
2016-08-28 10:55:47 +02:00
|
|
|
# obtain the prosody modules
|
2016-12-03 18:13:43 +01:00
|
|
|
if [ ! -d /var/lib/prosody/prosody-modules ]; then
|
|
|
|
hg clone https://hg.prosody.im/prosody-modules/ /var/lib/prosody/prosody-modules
|
|
|
|
fi
|
|
|
|
if [ ! -d /var/lib/prosody/prosody-modules/mod_onions ]; then
|
2016-08-28 10:55:47 +02:00
|
|
|
echo $'mod_onions prosody module could not be found'
|
|
|
|
exit 73254
|
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
|
2016-08-28 10:55:47 +02:00
|
|
|
# install the onions module
|
|
|
|
update_prosody_modules
|
|
|
|
|
|
|
|
# create a certificate
|
2016-10-30 20:59:40 +01:00
|
|
|
if [[ "$(cert_exists ${DEFAULT_DOMAIN_NAME} pem)" == "0" ]]; then
|
|
|
|
if [[ "$(cert_exists xmpp)" == "0" ]]; then
|
2016-10-26 18:08:45 +02:00
|
|
|
${PROJECT_NAME}-addcert -h xmpp --dhkey ${DH_KEYLENGTH}
|
2016-10-26 13:51:37 +02:00
|
|
|
check_certificates xmpp
|
|
|
|
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.*
|
|
|
|
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
|
2016-11-22 12:02:50 +01:00
|
|
|
if [ ! -d /etc/prosody/certs ]; then
|
|
|
|
mkdir /etc/prosody/certs
|
|
|
|
fi
|
2016-08-28 10:55:47 +02:00
|
|
|
|
2016-10-30 20:59:40 +01:00
|
|
|
if [[ "$(cert_exists ${DEFAULT_DOMAIN_NAME} pem)" == "1" ]]; then
|
2016-10-27 23:51:21 +02:00
|
|
|
sed -i "s|/etc/prosody/certs/example.com.key|/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.key|g" /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
sed -i "s|/etc/prosody/certs/example.com.crt|/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.pem|g" /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-10-26 13:51:37 +02:00
|
|
|
else
|
2016-10-27 23:51:21 +02:00
|
|
|
sed -i 's|/etc/prosody/certs/example.com.key|/etc/prosody/certs/xmpp.key|g' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
sed -i 's|/etc/prosody/certs/example.com.crt|/etc/prosody/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
|
2016-10-30 20:59:40 +01:00
|
|
|
if [[ "$(cert_exists ${DEFAULT_DOMAIN_NAME})" == "1" ]]; then
|
2016-10-27 23:51:21 +02:00
|
|
|
sed -i "/certificate =/a\ dhparam = \"/etc/prosody/certs/${DEFAULT_DOMAIN_NAME}.dhparam\";" /etc/prosody/conf.avail/xmpp.cfg.lua
|
2016-10-26 13:51:37 +02:00
|
|
|
else
|
2016-10-27 23:51:21 +02:00
|
|
|
sed -i '/certificate =/a\ dhparam = "/etc/prosody/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
|
|
|
|
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
|
|
|
|
fi
|
|
|
|
if ! grep -q 'ciphers =' /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
|
|
|
sed -i "/certificate =/a\ ciphers = $XMPP_CIPHERS;" /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
fi
|
|
|
|
if ! grep -q 'depth = "1";' /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
|
|
|
sed -i '/certificate =/a\ depth = "1";' /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
fi
|
|
|
|
if ! grep -q 'curve =' /etc/prosody/conf.avail/xmpp.cfg.lua; then
|
|
|
|
sed -i "/certificate =/a\ curve = $XMPP_ECC_CURVE;" /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
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
|
|
|
|
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
|
|
|
|
if ! grep -q "hidden_service_xmpp" /etc/tor/torrc; then
|
|
|
|
echo 'HiddenServiceDir /var/lib/tor/hidden_service_xmpp/' >> /etc/tor/torrc
|
|
|
|
echo "HiddenServicePort 5222 127.0.0.1:5222" >> /etc/tor/torrc
|
|
|
|
echo "HiddenServicePort 5269 127.0.0.1:5269" >> /etc/tor/torrc
|
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
|
|
|
|
echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
echo "VirtualHost \"${XMPP_ONION_HOSTNAME}\"" >> /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
echo ' modules_enabled = { "onions" };' >> /etc/prosody/conf.avail/xmpp.cfg.lua
|
|
|
|
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
|
|
|
|
2016-11-19 20:17:33 +01:00
|
|
|
if [ -f $IMAGE_PASSWORD_FILE ]; then
|
|
|
|
XMPP_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
|
|
|
|
else
|
2016-08-28 10:55:47 +02:00
|
|
|
if [ ${#XMPP_PASSWORD} -lt 8 ]; then
|
2016-11-19 20:17:33 +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
|
|
|
cp /etc/ssl/certs/xmpp.* /etc/prosody/certs
|
|
|
|
cp /etc/ssl/private/xmpp.* /etc/prosody/certs
|
|
|
|
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
|
|
|
|
|
2016-11-22 12:02:50 +01:00
|
|
|
systemctl restart prosody
|
|
|
|
|
2016-12-04 00:08:30 +01:00
|
|
|
cd
|
2017-03-24 20:57:14 +01:00
|
|
|
if [[ $ONION_ONLY != 'no' ]]; then
|
|
|
|
prosodyctl register $MY_USERNAME $XMPP_ONION_HOSTNAME "$XMPP_PASSWORD"
|
|
|
|
else
|
|
|
|
prosodyctl register $MY_USERNAME $DEFAULT_DOMAIN_NAME "$XMPP_PASSWORD"
|
|
|
|
fi
|
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 ''
|
|
|
|
remove_xmpp
|
2016-12-03 18:18:19 +01:00
|
|
|
echo $'Unable to register prosody user'
|
|
|
|
exit 347682
|
|
|
|
fi
|
|
|
|
|
|
|
|
${PROJECT_NAME}-pass -u $MY_USERNAME -a xmpp -p "$XMPP_PASSWORD"
|
|
|
|
|
2016-10-01 20:52:39 +02:00
|
|
|
install_completed xmpp_main
|
2016-07-03 17:13:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function install_xmpp_client {
|
2016-12-19 16:40:35 +01:00
|
|
|
# install profanity from source in order to get OMEMO support
|
2016-10-01 20:52:39 +02:00
|
|
|
if [[ $(app_is_installed xmpp_client) == "1" ]]; then
|
2016-08-28 10:55:47 +02:00
|
|
|
return
|
|
|
|
fi
|
2016-12-19 16:40:35 +01:00
|
|
|
if [ ! -d $INSTALL_DIR ]; then
|
|
|
|
mkdir -p $INSTALL_DIR
|
|
|
|
fi
|
|
|
|
|
|
|
|
apt-get -yq install automake autoconf autoconf-archive libtool build-essential
|
|
|
|
apt-get -yq install libncursesw5-dev libglib2.0-dev libcurl3-dev sqlite3
|
|
|
|
apt-get -yq install libotr5-dev libgpgme11-dev python-dev libreadline-dev
|
|
|
|
|
|
|
|
# dependency for profanity not available in debian
|
|
|
|
git_clone $LIBMESODE_REPO $INSTALL_DIR/libmesode
|
|
|
|
cd $INSTALL_DIR/libmesode
|
|
|
|
git checkout $LIBMESODE_COMMIT -b $LIBMESODE_COMMIT
|
|
|
|
./bootstrap.sh
|
|
|
|
./configure
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
cp /usr/local/lib/libmesode* /usr/lib
|
|
|
|
|
|
|
|
# build profanity
|
|
|
|
git_clone $PROFANITY_REPO $INSTALL_DIR/profanity
|
|
|
|
cd $INSTALL_DIR/profanity
|
|
|
|
git checkout $PROFANITY_COMMIT -b $PROFANITY_COMMIT
|
|
|
|
./bootstrap.sh
|
|
|
|
./configure --disable-notifications --disable-icons --enable-otr --enable-pgp --enable-plugins --enable-c-plugins --enable-python-plugins --without-xscreensaver
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
|
|
|
|
if [ ! -f /usr/local/bin/profanity ]; then
|
|
|
|
echo $'Unable to build profanity'
|
|
|
|
exit 7825272
|
|
|
|
fi
|
|
|
|
|
|
|
|
# install the omemo plugin
|
2017-02-11 00:16:33 +01:00
|
|
|
apt-get -yq install python-pip python-setuptools clang libffi-dev libssl-dev python-dev
|
2016-12-19 16:40:35 +01:00
|
|
|
git_clone $PROFANITY_OMEMO_PLUGIN_REPO $INSTALL_DIR/profanity-omemo-plugin
|
|
|
|
cd $INSTALL_DIR/profanity-omemo-plugin
|
|
|
|
git checkout $PROFANITY_OMEMO_PLUGIN_COMMIT -b $PROFANITY_OMEMO_PLUGIN_COMMIT
|
2017-02-09 22:41:38 +01:00
|
|
|
if [ ! -f $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py ]; then
|
|
|
|
echo $'prof_omemo_plugin.py not found'
|
2016-12-19 16:40:35 +01:00
|
|
|
exit 389225
|
|
|
|
fi
|
2017-02-09 22:41:38 +01:00
|
|
|
sed -i 's|python setup.py|python2.7 setup.py|g' $INSTALL_DIR/profanity-omemo-plugin/install.sh
|
|
|
|
./install.sh
|
2016-12-19 16:40:35 +01:00
|
|
|
|
|
|
|
mkdir -p /etc/skel/.local/share/profanity/plugins
|
2017-02-09 22:41:38 +01:00
|
|
|
cp $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py /etc/skel/.local/share/profanity/plugins
|
|
|
|
cp $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py /home/$MY_USERNAME/.local/share/profanity/plugins
|
2016-12-19 16:40:35 +01:00
|
|
|
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.local
|
2016-08-28 10:55:47 +02:00
|
|
|
|
|
|
|
XMPP_CLIENT_DIR=/home/$MY_USERNAME/.local/share/profanity
|
|
|
|
XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
|
|
|
|
if [ ! -d $XMPP_CLIENT_DIR ]; then
|
|
|
|
mkdir -p $XMPP_CLIENT_DIR
|
|
|
|
fi
|
|
|
|
|
2017-02-09 19:17:54 +01:00
|
|
|
XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
|
|
|
|
MY_GPG_PUBLIC_KEY_ID=$(su -c "gpg --list-keys $MY_USERNAME@$DEFAULT_DOMAIN_NAME | grep 'pub '" - $MY_USERNAME | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
|
|
|
|
2016-08-28 10:55:47 +02:00
|
|
|
if [[ $ONION_ONLY == 'no' ]]; then
|
|
|
|
echo "[${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}]" > $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo "jid=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
|
2017-02-09 19:17:54 +01:00
|
|
|
echo "server=$XMPP_ONION_HOSTNAME" >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo "pgp.keyid=$MY_GPG_PUBLIC_KEY_ID" >> $XMPP_CLIENT_ACCOUNTS
|
2016-08-28 10:55:47 +02:00
|
|
|
echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
|
2016-12-19 16:40:35 +01:00
|
|
|
echo "muc.service=chat.${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
|
2016-08-28 10:55:47 +02:00
|
|
|
echo "muc.nick=${MY_USERNAME}" >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.online=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.chat=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
if [ ${#XMPP_PASSWORD} -gt 2 ]; then
|
|
|
|
echo "password=$XMPP_PASSWORD" >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
|
|
|
|
echo "[${MY_USERNAME}@${XMPP_ONION_HOSTNAME}]" >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
if [[ $ONION_ONLY == 'no' ]]; then
|
|
|
|
echo 'enabled=false' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
else
|
|
|
|
echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
fi
|
|
|
|
echo "jid=${MY_USERNAME}@${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
|
2017-02-09 17:10:58 +01:00
|
|
|
echo "server=$XMPP_ONION_HOSTNAME" >> $XMPP_CLIENT_ACCOUNTS
|
2017-02-09 19:17:54 +01:00
|
|
|
echo "pgp.keyid=$MY_GPG_PUBLIC_KEY_ID" >> $XMPP_CLIENT_ACCOUNTS
|
2016-08-28 10:55:47 +02:00
|
|
|
echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
|
2016-12-19 16:40:35 +01:00
|
|
|
echo "muc.service=${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
|
2016-08-28 10:55:47 +02:00
|
|
|
echo "muc.nick=${MY_USERNAME}" >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.online=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.chat=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
if [ ${#XMPP_PASSWORD} -gt 2 ]; then
|
|
|
|
echo "password=$XMPP_PASSWORD" >> $XMPP_CLIENT_ACCOUNTS
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d /home/$MY_USERNAME/.config/profanity ]; then
|
2016-10-09 17:40:14 +02:00
|
|
|
mkdir -p /home/$MY_USERNAME/.config/profanity
|
2016-08-28 10:55:47 +02:00
|
|
|
fi
|
|
|
|
echo '[connection]' > /home/$MY_USERNAME/.config/profanity/profrc
|
2017-03-24 20:57:14 +01:00
|
|
|
if [[ $ONION_ONLY == 'no' ]]; then
|
|
|
|
echo "account=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}" >> /home/$MY_USERNAME/.config/profanity/profrc
|
|
|
|
else
|
|
|
|
echo "account=${MY_USERNAME}@${XMPP_ONION_HOSTNAME}" >> /home/$MY_USERNAME/.config/profanity/profrc
|
|
|
|
fi
|
2017-02-09 22:41:38 +01:00
|
|
|
echo '' >> /home/$MY_USERNAME/.config/profanity/profrc
|
|
|
|
echo '[plugins]' >> /home/$MY_USERNAME/.config/profanity/profrc
|
|
|
|
echo 'load=prof_omemo_plugin.py;' >> /home/$MY_USERNAME/.config/profanity/profrc
|
2017-02-11 00:16:33 +01:00
|
|
|
echo '' >> /home/$MY_USERNAME/.config/profanity/profrc
|
|
|
|
echo '[otr]' >> /home/$MY_USERNAME/.config/profanity/profrc
|
|
|
|
echo 'policy=opportunistic' >> /home/$MY_USERNAME/.config/profanity/profrc
|
2017-02-11 00:24:18 +01:00
|
|
|
echo 'log=off' >> /home/$MY_USERNAME/.config/profanity/profrc
|
2017-02-11 00:25:13 +01:00
|
|
|
echo '' >> /home/$MY_USERNAME/.config/profanity/profrc
|
|
|
|
echo '[pgp]' >> /home/$MY_USERNAME/.config/profanity/profrc
|
|
|
|
echo 'log=off' >> /home/$MY_USERNAME/.config/profanity/profrc
|
2017-02-11 00:26:22 +01:00
|
|
|
echo '' >> /home/$MY_USERNAME/.config/profanity/profrc
|
|
|
|
echo '[ui]' >> /home/$MY_USERNAME/.config/profanity/profrc
|
|
|
|
echo 'enc.warn=true' >> /home/$MY_USERNAME/.config/profanity/profrc
|
2016-08-28 10:55:47 +02:00
|
|
|
|
|
|
|
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.local
|
|
|
|
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
|
|
|
|
|
2017-03-18 12:30:08 +01:00
|
|
|
chmod -R 700 /root/.local/lib/python3.4/site-packages/python_axolotl_*
|
|
|
|
|
2016-10-01 20:52:39 +02:00
|
|
|
install_completed xmpp_client
|
2016-07-03 17:13:34 +02:00
|
|
|
}
|
|
|
|
|
2016-07-05 22:50:11 +02:00
|
|
|
function install_xmpp {
|
2016-08-28 10:55:47 +02:00
|
|
|
install_xmpp_main
|
|
|
|
install_xmpp_client
|
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
|