From f2a30422fa2d4c218ee6c002913ae6b0c2dbfbe3 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 19 Apr 2019 15:38:33 +0900 Subject: [PATCH] Added systemd service --- makefile | 8 ++++++++ systemd.service | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 systemd.service diff --git a/makefile b/makefile index 2fb2714c..640aa603 100644 --- a/makefile +++ b/makefile @@ -13,6 +13,7 @@ IP6TABLES=@sudo ip6tables PACK:=$(shell command -v pack 2> /dev/null) RUN:=$(shell command -v run 2> /dev/null) GOIMPORTS:=$(shell command -v goimports 2> /dev/null) +SERVICEFILE=/etc/systemd/system/animenotifier.service # Determine the name of the platform OSNAME= @@ -52,6 +53,13 @@ run: go install github.com/aerogo/run goimports: go install golang.org/x/tools/cmd/goimports +service: + sudo cp systemd.service $(SERVICEFILE) + sudo sed -i "s|MAKEFILE_USER|$(USER)|g" $(SERVICEFILE) + sudo sed -i "s|MAKEFILE_PWD|$(PWD)|g" $(SERVICEFILE) + sudo sed -i "s|MAKEFILE_EXEC|$(PWD)/notify.moe|g" $(SERVICEFILE) + sudo systemctl daemon-reload + @echo -e "\nYou can now start the service using:\n\nsudo systemctl start animenotifier" tools: ifeq ($(OSNAME),OSX) brew install coreutils diff --git a/systemd.service b/systemd.service new file mode 100644 index 00000000..e8248d5f --- /dev/null +++ b/systemd.service @@ -0,0 +1,13 @@ +[Unit] +Description=Anime Notifier +After=network.target + +[Service] +Type=simple +User=MAKEFILE_USER +ExecStart=MAKEFILE_EXEC +WorkingDirectory=MAKEFILE_PWD +Restart=on-failure + +[Install] +WantedBy=multi-user.target \ No newline at end of file