-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9b827f
commit c4e3390
Showing
1 changed file
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|