More generic

This commit is contained in:
Bob Mottram 2016-04-12 09:40:47 +01:00
parent d9af8529d2
commit e8702fed67
1 changed files with 99 additions and 99 deletions

View File

@ -420,10 +420,10 @@ function mesh_firewall {
function mesh_tox_node { function mesh_tox_node {
# obtain commits from the main file # obtain commits from the main file
if [ -f /usr/loca/bin/freedombone ]; then if [ -f /usr/loca/bin/${PROJECT_NAME} ]; then
TOX_COMMIT_MAIN=$(cat /usr/local/bin/freedombone | grep "TOX_COMMIT=" | head -n 1 | awk -F "'" '{print $2}') TOX_COMMIT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOX_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
else else
TOX_COMMIT_MAIN=$(cat /usr/bin/freedombone | grep "TOX_COMMIT=" | head -n 1 | awk -F "'" '{print $2}') TOX_COMMIT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOX_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
fi fi
if [ ${#TOX_COMMIT_MAIN} -gt 10 ]; then if [ ${#TOX_COMMIT_MAIN} -gt 10 ]; then
TOX_COMMIT=$TOX_COMMIT_MAIN TOX_COMMIT=$TOX_COMMIT_MAIN
@ -433,10 +433,10 @@ function mesh_tox_node {
exit 76325 exit 76325
fi fi
if [ -f /usr/loca/bin/freedombone ]; then if [ -f /usr/loca/bin/${PROJECT_NAME} ]; then
TOXID_REPO_MAIN=$(cat /usr/local/bin/freedombone | grep "TOXID_REPO=" | head -n 1 | awk -F "'" '{print $2}') TOXID_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXID_REPO=" | head -n 1 | awk -F "'" '{print $2}')
else else
TOXID_REPO_MAIN=$(cat /usr/bin/freedombone | grep "TOXID_REPO=" | head -n 1 | awk -F "'" '{print $2}') TOXID_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXID_REPO=" | head -n 1 | awk -F "'" '{print $2}')
fi fi
if [ ${#TOXID_REPO_MAIN} -gt 5 ]; then if [ ${#TOXID_REPO_MAIN} -gt 5 ]; then
TOXID_REPO=$TOXID_REPO_MAIN TOXID_REPO=$TOXID_REPO_MAIN
@ -446,10 +446,10 @@ function mesh_tox_node {
exit 78252 exit 78252
fi fi
if [ -f /usr/loca/bin/freedombone ]; then if [ -f /usr/loca/bin/${PROJECT_NAME} ]; then
TOX_PORT_MAIN=$(cat /usr/local/bin/freedombone | grep "TOX_PORT=" | head -n 1 | awk -F "'" '{print $2}') TOX_PORT_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOX_PORT=" | head -n 1 | awk -F "'" '{print $2}')
else else
TOX_PORT_MAIN=$(cat /usr/bin/freedombone | grep "TOX_PORT=" | head -n 1 | awk -F "'" '{print $2}') TOX_PORT_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOX_PORT=" | head -n 1 | awk -F "'" '{print $2}')
fi fi
if [ ${#TOX_PORT_MAIN} -gt 2 ]; then if [ ${#TOX_PORT_MAIN} -gt 2 ]; then
TOX_PORT=$TOX_PORT_MAIN TOX_PORT=$TOX_PORT_MAIN
@ -459,105 +459,105 @@ function mesh_tox_node {
exit 32856 exit 32856
fi fi
if [ -f /usr/loca/bin/freedombone ]; then if [ -f /usr/loca/bin/${PROJECT_NAME} ]; then
TOX_REPO_MAIN=$(cat /usr/local/bin/freedombone | grep "TOX_REPO=" | head -n 1 | awk -F "'" '{print $2}') TOX_REPO_MAIN=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOX_REPO=" | head -n 1 | awk -F "'" '{print $2}')
else else
TOX_REPO_MAIN=$(cat /usr/bin/freedombone | grep "TOX_REPO=" | head -n 1 | awk -F "'" '{print $2}') TOX_REPO_MAIN=$(cat /usr/bin/${PROJECT_NAME} | grep "TOX_REPO=" | head -n 1 | awk -F "'" '{print $2}')
fi fi
if [ ${#TOX_REPO_MAIN} -gt 10 ]; then if [ ${#TOX_REPO_MAIN} -gt 10 ]; then
TOX_REPO=$TOX_REPO_MAIN TOX_REPO=$TOX_REPO_MAIN
fi fi
if [ ! $TOX_REPO ]; then if [ ! $TOX_REPO ]; then
echo $'No Tox repo was specified' echo $'No Tox repo was specified'
exit 16865 exit 16865
fi fi
$CHROOT_PREFIX apt-get -y install build-essential libtool autotools-dev $CHROOT_PREFIX apt-get -y install build-essential libtool autotools-dev
$CHROOT_PREFIX apt-get -y install automake checkinstall check git yasm $CHROOT_PREFIX apt-get -y install automake checkinstall check git yasm
$CHROOT_PREFIX apt-get -y install libsodium13 libsodium-dev libcap2-bin $CHROOT_PREFIX apt-get -y install libsodium13 libsodium-dev libcap2-bin
$CHROOT_PREFIX apt-get -y install libconfig9 libconfig-dev $CHROOT_PREFIX apt-get -y install libconfig9 libconfig-dev
$CHROOT_PREFIX git_clone $TOX_REPO $INSTALL_DIR/toxcore $CHROOT_PREFIX git_clone $TOX_REPO $INSTALL_DIR/toxcore
$CHROOT_PREFIX cd $INSTALL_DIR/toxcore $CHROOT_PREFIX cd $INSTALL_DIR/toxcore
$CHROOT_PREFIX git checkout $TOX_COMMIT -b $TOX_COMMIT $CHROOT_PREFIX git checkout $TOX_COMMIT -b $TOX_COMMIT
$CHROOT_PREFIX autoreconf -i $CHROOT_PREFIX autoreconf -i
$CHROOT_PREFIX ./configure --enable-daemon --disable-av $CHROOT_PREFIX ./configure --enable-daemon --disable-av
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
return return
fi fi
$CHROOT_PREFIX make $CHROOT_PREFIX make
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
return return
fi fi
$CHROOT_PREFIX make install $CHROOT_PREFIX make install
$CHROOT_PREFIX cp /usr/local/lib/libtoxcore* /usr/lib/ $CHROOT_PREFIX cp /usr/local/lib/libtoxcore* /usr/lib/
if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then
echo $"File not found /usr/local/bin/tox-bootstrapd" echo $"File not found /usr/local/bin/tox-bootstrapd"
return return
fi fi
$CHROOT_PREFIX 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_PREFIX 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_PREFIX chmod 700 /var/lib/tox-bootstrapd $CHROOT_PREFIX chmod 700 /var/lib/tox-bootstrapd
if [ ! -f $rootdir/$INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf ]; then if [ ! -f $rootdir/$INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf ]; then
echo $"File not found $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf" echo $"File not found $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf"
fi fi
# remove Maildir # remove Maildir
if [ -d $rootdir/var/lib/tox-bootstrapd/Maildir ]; then if [ -d $rootdir/var/lib/tox-bootstrapd/Maildir ]; then
rm -rf $rootdir/var/lib/tox-bootstrapd/Maildir rm -rf $rootdir/var/lib/tox-bootstrapd/Maildir
fi fi
# create configuration file # create configuration file
TOX_BOOTSTRAP_CONFIG=${rootdir}/etc/tox-bootstrapd.conf TOX_BOOTSTRAP_CONFIG=${rootdir}/etc/tox-bootstrapd.conf
echo "port = $TOX_PORT" > $TOX_BOOTSTRAP_CONFIG echo "port = $TOX_PORT" > $TOX_BOOTSTRAP_CONFIG
echo 'keys_file_path = "/var/lib/tox-bootstrapd/keys"' >> $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 'pid_file_path = "/var/run/tox-bootstrapd/tox-bootstrapd.pid"' >> $TOX_BOOTSTRAP_CONFIG
echo 'enable_ipv6 = true' >> $TOX_BOOTSTRAP_CONFIG echo 'enable_ipv6 = true' >> $TOX_BOOTSTRAP_CONFIG
echo 'enable_ipv4_fallback = true' >> $TOX_BOOTSTRAP_CONFIG echo 'enable_ipv4_fallback = true' >> $TOX_BOOTSTRAP_CONFIG
echo 'enable_lan_discovery = true' >> $TOX_BOOTSTRAP_CONFIG echo 'enable_lan_discovery = true' >> $TOX_BOOTSTRAP_CONFIG
echo 'enable_tcp_relay = true' >> $TOX_BOOTSTRAP_CONFIG echo 'enable_tcp_relay = true' >> $TOX_BOOTSTRAP_CONFIG
echo "tcp_relay_ports = [443, 3389, $TOX_PORT]" >> $TOX_BOOTSTRAP_CONFIG echo "tcp_relay_ports = [443, 3389, $TOX_PORT]" >> $TOX_BOOTSTRAP_CONFIG
echo 'enable_motd = true' >> $TOX_BOOTSTRAP_CONFIG echo 'enable_motd = true' >> $TOX_BOOTSTRAP_CONFIG
echo 'motd = "tox-bootstrapd"' >> $TOX_BOOTSTRAP_CONFIG echo 'motd = "tox-bootstrapd"' >> $TOX_BOOTSTRAP_CONFIG
if [ $TOX_NODES ]; then if [ $TOX_NODES ]; then
echo 'bootstrap_nodes = (' >> $TOX_BOOTSTRAP_CONFIG echo 'bootstrap_nodes = (' >> $TOX_BOOTSTRAP_CONFIG
toxcount=0 toxcount=0
while [ "x${TOX_NODES[toxcount]}" != "x" ] while [ "x${TOX_NODES[toxcount]}" != "x" ]
do do
toxval_ipv4=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $1}') toxval_ipv4=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $1}')
toxval_ipv6=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $2}') toxval_ipv6=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $2}')
toxval_port=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $3}') toxval_port=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $3}')
toxval_pubkey=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $4}') toxval_pubkey=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $4}')
toxval_maintainer=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $5}') toxval_maintainer=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $5}')
echo "{ // $toxval_maintainer" >> $TOX_BOOTSTRAP_CONFIG echo "{ // $toxval_maintainer" >> $TOX_BOOTSTRAP_CONFIG
if [[ $toxval_ipv6 != 'NONE' ]]; then if [[ $toxval_ipv6 != 'NONE' ]]; then
echo " address = \"$toxval_ipv6\"" >> $TOX_BOOTSTRAP_CONFIG echo " address = \"$toxval_ipv6\"" >> $TOX_BOOTSTRAP_CONFIG
else else
echo " address = \"$toxval_ipv4\"" >> $TOX_BOOTSTRAP_CONFIG echo " address = \"$toxval_ipv4\"" >> $TOX_BOOTSTRAP_CONFIG
fi fi
echo " port = $toxval_port" >> $TOX_BOOTSTRAP_CONFIG echo " port = $toxval_port" >> $TOX_BOOTSTRAP_CONFIG
echo " public_key = \"$toxval_pubkey\"" >> $TOX_BOOTSTRAP_CONFIG echo " public_key = \"$toxval_pubkey\"" >> $TOX_BOOTSTRAP_CONFIG
toxcount=$(( $toxcount + 1 )) toxcount=$(( $toxcount + 1 ))
if [ "x${TOX_NODES[toxcount]}" != "x" ]; then if [ "x${TOX_NODES[toxcount]}" != "x" ]; then
echo "}," >> $TOX_BOOTSTRAP_CONFIG echo "}," >> $TOX_BOOTSTRAP_CONFIG
else else
echo "}" >> $TOX_BOOTSTRAP_CONFIG echo "}" >> $TOX_BOOTSTRAP_CONFIG
fi fi
done done
echo ')' >> $TOX_BOOTSTRAP_CONFIG echo ')' >> $TOX_BOOTSTRAP_CONFIG
fi fi
if [ ! -f $rootdir/$INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service ]; then if [ ! -f $rootdir/$INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service ]; then
echo $"File not found $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service" echo $"File not found $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service"
return return
fi fi
cp $rootdir/$INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service $rootdir/etc/systemd/system/ 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 sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service
$CHROOT_PREFIX systemctl daemon-reload $CHROOT_PREFIX systemctl daemon-reload
$CHROOT_PREFIX systemctl enable tox-bootstrapd.service $CHROOT_PREFIX systemctl enable tox-bootstrapd.service
} }
function mesh_tox_client { function mesh_tox_client {