Alter to use avahi scripts from toxid

This commit is contained in:
Bob Mottram 2015-08-25 18:43:27 +01:00
parent 96bcdd36d5
commit 41c0c6f449
1 changed files with 6 additions and 35 deletions

View File

@ -8167,45 +8167,16 @@ function tox_avahi {
exit 58432
fi
make install
# script to publish the tox user
if [ ! -f /usr/bin/publish-to-avahi ]; then
echo '#!/bin/bash' > /usr/bin/publish-to-avahi
fi
echo '' >> /usr/bin/publish-to-avahi
echo "DATA_FILE=/home/$MY_USERNAME/.config/tox/data" >> /usr/bin/publish-to-avahi
echo 'if [ ! -f $DATA_FILE ]; then' >> /usr/bin/publish-to-avahi
echo ' exit 0' >> /usr/bin/publish-to-avahi
echo 'fi' >> /usr/bin/publish-to-avahi
echo '' >> /usr/bin/publish-to-avahi
echo -n 'TOX_ID=$(toxid -u ' >> /usr/bin/publish-to-avahi
echo "$MY_USERNAME)" >> /usr/bin/publish-to-avahi
echo '' >> /usr/bin/publish-to-avahi
echo "echo \"<?xml version='1.0' standalone='no'?><!--*-nxml-*-->\" > /etc/avahi/services/tox.service" >> /usr/bin/publish-to-avahi
echo "echo '<!DOCTYPE service-group SYSTEM \"avahi-service.dtd\">' >> /etc/avahi/services/tox.service" >> /usr/bin/publish-to-avahi
echo "echo '<service-group>' >> /etc/avahi/services/tox.service" >> /usr/bin/publish-to-avahi
echo -n 'echo " <name replace-wildcards=' >> /usr/bin/publish-to-avahi
echo -n "'yes'" >> /usr/bin/publish-to-avahi
echo '>%h $TOX_ID</name>" >> /etc/avahi/services/tox.service' >> /usr/bin/publish-to-avahi
echo "echo ' <service>' >> /etc/avahi/services/tox.service" >> /usr/bin/publish-to-avahi
echo "echo ' <type>_tox._tcp</type>' >> /etc/avahi/services/tox.service" >> /usr/bin/publish-to-avahi
echo "echo \" <port>$TOX_PORT</port>\" >> /etc/avahi/services/tox.service" >> /usr/bin/publish-to-avahi
echo "echo ' </service>' >> /etc/avahi/services/tox.service" >> /usr/bin/publish-to-avahi
echo "echo '</service-group>' >> /etc/avahi/services/tox.service" >> /usr/bin/publish-to-avahi
echo '' >> /usr/bin/publish-to-avahi
echo 'exit 0' >> /usr/bin/publish-to-avahi
chmod +x /usr/bin/publish-to-avahi
publish-to-avahi
systemctl restart avahi-daemon
toxavahi
# publish regularly
if ! grep -Fxq "publish-to-avahi" /etc/crontab; then
echo '* * * * * root /usr/bin/publish-to-avahi > /dev/null' >> /etc/crontab
if ! grep -Fxq "toxavahi" /etc/crontab; then
echo '* * * * * root toxavahi > /dev/null' >> /etc/crontab
fi
systemctl restart avahi-daemon
echo 'tox_avahi' >> $COMPLETION_FILE
}