Skip to content

Commit

Permalink
switch to systemd emonhub.service
Browse files Browse the repository at this point in the history
  • Loading branch information
glynhudson committed Feb 7, 2019
1 parent d9b827f commit c4e3390
Showing 1 changed file with 48 additions and 2 deletions.
50 changes: 48 additions & 2 deletions emonhubupdate
Original file line number Diff line number Diff line change
@@ -1,9 +1,55 @@
#!/bin/bash
echo
echo "================================="
echo "EmonPi update started"
echo "emonHub update started"
echo "================================="

username="pi"
homedir="/home/$username"

service="emonhub"
servicepath="$homedir/emonhub/service/emonhub.service"

if [ -d /etc/systemd ] && [ -f $servicepath ]; then
if [ -f /etc/init.d/$service ]; then
echo "removing initd $service service"
sudo /etc/init.d/$service stop
sudo rm /etc/init.d/$service
fi

# service will be symlinked to /etc/systemd/system by "systemctl enable"
if [ -f /etc/systemd/system/$service.service ]; then
if ! [ -L /etc/systemd/system/$service.service ]; then
echo "Removing hard copy of $service.service from /etc/systemd/system (should be symlink)"
sudo systemctl stop $service.service
sudo systemctl disable $service.service
sudo rm /etc/systemd/system/$service.service
sudo systemctl daemon-reload
fi
fi

if [ -f /lib/systemd/system/$service.service ]; then
if ! [ -L /lib/systemd/system/$service.service ]; then
echo "Removing hard copy of $service.service in /lib/systemd/system (should be symlink)"
sudo systemctl stop $service.service
sudo systemctl disable $service.service
sudo rm /lib/systemd/system/$service.service
sudo systemctl daemon-reload
fi
fi

if [ ! -f /lib/systemd/system/$service.service ]; then
echo "Installing $service.service in /lib/systemd/system (creating symlink)"
sudo ln -s $servicepath /lib/systemd/system
sudo systemctl enable $service.service
sudo systemctl start $service.service
else
echo "$service.service already installed"
fi
fi

echo
echo "Running emonhub automatic node addition script"
echo "EUID: $EUID"
/home/pi/emonhub/conf/nodes/emonpi_auto_add_nodes.sh
$homedir/emonhub/conf/nodes/emonpi_auto_add_nodes.sh

0 comments on commit c4e3390

Please sign in to comment.