2016-07-03 17:13:34 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# .---. . .
|
|
|
|
# | | |
|
|
|
|
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
|
|
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
|
|
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
|
|
#
|
|
|
|
# Freedom in the Cloud
|
|
|
|
#
|
|
|
|
# Tox Application
|
|
|
|
#
|
|
|
|
# License
|
|
|
|
# =======
|
|
|
|
#
|
|
|
|
# Copyright (C) 2014-2016 Bob Mottram <bob@robotics.uk.to>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-07-06 17:47:55 +02:00
|
|
|
VARIANTS='full chat'
|
|
|
|
|
2016-07-03 17:13:34 +02:00
|
|
|
TOX_PORT=33445
|
|
|
|
TOXCORE_REPO="git://github.com/irungentoo/toxcore.git"
|
|
|
|
TOXCORE_COMMIT='532629d486e3361c7d8d95b38293cc7d61dc4ee5'
|
|
|
|
TOXID_REPO="https://github.com/bashrc/toxid"
|
|
|
|
TOX_BOOTSTRAP_ID_FILE=/var/lib/tox-bootstrapd/pubkey.txt
|
|
|
|
# These are some default nodes, but you can replace them with trusted nodes
|
|
|
|
# as you prefer. See https://wiki.tox.im/Nodes
|
|
|
|
TOX_NODES=
|
|
|
|
#TOX_NODES=(
|
|
|
|
# '192.254.75.102,2607:5600:284::2,33445,951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F,Tox RELENG,US'
|
|
|
|
# '144.76.60.215,2a01:4f8:191:64d6::1,33445,04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F,sonOfRa,DE'
|
|
|
|
#)
|
|
|
|
TOXIC_REPO="https://github.com/Tox/toxic"
|
|
|
|
TOXIC_COMMIT='cf16849b374e484a33a4dffa3dfb937b59d537f2'
|
|
|
|
TOXIC_FILE=/usr/local/bin/toxic
|
|
|
|
|
2016-07-09 12:36:12 +02:00
|
|
|
function reconfigure_tox {
|
2016-07-09 22:52:17 +02:00
|
|
|
echo -n ''
|
2016-07-09 12:36:12 +02:00
|
|
|
}
|
|
|
|
|
2016-07-06 16:01:28 +02:00
|
|
|
function upgrade_tox {
|
2016-07-06 16:40:09 +02:00
|
|
|
if ! grep -Fxq "install_tox" $COMPLETION_FILE; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
function_check set_repo_commit
|
|
|
|
set_repo_commit $INSTALL_DIR/toxcore "toxcore commit" "$TOXCORE_COMMIT" $TOXCORE_REPO
|
|
|
|
|
|
|
|
function_check set_repo_commit
|
|
|
|
set_repo_commit $INSTALL_DIR/toxic "Toxic commit" "$TOXIC_COMMIT" $TOXIC_REPO
|
2016-07-06 16:01:28 +02:00
|
|
|
}
|
|
|
|
|
2016-07-06 15:55:09 +02:00
|
|
|
function backup_local_tox {
|
2016-07-07 21:42:25 +02:00
|
|
|
if [ -d /var/lib/tox-bootstrapd ]; then
|
|
|
|
echo $"Backing up Tox"
|
|
|
|
|
|
|
|
if [ -d /var/lib/tox-bootstrapd ]; then
|
|
|
|
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
|
|
|
|
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
|
|
|
|
rm -rf /var/lib/tox-bootstrapd/Maildir
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
function_check backup_directory_to_usb
|
|
|
|
backup_directory_to_usb /var/lib/tox-bootstrapd tox
|
|
|
|
|
|
|
|
echo $"Backup of Tox complete"
|
|
|
|
fi
|
2016-07-06 15:55:09 +02:00
|
|
|
}
|
|
|
|
|
2016-07-08 17:18:23 +02:00
|
|
|
function restore_local_tox {
|
|
|
|
if [ -d $USB_MOUNT/backup/tox ]; then
|
|
|
|
echo $"Restoring Tox node settings"
|
|
|
|
function_check restore_directory_from_usb
|
|
|
|
restore_directory_from_usb / tox
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
function_check set_user_permissions
|
|
|
|
set_user_permissions
|
|
|
|
function_check backup_unmount_drive
|
|
|
|
backup_unmount_drive
|
|
|
|
exit 6393
|
|
|
|
fi
|
|
|
|
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
|
|
|
systemctl restart tox-bootstrapd.service
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
systemctl status tox-bootstrapd.service
|
|
|
|
function_check set_user_permissions
|
|
|
|
set_user_permissions
|
|
|
|
function_check backup_unmount_drive
|
|
|
|
backup_unmount_drive
|
|
|
|
exit 59369
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-07-06 15:55:09 +02:00
|
|
|
function backup_remote_tox {
|
2016-07-09 22:52:17 +02:00
|
|
|
if [ -d /var/lib/tox-bootstrapd ]; then
|
|
|
|
echo "Backing up Tox node settings"
|
|
|
|
if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
|
|
|
|
rm -rf /var/lib/tox-bootstrapd/Maildir
|
|
|
|
fi
|
|
|
|
cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
|
|
|
|
backup_directory_to_friend /var/lib/tox-bootstrapd tox
|
|
|
|
echo "Backup of Tox node settings complete"
|
|
|
|
fi
|
2016-07-08 17:18:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function restore_remote_tox {
|
2016-07-10 15:54:19 +02:00
|
|
|
if [ -d $SERVER_DIRECTORY/backup/tox ]; then
|
|
|
|
echo $"Restoring Tox node settings"
|
|
|
|
function_check restore_directory_from_friend
|
|
|
|
restore_directory_from_friend / tox
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
exit 93653
|
|
|
|
fi
|
|
|
|
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
|
|
|
systemctl restart tox-bootstrapd.service
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
systemctl status tox-bootstrapd.service
|
|
|
|
exit 59369
|
|
|
|
fi
|
|
|
|
echo $"Restore of Tox node complete"
|
|
|
|
fi
|
2016-07-04 22:02:22 +02:00
|
|
|
}
|
|
|
|
|
2016-07-04 14:32:23 +02:00
|
|
|
function remove_tox_node {
|
|
|
|
if ! grep -Fxq "install_tox_node" $COMPLETION_FILE; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
iptables -D INPUT -p tcp --dport $TOX_PORT -j ACCEPT
|
|
|
|
function_check save_firewall_settings
|
|
|
|
save_firewall_settings
|
|
|
|
|
|
|
|
function_check remove_onion_service
|
|
|
|
remove_onion_service tox ${TOX_PORT}
|
|
|
|
|
|
|
|
${PROJECT_NAME}-mesh-install -f tox_node --remove yes
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
echo $'Failed to remove tox node'
|
|
|
|
exit 763836
|
|
|
|
fi
|
|
|
|
sed -i '/install_tox_node/d' $COMPLETION_FILE
|
2016-07-04 20:03:55 +02:00
|
|
|
sed -i '/configure_firewall_for_tox/d' $COMPLETION_FILE
|
|
|
|
}
|
|
|
|
|
|
|
|
function remove_tox_avahi {
|
|
|
|
if ! grep -Fxq "tox_avahi" $COMPLETION_FILE; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
cd $INSTALL_DIR/toxid
|
|
|
|
make uninstall
|
|
|
|
rm -rf $INSTALL_DIR/toxid
|
|
|
|
sed -i '/toxavahi/d' /etc/crontab
|
|
|
|
systemctl restart cron
|
|
|
|
sed -i '/tox_avahi/d' $COMPLETION_FILE
|
|
|
|
}
|
|
|
|
|
|
|
|
function remove_tox_client {
|
|
|
|
if ! grep -Fxq "install_tox_client" $COMPLETION_FILE; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
${PROJECT_NAME}-mesh-install -f tox_client --remove yes
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
echo $'Could not remove Tox client'
|
|
|
|
exit 737253
|
|
|
|
fi
|
|
|
|
sed -i '/install_tox_client/d' $COMPLETION_FILE
|
|
|
|
sed -i '/Tox /d' $COMPLETION_FILE
|
|
|
|
sed -i '/Toxic /d' $COMPLETION_FILE
|
|
|
|
}
|
|
|
|
|
|
|
|
function remove_tox {
|
|
|
|
remove_tox_client
|
|
|
|
remove_tox_avahi
|
|
|
|
remove_tox_node
|
2016-07-04 14:32:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-03 19:52:57 +02:00
|
|
|
function configure_firewall_for_tox {
|
2016-07-17 17:46:49 +02:00
|
|
|
if [ ! $INSTALLING_MESH ]; then
|
|
|
|
if [ -f $COMPLETION_FILE ]; then
|
|
|
|
if grep -Fxq "configure_firewall_for_tox" $COMPLETION_FILE; then
|
|
|
|
return
|
|
|
|
fi
|
2016-07-12 17:00:51 +02:00
|
|
|
fi
|
2016-07-03 19:52:57 +02:00
|
|
|
fi
|
2016-07-17 17:46:49 +02:00
|
|
|
|
2016-07-03 19:52:57 +02:00
|
|
|
if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
|
|
|
|
# docker does its own firewalling
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
if [[ $ONION_ONLY != "no" ]]; then
|
|
|
|
return
|
|
|
|
fi
|
2016-07-12 17:48:21 +02:00
|
|
|
|
|
|
|
TOX_PORT_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOX_PORT=" | head -n 1 | awk -F '=' '{print $2}')
|
|
|
|
if [ ${#TOX_PORT_MAIN} -gt 2 ]; then
|
|
|
|
TOX_PORT=$TOX_PORT_MAIN
|
|
|
|
fi
|
|
|
|
if [ ! $TOX_PORT ]; then
|
|
|
|
echo $'No Tox port was specified'
|
|
|
|
exit 32856
|
|
|
|
fi
|
|
|
|
|
2016-07-03 19:52:57 +02:00
|
|
|
iptables -A INPUT -p tcp --dport $TOX_PORT -j ACCEPT
|
|
|
|
function_check save_firewall_settings
|
|
|
|
save_firewall_settings
|
|
|
|
|
|
|
|
OPEN_PORTS+=("Tox $TOX_PORT")
|
2016-07-12 17:00:51 +02:00
|
|
|
if [ -f $COMPLETION_FILE ]; then
|
|
|
|
echo 'configure_firewall_for_tox' >> $COMPLETION_FILE
|
|
|
|
fi
|
2016-07-03 19:52:57 +02:00
|
|
|
}
|
|
|
|
|
2016-07-03 17:13:34 +02:00
|
|
|
function tox_avahi {
|
|
|
|
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
if grep -Fxq "tox_avahi" $COMPLETION_FILE; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d /etc/avahi ]; then
|
|
|
|
echo $'tox_avahi: avahi is not installed'
|
|
|
|
exit 87359
|
|
|
|
fi
|
|
|
|
|
|
|
|
# install a command to obtain the Tox ID
|
|
|
|
cd $INSTALL_DIR
|
|
|
|
function_check git_clone
|
|
|
|
git_clone $TOXID_REPO $INSTALL_DIR/toxid
|
|
|
|
if [ ! -d $INSTALL_DIR/toxid ]; then
|
|
|
|
exit 63921
|
|
|
|
fi
|
|
|
|
cd $INSTALL_DIR/toxid
|
|
|
|
make
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
exit 58432
|
|
|
|
fi
|
|
|
|
make install
|
|
|
|
|
|
|
|
toxavahi
|
|
|
|
|
|
|
|
# publish regularly
|
|
|
|
function_check cron_add_mins
|
|
|
|
cron_add_mins 1 'toxavahi > /dev/null'
|
|
|
|
|
|
|
|
systemctl restart avahi-daemon
|
|
|
|
|
|
|
|
echo 'tox_avahi' >> $COMPLETION_FILE
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_tox_node {
|
|
|
|
if grep -Fxq "install_tox_node" $COMPLETION_FILE; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
${PROJECT_NAME}-mesh-install -f tox_node
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
echo $'Failed to install tox node'
|
|
|
|
exit 26778
|
|
|
|
fi
|
|
|
|
|
|
|
|
TOX_ONION_HOSTNAME=$(add_onion_service tox ${TOX_PORT} ${TOX_PORT})
|
|
|
|
|
|
|
|
if ! grep -q "tox onion domain" $COMPLETION_FILE; then
|
|
|
|
echo "tox onion domain:${TOX_ONION_HOSTNAME}" >> $COMPLETION_FILE
|
|
|
|
else
|
|
|
|
sed -i "s|tox onion domain.*|tox onion domain:${TOX_ONION_HOSTNAME}|g" $COMPLETION_FILE
|
|
|
|
fi
|
|
|
|
|
|
|
|
systemctl restart tox-bootstrapd.service
|
|
|
|
|
|
|
|
TOX_PUBLIC_KEY=$(cat /var/log/syslog | grep tox | grep "Public Key" | awk -F ' ' '{print $8}' | tail -1)
|
|
|
|
if [ ${#TOX_PUBLIC_KEY} -lt 30 ]; then
|
|
|
|
echo $'Could not obtain the tox node public key'
|
|
|
|
exit 6529
|
|
|
|
fi
|
|
|
|
|
|
|
|
# save the public key for later reference
|
|
|
|
echo "$TOX_PUBLIC_KEY" > $TOX_BOOTSTRAP_ID_FILE
|
|
|
|
|
|
|
|
function_check configure_firewall_for_tox
|
|
|
|
configure_firewall_for_tox
|
|
|
|
|
|
|
|
if ! grep -q $"Your Tox node public key is" /home/$MY_USERNAME/README; then
|
|
|
|
echo '' >> /home/$MY_USERNAME/README
|
|
|
|
echo '' >> /home/$MY_USERNAME/README
|
|
|
|
echo 'Tox' >> /home/$MY_USERNAME/README
|
|
|
|
echo '===' >> /home/$MY_USERNAME/README
|
|
|
|
echo $"tox onion domain: ${TOX_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README
|
|
|
|
echo $"Your Tox node public key is: $TOX_PUBLIC_KEY" >> /home/$MY_USERNAME/README
|
|
|
|
echo $'In the Toxic client you can connect to it with:' >> /home/$MY_USERNAME/README
|
|
|
|
echo " /connect $DEFAULT_DOMAIN_NAME.local $TOX_PORT $TOX_PUBLIC_KEY" >> /home/$MY_USERNAME/README
|
|
|
|
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
|
|
|
|
chmod 600 /home/$MY_USERNAME/README
|
|
|
|
fi
|
|
|
|
|
|
|
|
function_check configure_firewall_for_tox
|
|
|
|
configure_firewall_for_tox
|
|
|
|
echo 'install_tox_node' >> $COMPLETION_FILE
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_tox_client {
|
|
|
|
if grep -Fxq "install_tox_client" $COMPLETION_FILE; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
${PROJECT_NAME}-mesh-install -f tox_client
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
echo $'Could not install Tox client'
|
|
|
|
exit 67248
|
|
|
|
fi
|
|
|
|
|
|
|
|
# initial setup of username
|
|
|
|
#su -c "echo 'n
|
|
|
|
#/nick $MY_USERNAME
|
|
|
|
#/exit
|
|
|
|
#' | $TOXIC_FILE -d" - $MY_USERNAME
|
|
|
|
|
|
|
|
echo 'install_tox_client' >> $COMPLETION_FILE
|
|
|
|
}
|
|
|
|
|
2016-07-12 09:27:11 +02:00
|
|
|
function mesh_tox_node {
|
|
|
|
if [ ! $TOXCORE_COMMIT ]; then
|
|
|
|
echo $'No Tox commit was specified'
|
|
|
|
exit 76325
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! $TOXCORE_REPO ]; then
|
|
|
|
echo $'No Tox repo was specified'
|
|
|
|
exit 16865
|
|
|
|
fi
|
|
|
|
|
|
|
|
chroot "$rootdir" apt-get -y install build-essential libtool autotools-dev
|
|
|
|
chroot "$rootdir" apt-get -y install automake checkinstall check git yasm
|
|
|
|
chroot "$rootdir" apt-get -y install libsodium13 libsodium-dev libcap2-bin
|
|
|
|
chroot "$rootdir" apt-get -y install libconfig9 libconfig-dev
|
|
|
|
|
|
|
|
TEMP_SCRIPT_NAME=fbtmp37272.sh
|
|
|
|
TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME
|
|
|
|
|
2016-07-17 17:31:38 +02:00
|
|
|
mkdir -p ${rootdir}${INSTALL_DIR}
|
|
|
|
git clone ${TOXCORE_REPO} ${rootdir}${INSTALL_DIR}/toxcore
|
|
|
|
chroot "$rootdir" cd $INSTALL_DIR/toxcore && git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT
|
|
|
|
chroot "$rootdir" cd $INSTALL_DIR/toxcore && autoreconf -i
|
|
|
|
chroot "$rootdir" cd $INSTALL_DIR/toxcore && ./configure --enable-daemon --disable-av
|
|
|
|
chroot "$rootdir" cd $INSTALL_DIR/toxcore && make
|
2016-07-12 09:27:11 +02:00
|
|
|
if [ ! "$?" = "0" ]; then
|
2016-07-17 17:31:38 +02:00
|
|
|
exit 429285
|
|
|
|
fi
|
|
|
|
chroot "$rootdir" cd $INSTALL_DIR/toxcore && make install
|
|
|
|
cp $rootdir/usr/local/lib/libtoxcore* $rootdir/usr/lib/
|
|
|
|
cp ${rootdir}${INSTALL_DIR}/toxcore/other/bootstrap_daemon/tox-bootstrapd.service $rootdir/etc/systemd/system/
|
|
|
|
sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service
|
|
|
|
chroot "$rootdir" systemctl enable tox-bootstrapd.service
|
|
|
|
|
|
|
|
SECONDS=0
|
|
|
|
if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then
|
2016-07-12 09:27:11 +02:00
|
|
|
duration=$SECONDS
|
|
|
|
echo $"Toxcore compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
|
|
|
|
echo $'Unable to make toxcore'
|
|
|
|
exit 73835
|
|
|
|
fi
|
|
|
|
duration=$SECONDS
|
|
|
|
echo $"Toxcore compile $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
|
|
|
|
|
|
|
|
chroot "$rootdir" useradd --home-dir /var/lib/tox-bootstrapd --create-home --system --shell /sbin/nologin --comment $"Account to run Tox's DHT bootstrap daemon" --user-group tox-bootstrapd
|
|
|
|
chroot "$rootdir" chmod 700 /var/lib/tox-bootstrapd
|
|
|
|
|
|
|
|
# remove Maildir
|
|
|
|
if [ -d $rootdir/var/lib/tox-bootstrapd/Maildir ]; then
|
|
|
|
rm -rf $rootdir/var/lib/tox-bootstrapd/Maildir
|
|
|
|
fi
|
|
|
|
|
|
|
|
# create configuration file
|
|
|
|
TOX_BOOTSTRAP_CONFIG=$rootdir/etc/tox-bootstrapd.conf
|
|
|
|
echo "port = $TOX_PORT" > $TOX_BOOTSTRAP_CONFIG
|
|
|
|
echo 'keys_file_path = "/var/lib/tox-bootstrapd/keys"' >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
echo 'pid_file_path = "/var/run/tox-bootstrapd/tox-bootstrapd.pid"' >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
echo 'enable_ipv6 = true' >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
echo 'enable_ipv4_fallback = true' >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
echo 'enable_lan_discovery = true' >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
echo 'enable_tcp_relay = true' >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
echo "tcp_relay_ports = [443, 3389, $TOX_PORT]" >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
echo 'enable_motd = true' >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
echo 'motd = "tox-bootstrapd"' >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
|
|
|
|
if [ $TOX_NODES ]; then
|
|
|
|
echo 'bootstrap_nodes = (' >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
toxcount=0
|
|
|
|
while [ "x${TOX_NODES[toxcount]}" != "x" ]
|
|
|
|
do
|
|
|
|
toxval_ipv4=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $1}')
|
|
|
|
toxval_ipv6=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $2}')
|
|
|
|
toxval_port=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $3}')
|
|
|
|
toxval_pubkey=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $4}')
|
|
|
|
toxval_maintainer=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $5}')
|
|
|
|
echo "{ // $toxval_maintainer" >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
if [[ $toxval_ipv6 != 'NONE' ]]; then
|
|
|
|
echo " address = \"$toxval_ipv6\"" >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
else
|
|
|
|
echo " address = \"$toxval_ipv4\"" >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
fi
|
|
|
|
echo " port = $toxval_port" >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
echo " public_key = \"$toxval_pubkey\"" >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
toxcount=$(( $toxcount + 1 ))
|
|
|
|
if [ "x${TOX_NODES[toxcount]}" != "x" ]; then
|
|
|
|
echo "}," >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
else
|
|
|
|
echo "}" >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo ')' >> $TOX_BOOTSTRAP_CONFIG
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function mesh_tox_avahi {
|
|
|
|
if [ ! -d $rootdir/etc/avahi ]; then
|
|
|
|
echo $'tox_avahi: avahi is not installed'
|
|
|
|
exit 87359
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! $TOXID_REPO ]; then
|
|
|
|
echo $'No ToxID repo was specified'
|
|
|
|
exit 78252
|
|
|
|
fi
|
|
|
|
|
2016-07-17 17:31:38 +02:00
|
|
|
if [ ! -d ${rootdir}${INSTALL_DIR} ]; then
|
|
|
|
mkdir -p ${rootdir}${INSTALL_DIR}
|
|
|
|
fi
|
|
|
|
|
|
|
|
git clone ${TOXID_REPO} ${rootdir}${INSTALL_DIR}/toxid
|
|
|
|
if [ ! -d ${rootdir}${INSTALL_DIR}/toxid ]; then
|
|
|
|
echo $'Unable to clone toxid repo'
|
|
|
|
exit 768352
|
|
|
|
fi
|
|
|
|
chroot "$rootdir" cd $INSTALL_DIR/toxid && make
|
2016-07-12 09:27:11 +02:00
|
|
|
if [ ! "$?" = "0" ]; then
|
2016-07-17 17:31:38 +02:00
|
|
|
echo $'Unable to make toxid'
|
|
|
|
exit 386823
|
|
|
|
fi
|
|
|
|
chroot "$rootdir" cd $INSTALL_DIR/toxid && make install
|
|
|
|
if [ ! -f $rootdir/usr/local/bin/toxavahi ]; then
|
|
|
|
exit 3621729
|
2016-07-12 09:27:11 +02:00
|
|
|
fi
|
2016-07-17 17:31:38 +02:00
|
|
|
echo "* * * * * root /usr/local/bin/toxavahi > /dev/null" >> $rootdir/etc/crontab
|
2016-07-12 09:27:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function mesh_tox_client {
|
|
|
|
TOXIC_FILE=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
|
|
|
|
|
|
|
|
# obtain commits from the main file
|
|
|
|
TOXIC_COMMIT_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXIC_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
|
|
|
|
if [ ${#TOXIC_COMMIT_MAIN} -gt 10 ]; then
|
|
|
|
TOXIC_COMMIT=$TOXIC_COMMIT_MAIN
|
|
|
|
fi
|
|
|
|
|
|
|
|
TOXIC_REPO_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXIC_REPO=" | head -n 1 | awk -F '"' '{print $2}')
|
|
|
|
if [ ${#TOXIC_REPO_MAIN} -gt 5 ]; then
|
|
|
|
TOXIC_REPO=$TOXIC_REPO_MAIN
|
|
|
|
fi
|
|
|
|
|
|
|
|
chroot "$rootdir" apt-get -y install libncursesw5-dev libconfig-dev libqrencode-dev
|
|
|
|
chroot "$rootdir" apt-get -y install libcurl4-openssl-dev libvpx-dev libopenal-dev
|
|
|
|
|
|
|
|
TEMP_SCRIPT_NAME=fbtmp728353.sh
|
|
|
|
TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME
|
|
|
|
echo '#!/bin/bash' > $TEMP_SCRIPT
|
|
|
|
echo "mkdir -p $INSTALL_DIR" >> $TEMP_SCRIPT
|
|
|
|
echo "git clone $TOXIC_REPO $INSTALL_DIR/toxic" >> $TEMP_SCRIPT
|
|
|
|
echo "cd $INSTALL_DIR/toxic" >> $TEMP_SCRIPT
|
|
|
|
echo "git checkout $TOXIC_COMMIT -b $TOXIC_COMMIT" >> $TEMP_SCRIPT
|
|
|
|
echo 'make' >> $TEMP_SCRIPT
|
|
|
|
echo 'if [ ! "$?" = "0" ]; then' >> $TEMP_SCRIPT
|
|
|
|
echo ' exit 1' >> $TEMP_SCRIPT
|
|
|
|
echo 'fi' >> $TEMP_SCRIPT
|
|
|
|
echo 'make install' >> $TEMP_SCRIPT
|
|
|
|
echo 'exit 0' >> $TEMP_SCRIPT
|
|
|
|
chmod +x $TEMP_SCRIPT
|
|
|
|
cp $TEMP_SCRIPT $rootdir/root/
|
|
|
|
|
|
|
|
TOXIC_FILE=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
|
|
|
|
|
|
|
|
SECONDS=0
|
|
|
|
chroot "$rootdir" /root/$TEMP_SCRIPT_NAME
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
duration=$SECONDS
|
|
|
|
echo $"Toxic client compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
|
|
|
|
echo $'Unable to make tox client'
|
|
|
|
rm $TEMP_SCRIPT
|
|
|
|
exit 74872
|
|
|
|
fi
|
|
|
|
rm $TEMP_SCRIPT
|
|
|
|
if [ ! -f $rootdir$TOXIC_FILE ]; then
|
|
|
|
echo $"Tox client was not installed to $TOXIC_FILE"
|
|
|
|
exit 63278
|
|
|
|
fi
|
|
|
|
duration=$SECONDS
|
|
|
|
echo $"Toxic client compile $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
|
|
|
|
}
|
|
|
|
|
|
|
|
function enable_tox_repo {
|
|
|
|
echo 'deb http://download.opensuse.org/repositories/home:/antonbatenev:/tox/Debian_8.0/ /' > $rootdir/etc/apt/sources.list.d/tox.list
|
|
|
|
|
|
|
|
|
|
|
|
chroot "$rootdir" wget -q http://download.opensuse.org/repositories/home:antonbatenev:tox/Debian_8.0/Release.key -O- | apt-key add -
|
|
|
|
chroot "$rootdir" apt-get update
|
|
|
|
echo "Tox Repository Installed."
|
|
|
|
}
|
|
|
|
|
2016-07-12 11:55:18 +02:00
|
|
|
function install_tox {
|
2016-07-17 17:46:49 +02:00
|
|
|
if [ ! $INSTALLING_MESH ]; then
|
|
|
|
if grep -Fxq "install_tox" $COMPLETION_FILE; then
|
|
|
|
return
|
|
|
|
fi
|
2016-07-12 11:55:18 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
configure_firewall_for_tox
|
|
|
|
|
|
|
|
if [ $INSTALLING_MESH ]; then
|
|
|
|
mesh_tox_node
|
|
|
|
mesh_tox_avahi
|
|
|
|
mesh_tox_client
|
|
|
|
else
|
|
|
|
install_tox_node
|
|
|
|
tox_avahi
|
|
|
|
install_tox_client
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo 'install_tox' >> $COMPLETION_FILE
|
|
|
|
}
|
|
|
|
|
2016-07-03 17:13:34 +02:00
|
|
|
# NOTE: deliberately no exit 0
|