Use a daemon rather than a cron job for mesh publications
This commit is contained in:
parent
2789ac7ac7
commit
bd534ac02f
|
@ -215,9 +215,13 @@ function remove_tox_avahi {
|
|||
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
|
||||
if [ -f /etc/systemd/system/mesh-sync.service ]; then
|
||||
systemctl stop mesh-sync
|
||||
systemctl disable mesh-sync
|
||||
rm -f /etc/systemd/system/mesh-sync.service
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_tox_client {
|
||||
|
@ -580,7 +584,35 @@ EOF
|
|||
if [ ! -f $rootdir/usr/local/bin/toxavahi ]; then
|
||||
exit 3621729
|
||||
fi
|
||||
echo "*/1 * * * * root /usr/local/bin/toxavahi > /dev/null" >> $rootdir/etc/crontab
|
||||
|
||||
MESH_SYNC_COMMAND=$rootdir/usr/bin/mesh-sync
|
||||
echo '#!/bin/bash' > $MESH_SYNC_COMMAND
|
||||
echo 'while true' >> $MESH_SYNC_COMMAND
|
||||
echo 'do' >> $MESH_SYNC_COMMAND
|
||||
echo ' /usr/bin/timeout 20 /usr/local/bin/toxavahi' >> $MESH_SYNC_COMMAND
|
||||
echo ' /usr/bin/timeout 20 /usr/local/bin/zeronetavahi' >> $MESH_SYNC_COMMAND
|
||||
echo ' sleep 5' >> $MESH_SYNC_COMMAND
|
||||
echo 'done' >> $MESH_SYNC_COMMAND
|
||||
chmod +x $MESH_SYNC_COMMAND
|
||||
|
||||
if [ ! -f $rootdir/etc/systemd/system/mesh-sync.service ]; then
|
||||
MESH_SYNC_FILENAME=$rootdir/etc/systemd/system/mesh-sync.service
|
||||
echo '[Unit]' > $MESH_SYNC_FILENAME
|
||||
echo 'Description=mesh-sync - Service publications over avahi' >> $MESH_SYNC_FILENAME
|
||||
echo 'After=network.target' >> $MESH_SYNC_FILENAME
|
||||
echo '' >> $MESH_SYNC_FILENAME
|
||||
echo '[Service]' >> $MESH_SYNC_FILENAME
|
||||
echo 'User=root' >> $MESH_SYNC_FILENAME
|
||||
echo 'ExecStart=/usr/bin/mesh-sync' >> $MESH_SYNC_FILENAME
|
||||
echo 'Restart=on-failure' >> $MESH_SYNC_FILENAME
|
||||
echo 'SuccessExitStatus=3 4' >> $MESH_SYNC_FILENAME
|
||||
echo 'RestartForceExitStatus=3 4' >> $MESH_SYNC_FILENAME
|
||||
echo '' >> $MESH_SYNC_FILENAME
|
||||
echo '[Install]' >> $MESH_SYNC_FILENAME
|
||||
echo 'WantedBy=multi-user.target' >> $MESH_SYNC_FILENAME
|
||||
|
||||
chroot "$rootdir" systemctl enable mesh-sync.service
|
||||
fi
|
||||
}
|
||||
|
||||
function mesh_tox_client {
|
||||
|
|
|
@ -120,6 +120,12 @@ function remove_zeronet {
|
|||
if ! grep -Fxq "install_zeronet" $COMPLETION_FILE; then
|
||||
return
|
||||
fi
|
||||
if [ -f /etc/systemd/system/mesh-sync.service ]; then
|
||||
systemctl stop mesh-sync
|
||||
systemctl disable mesh-sync
|
||||
rm -f /etc/systemd/system/mesh-sync.service
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
iptables -D INPUT -i $WIFI_INTERFACE -p udp --dport $ZERONET_PORT -j ACCEPT
|
||||
iptables -D INPUT -i $WIFI_INTERFACE -p tcp --dport $ZERONET_PORT -j ACCEPT
|
||||
iptables -D INPUT -i $WIFI_INTERFACE -p udp --dport $TRACKER_PORT -j ACCEPT
|
||||
|
@ -555,7 +561,34 @@ function mesh_zeronet {
|
|||
chroot "$rootdir" chown -R tracker:tracker $MESH_INSTALL_DIR/tracker
|
||||
|
||||
# publish regularly
|
||||
echo "*/1 * * * * root /usr/local/bin/zeronetavahi > /dev/null" >> $rootdir/etc/crontab
|
||||
MESH_SYNC_COMMAND=$rootdir/usr/bin/mesh-sync
|
||||
echo '#!/bin/bash' > $MESH_SYNC_COMMAND
|
||||
echo 'while true' >> $MESH_SYNC_COMMAND
|
||||
echo 'do' >> $MESH_SYNC_COMMAND
|
||||
echo ' /usr/bin/timeout 20 /usr/local/bin/toxavahi' >> $MESH_SYNC_COMMAND
|
||||
echo ' /usr/bin/timeout 20 /usr/local/bin/zeronetavahi' >> $MESH_SYNC_COMMAND
|
||||
echo ' sleep 5' >> $MESH_SYNC_COMMAND
|
||||
echo 'done' >> $MESH_SYNC_COMMAND
|
||||
chmod +x $MESH_SYNC_COMMAND
|
||||
|
||||
if [ ! -f $rootdir/etc/systemd/system/mesh-sync.service ]; then
|
||||
MESH_SYNC_FILENAME=$rootdir/etc/systemd/system/mesh-sync.service
|
||||
echo '[Unit]' > $MESH_SYNC_FILENAME
|
||||
echo 'Description=mesh-sync - Service publications over avahi' >> $MESH_SYNC_FILENAME
|
||||
echo 'After=network.target' >> $MESH_SYNC_FILENAME
|
||||
echo '' >> $MESH_SYNC_FILENAME
|
||||
echo '[Service]' >> $MESH_SYNC_FILENAME
|
||||
echo 'User=root' >> $MESH_SYNC_FILENAME
|
||||
echo 'ExecStart=/usr/bin/mesh-sync' >> $MESH_SYNC_FILENAME
|
||||
echo 'Restart=on-failure' >> $MESH_SYNC_FILENAME
|
||||
echo 'SuccessExitStatus=3 4' >> $MESH_SYNC_FILENAME
|
||||
echo 'RestartForceExitStatus=3 4' >> $MESH_SYNC_FILENAME
|
||||
echo '' >> $MESH_SYNC_FILENAME
|
||||
echo '[Install]' >> $MESH_SYNC_FILENAME
|
||||
echo 'WantedBy=multi-user.target' >> $MESH_SYNC_FILENAME
|
||||
|
||||
chroot "$rootdir" systemctl enable mesh-sync.service
|
||||
fi
|
||||
|
||||
chroot "$rootdir" systemctl enable tracker.service
|
||||
chroot "$rootdir" systemctl enable zeronet.service
|
||||
|
|
|
@ -169,13 +169,6 @@ function install_toxid {
|
|||
echo $"Couldn't install toxid"
|
||||
exit 6389
|
||||
fi
|
||||
|
||||
if ! grep -Fxq "toxavahi" /etc/crontab; then
|
||||
cp /etc/crontab /tmp/crontab
|
||||
echo "*/1 * * * * root toxavahi > /dev/null" >> /tmp/crontab
|
||||
sudo cp /tmp/crontab /etc/crontab
|
||||
rm /tmp/crontab
|
||||
fi
|
||||
}
|
||||
|
||||
function run_tox {
|
||||
|
|
Loading…
Reference in New Issue