Add grow system service

This commit is contained in:
Phil Howard
2020-09-08 16:56:50 +01:00
parent 31bf595853
commit 9492c0baf3
3 changed files with 68 additions and 0 deletions

14
service/README.md Normal file
View File

@@ -0,0 +1,14 @@
# Grow Service
This script will install Grow as a service on your Raspberry Pi, allowing it to run from boot and recover from errors.
# Useful Commands
* View service status: `systemctl status grow-monitor`
* Stop service: `sudo systemctl stop grow-monitor`
* Start service: `sudo systemctl start grow-monitor`
* View full debug/error output: `journalctl --no-pager --unit grow-monitor`
# Configuring Grow
You can configure grow using the on-screen UI, or by editing the settings in `/etc/default/grow`

View File

@@ -0,0 +1,14 @@
[Unit]
Description=Grow Monitoring Service
After=multi-user.target
[Service]
Type=simple
WorkingDirectory=/usr/share/grow-monitor
ExecStart=/usr/bin/grow-monitor /etc/default/grow
Restart=on-failure
StandardOutput=syslog+console
StandardError=syslog+console
[Install]
WantedBy=multi-user.target

40
service/install.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
user_check() {
if [ $(id -u) -ne 0 ]; then
printf "Script must be run as root. Try 'sudo ./install.sh'\n"
exit 1
fi
}
success() {
echo -e "$(tput setaf 2)$1$(tput sgr0)"
}
inform() {
echo -e "$(tput setaf 6)$1$(tput sgr0)"
}
warning() {
echo -e "$(tput setaf 1)$1$(tput sgr0)"
}
user_check
inform "Copying icons to /usr/share/grow-monitor...\n"
mkdir -p /usr/share/grow-monitor/icons
cp ../examples/icons/* /usr/share/grow-monitor/icons
inform "Installing grow-monitor to /usr/bin/grow-monitor...\n"
cp ../examples/monitor.py /usr/bin/grow-monitor
chmod +x /usr/bin/grow-monitor
inform "Installing settings to /etc/default/grow...\n"
cp ../examples/settings.yml /etc/default/grow
inform "Installing systemd service...\n"
cp grow-monitor.service /etc/systemd/system/
systemctl reenable grow-monitor.service
systemctl start grow-monitor.service
inform "\nTo see grow debug output, run: \"journalctl --no-pager --unit grow-monitor\"\n"