Separate the profanity client from the xmpp install

This commit is contained in:
Bob Mottram 2017-05-16 20:49:39 +01:00
parent d0bdcc54df
commit 0d42aedcdc
2 changed files with 388 additions and 282 deletions

324
src/freedombone-app-profanity Executable file
View File

@ -0,0 +1,324 @@
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Profanity XMPP client
#
# License
# =======
#
# Copyright (C) 2017 Bob Mottram <bob@freedombone.net>
#
# 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/>.
VARIANTS='full full-vim chat'
IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=1
LIBMESODE_REPO="https://github.com/boothj5/libmesode"
LIBMESODE_COMMIT='e3db0e9bfba61b2d82193874343a94a88f910800'
PROFANITY_REPO="https://github.com/boothj5/profanity"
PROFANITY_COMMIT='2fafaec8a7dc9bc01ee894d83214590598b32914'
PROFANITY_OMEMO_PLUGIN_REPO="https://github.com/ReneVolution/profanity-omemo-plugin"
PROFANITY_OMEMO_PLUGIN_COMMIT='3ec8ec173656bed9761b740b086123e07c749548'
xmpp_variables=(ONION_ONLY
INSTALLED_WITHIN_DOCKER
MY_USERNAME
DEFAULT_DOMAIN_NAME
XMPP_DOMAIN_CODE)
function remove_user_profanity {
remove_username="$1"
}
function add_user_profanity {
new_username="$1"
new_user_password="$2"
echo '0'
}
function run_client_profanity {
torify profanity
}
function install_interactive_profanity {
echo -n ''
APP_INSTALLED=1
}
function change_password_profanity {
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}
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
}
function reconfigure_profanity {
echo -n ''
}
function upgrade_profanity {
# update profanity client
if [ -f /usr/bin/profanity ]; then
apt-get -y remove --purge profanity
fi
rm -rf /tmp/*
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
rm -rf /tmp/*
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
fi
done
if [ -f /etc/skel/.local/share/profanity/plugins/omemo.py ]; then
rm /etc/skel/.local/share/profanity/plugins/omemo.*
fi
cp $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py /etc/skel/.local/share/profanity/plugins
fi
chmod -R 700 /root/.local/lib/python3.4/site-packages/python_axolotl_*
}
function backup_local_profanity {
echo -n ''
}
function restore_local_profanity {
echo -n ''
}
function backup_remote_profanity {
echo -n ''
}
function restore_remote_profanity {
echo -n ''
}
function remove_profanity {
cd $INSTALL_DIR/profanity
make uninstall
remove_completion_param install_profanity
sed -i '/profanity/d' $COMPLETION_FILE
}
function install_profanity {
# xmpp must already be installed
if [ ! -d /etc/prosody ]; then
return
fi
# install profanity from source in order to get OMEMO support
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
apt-get -yq install python-pip python-setuptools clang libffi-dev libssl-dev python-dev
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
if [ ! -f $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py ]; then
echo $'prof_omemo_plugin.py not found'
exit 389225
fi
sed -i 's|python setup.py|python2.7 setup.py|g' $INSTALL_DIR/profanity-omemo-plugin/install.sh
./install.sh
mkdir -p /etc/skel/.local/share/profanity/plugins
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
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.local
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
XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
MY_GPG_PUBLIC_KEY_ID=$(gpg_pubkey_from_email "$MY_USERNAME" "$MY_USERNAME@$DEFAULT_DOMAIN_NAME")
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
echo "server=$XMPP_ONION_HOSTNAME" >> $XMPP_CLIENT_ACCOUNTS
echo "pgp.keyid=$MY_GPG_PUBLIC_KEY_ID" >> $XMPP_CLIENT_ACCOUNTS
echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
echo "muc.service=chat.${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
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
echo "server=$XMPP_ONION_HOSTNAME" >> $XMPP_CLIENT_ACCOUNTS
echo "pgp.keyid=$MY_GPG_PUBLIC_KEY_ID" >> $XMPP_CLIENT_ACCOUNTS
echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
echo "muc.service=${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
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
mkdir -p /home/$MY_USERNAME/.config/profanity
fi
echo '[connection]' > /home/$MY_USERNAME/.config/profanity/profrc
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
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
echo '' >> /home/$MY_USERNAME/.config/profanity/profrc
echo '[otr]' >> /home/$MY_USERNAME/.config/profanity/profrc
echo 'policy=opportunistic' >> /home/$MY_USERNAME/.config/profanity/profrc
echo 'log=off' >> /home/$MY_USERNAME/.config/profanity/profrc
echo '' >> /home/$MY_USERNAME/.config/profanity/profrc
echo '[pgp]' >> /home/$MY_USERNAME/.config/profanity/profrc
echo 'log=off' >> /home/$MY_USERNAME/.config/profanity/profrc
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
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.local
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
chmod -R 700 /root/.local/lib/python3.4/site-packages/python_axolotl_*
APP_INSTALLED=1
}
# NOTE: deliberately no exit 0

View File

@ -183,23 +183,11 @@ function remove_user_xmpp {
fi
}
function add_user_xmpp {
function add_user_xmpp_client {
new_username="$1"
new_user_password="$2"
XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
${PROJECT_NAME}-pass -u $new_username -a xmpp -p "$new_user_password"
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
if [ ! "$?" = "0" ]; then
echo '1'
return
fi
if [ -f /usr/local/bin/profanity ]; then
XMPP_CLIENT_DIR=/home/$new_username/.local/share/profanity
XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
if [ ! -d $XMPP_CLIENT_DIR ]; then
@ -247,11 +235,28 @@ function add_user_xmpp {
chown -R $new_username:$new_username /home/$new_username/.local
chown -R $new_username:$new_username /home/$new_username/.config
echo '0'
fi
}
function run_client_xmpp {
torify profanity
function add_user_xmpp {
new_username="$1"
new_user_password="$2"
XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
${PROJECT_NAME}-pass -u $new_username -a xmpp -p "$new_user_password"
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
if [ ! "$?" = "0" ]; then
echo '1'
return
fi
add_user_xmpp_client "$new_username" "$new_user_password"
echo '0'
}
function install_interactive_xmpp {
@ -274,11 +279,13 @@ function change_password_xmpp {
echo $'Currently Prosody requires password changes to be done interactively'
prosodyctl passwd ${curr_username}@${DEFAULT_DOMAIN_NAME}
if [ -f /usr/local/bin/profanity ]; then
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
fi
}
function reconfigure_xmpp {
@ -344,7 +351,7 @@ function update_prosody_modules {
fi
}
function upgrade_xmpp_server {
function upgrade_xmpp {
if [ -d /etc/letsencrypt ]; then
usermod -a -G ssl-cert prosody
fi
@ -408,74 +415,6 @@ function upgrade_xmpp_server {
systemctl restart prosody
}
function upgrade_xmpp_client {
# update profanity client
if [ -f /usr/bin/profanity ]; then
apt-get -y remove --purge profanity
fi
rm -rf /tmp/*
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
rm -rf /tmp/*
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
fi
done
if [ -f /etc/skel/.local/share/profanity/plugins/omemo.py ]; then
rm /etc/skel/.local/share/profanity/plugins/omemo.*
fi
cp $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py /etc/skel/.local/share/profanity/plugins
fi
chmod -R 700 /root/.local/lib/python3.4/site-packages/python_axolotl_*
}
function upgrade_xmpp {
upgrade_xmpp_server
upgrade_xmpp_client
}
function backup_local_xmpp {
source_directory=/var/lib/prosody
if [ -d $source_directory ]; then
@ -553,14 +492,7 @@ function configure_firewall_for_xmpp {
mark_completed $FUNCNAME
}
function remove_xmpp_client {
apt-get -yq remove --purge profanity
remove_completion_param install_xmpp_client
remove_certs xmpp
}
function remove_xmpp {
remove_xmpp_client
firewall_remove 5222 tcp
firewall_remove 5223 tcp
firewall_remove 5269 tcp
@ -834,13 +766,9 @@ function install_xmpp_nightly {
set_completion_param "prosody_filename" "${prosody_filename}"
}
function install_xmpp_main {
function install_xmpp {
update_prosody_modules
if [[ $(app_is_installed xmpp_main) == "1" ]]; then
return
fi
if [[ $ONION_ONLY == 'no' ]]; then
# obtain a cert for the default domain
if [[ "$(cert_exists ${DEFAULT_DOMAIN_NAME} pem)" == "0" ]]; then
@ -1053,152 +981,6 @@ function install_xmpp_main {
${PROJECT_NAME}-pass -u $MY_USERNAME -a xmpp -p "$XMPP_PASSWORD"
install_completed xmpp_main
}
function install_xmpp_client {
# install profanity from source in order to get OMEMO support
if [[ $(app_is_installed xmpp_client) == "1" ]]; then
return
fi
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
apt-get -yq install python-pip python-setuptools clang libffi-dev libssl-dev python-dev
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
if [ ! -f $INSTALL_DIR/profanity-omemo-plugin/deploy/prof_omemo_plugin.py ]; then
echo $'prof_omemo_plugin.py not found'
exit 389225
fi
sed -i 's|python setup.py|python2.7 setup.py|g' $INSTALL_DIR/profanity-omemo-plugin/install.sh
./install.sh
mkdir -p /etc/skel/.local/share/profanity/plugins
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
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.local
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
XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
MY_GPG_PUBLIC_KEY_ID=$(gpg_pubkey_from_email "$MY_USERNAME" "$MY_USERNAME@$DEFAULT_DOMAIN_NAME")
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
echo "server=$XMPP_ONION_HOSTNAME" >> $XMPP_CLIENT_ACCOUNTS
echo "pgp.keyid=$MY_GPG_PUBLIC_KEY_ID" >> $XMPP_CLIENT_ACCOUNTS
echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
echo "muc.service=chat.${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
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
echo "server=$XMPP_ONION_HOSTNAME" >> $XMPP_CLIENT_ACCOUNTS
echo "pgp.keyid=$MY_GPG_PUBLIC_KEY_ID" >> $XMPP_CLIENT_ACCOUNTS
echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
echo "muc.service=${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
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
mkdir -p /home/$MY_USERNAME/.config/profanity
fi
echo '[connection]' > /home/$MY_USERNAME/.config/profanity/profrc
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
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
echo '' >> /home/$MY_USERNAME/.config/profanity/profrc
echo '[otr]' >> /home/$MY_USERNAME/.config/profanity/profrc
echo 'policy=opportunistic' >> /home/$MY_USERNAME/.config/profanity/profrc
echo 'log=off' >> /home/$MY_USERNAME/.config/profanity/profrc
echo '' >> /home/$MY_USERNAME/.config/profanity/profrc
echo '[pgp]' >> /home/$MY_USERNAME/.config/profanity/profrc
echo 'log=off' >> /home/$MY_USERNAME/.config/profanity/profrc
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
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.local
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
chmod -R 700 /root/.local/lib/python3.4/site-packages/python_axolotl_*
install_completed xmpp_client
}
function install_xmpp {
install_xmpp_main
install_xmpp_client
APP_INSTALLED=1
}