Skip to content
Snippets Groups Projects
Commit f74341bf authored by Bob Mottram's avatar Bob Mottram
Browse files

Daemon to restart mesh networking when ethernet is connected

parent 5357e59f
No related branches found
No related tags found
No related merge requests found
......@@ -867,6 +867,7 @@ function mesh_restart_daemons {
systemctl restart avahi-daemon
systemctl restart tox-bootstrapd
systemctl restart nginx
systemctl restart ethmesh
echo $'Daemons restarted' >> $INSTALL_LOG
}
......@@ -1330,6 +1331,31 @@ function initialise_scuttlebot_pub {
fi
}
function mesh_ethernet_daemon {
if [ -f /etc/systemd/system/ethmesh.service ]; then
return
fi
{ echo '[Unit]';
echo 'Description=Ethernet daemon for mesh';
echo 'After=network.target';
echo '';
echo '[Service]';
echo 'User=root';
echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-mesh-ethernet";
echo "ExecReload=/bin/kill \$MAINPID";
echo 'KillMode=process';
echo 'Restart=always';
echo '';
echo '[Install]';
echo 'WantedBy=multi-user.target'; } > /etc/systemd/system/ethmesh.service
systemctl enable ethmesh
systemctl daemon-reload
systemctl start ethmesh
}
# whether to reset the identity
set_new_identity=
if [ "$2" ]; then
......@@ -1449,6 +1475,7 @@ if [ -f $MESH_INSTALL_SETUP ]; then
enable_peertube
mesh_amnesic
make_root_read_only
mesh_ethernet_daemon
if [ ! -f $MESH_AMNESIC ]; then
rm $MESH_INSTALL_SETUP
......
#!/bin/bash
# _____ _ _
# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
# | __| _| -_| -_| . | . | | . | . | | -_|
# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
#
# Freedom in the Cloud
#
# Daemon which monitors whether ethernet is connected or not
#
# License
# =======
#
# Copyright (C) 2018 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/>.
ETHERNET_ATTACHED=/sys/class/net/eth0/carrier
prev_eth_attached=$(cat $ETHERNET_ATTACHED)
while true
do
sleep 5
eth_attached=$(cat $ETHERNET_ATTACHED)
if [[ "$eth_attached" != "$prev_eth_attached" ]]; then
/usr/local/bin/batman restart
fi
prev_eth_attached=$eth_attached
done
exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment