From ddc75880ed9e1f5d5bd4ca9ae38ee5959f4504bd Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Tue, 10 Mar 2020 05:33:12 +0100 Subject: [PATCH 1/5] Change config and bin dirs --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 59226a7..bdded0f 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ # Copyright (c) 2017 by Thomas A. Early N7TAE # if you change these locations, make sure the sgs-xl.service file is updated! -BINDIR=/usr/local/bin -CFGDIR=/usr/local/etc +BINDIR=/usr/sbin +CFGDIR=/etc/sgs-xl # choose this if you want debugging help #CPPFLAGS=-g -ggdb -W -Wall -std=c++11 -DCFG_DIR=\"$(CFGDIR)\" From 2953ce49ec7edecbe3dd0dddad8009768b94a9b2 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Tue, 10 Mar 2020 06:00:34 +0100 Subject: [PATCH 2/5] No manual editing of service file requred. Start service after network. --- Makefile | 4 +++- sgs-xl.service | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index bdded0f..dd4a912 100644 --- a/Makefile +++ b/Makefile @@ -32,9 +32,11 @@ newhostfiles : /usr/bin/wget http://www.pistar.uk/downloads/DCS_Hosts.txt && sudo /bin/mv -f DCS_Hosts.txt $(CFGDIR) install : sgs-xl + /bin/mkdir -p $(CFGDIR) /bin/cp -f sgs-xl.cfg $(CFGDIR) /bin/cp -f sgs-xl $(BINDIR) /bin/cp -f sgs-xl.service /lib/systemd/system + /usr/bin/sed -i "s|REPLACEME|/usr/sbin/sgs-xl /etc/sgs-xl/sgs-xl.cfg|g" /lib/systemd/system/sgs-xl.service systemctl enable sgs-xl.service systemctl daemon-reload systemctl start sgs-xl.service @@ -45,7 +47,7 @@ uninstall : /bin/rm -f /lib/systemd/system/sgs-xl.service systemctl daemon-reload /bin/rm -f $(BINDIR)/sgs-xl - /bin/rm -f $(CFGDIR)/sgs-xl.cfg + /bin/rm -rf $(CFGDIR) removehostfiles : /bin/rm -f $(CFGDIR)/DExtra_Hosts.txt diff --git a/sgs-xl.service b/sgs-xl.service index ba13702..a750966 100644 --- a/sgs-xl.service +++ b/sgs-xl.service @@ -1,10 +1,11 @@ [Unit] Description=Smart Group Server -After=systemd-user-session.service +After=network-online.target +Wants=network-online.target [Service] Type=simple -ExecStart=/usr/local/bin/sgs /usr/local/etc/sgs.cfg +ExecStart=REPLACEME [Install] WantedBy=multi-user.target From 94e82101adb31a4235843c254fe9c345c5198c5c Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Tue, 10 Mar 2020 06:05:26 +0100 Subject: [PATCH 3/5] No longer downloading hostfiles to /usr/bin Also download host files during install --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index dd4a912..975009d 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,6 @@ sgs-xl : GitVersion.h $(OBJS) g++ $(CPPFLAGS) -MMD -MD -c $< -o $@ .PHONY: clean - clean: $(RM) GitVersion.h $(OBJS) $(DEPS) sgs-xl @@ -28,10 +27,11 @@ clean: # install, uninstall and removehostfiles need root priviledges newhostfiles : - /usr/bin/wget http://www.pistar.uk/downloads/DExtra_Hosts.txt && sudo /bin/mv -f DExtra_Hosts.txt $(CFGDIR) - /usr/bin/wget http://www.pistar.uk/downloads/DCS_Hosts.txt && sudo /bin/mv -f DCS_Hosts.txt $(CFGDIR) + /bin/mkdir -p $(CFGDIR) + /usr/bin/wget -O $(CFGDIR)/DExtra_Hosts.txt http://www.pistar.uk/downloads/DExtra_Hosts.txt + /usr/bin/wget -O $(CFGDIR)/DCS_Hosts.txt http://www.pistar.uk/downloads/DCS_Hosts.txt -install : sgs-xl +install : newhostfiles sgs-xl /bin/mkdir -p $(CFGDIR) /bin/cp -f sgs-xl.cfg $(CFGDIR) /bin/cp -f sgs-xl $(BINDIR) From 7aed6cb9c50509beb92a3e73814a3e50732b6005 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Tue, 10 Mar 2020 06:08:14 +0100 Subject: [PATCH 4/5] Add PHONY where required --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 975009d..23951cd 100644 --- a/Makefile +++ b/Makefile @@ -26,11 +26,13 @@ clean: -include $(DEPS) # install, uninstall and removehostfiles need root priviledges +.PHONY: newhostfiles newhostfiles : /bin/mkdir -p $(CFGDIR) /usr/bin/wget -O $(CFGDIR)/DExtra_Hosts.txt http://www.pistar.uk/downloads/DExtra_Hosts.txt /usr/bin/wget -O $(CFGDIR)/DCS_Hosts.txt http://www.pistar.uk/downloads/DCS_Hosts.txt +.PHONY: install install : newhostfiles sgs-xl /bin/mkdir -p $(CFGDIR) /bin/cp -f sgs-xl.cfg $(CFGDIR) @@ -41,6 +43,7 @@ install : newhostfiles sgs-xl systemctl daemon-reload systemctl start sgs-xl.service +.PHONY: uninstall uninstall : systemctl stop sgs-xl.service systemctl disable sgs-xl.service @@ -49,6 +52,7 @@ uninstall : /bin/rm -f $(BINDIR)/sgs-xl /bin/rm -rf $(CFGDIR) +.PHONY: removehostfiles removehostfiles : /bin/rm -f $(CFGDIR)/DExtra_Hosts.txt /bin/rm -f $(CFGDIR)/DCS_Hosts.txt From 8935623381306eb4d93de07657f383592ec942be Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Tue, 10 Mar 2020 06:14:14 +0100 Subject: [PATCH 5/5] Always regenerate GitVersion.h --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 23951cd..dfbc010 100644 --- a/Makefile +++ b/Makefile @@ -57,9 +57,13 @@ removehostfiles : /bin/rm -f $(CFGDIR)/DExtra_Hosts.txt /bin/rm -f $(CFGDIR)/DCS_Hosts.txt -GitVersion.h: +GitVersion.h: force ifneq ("$(wildcard .git/index)","") echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@ else echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@ endif + +.PHONY: force +force: + @true \ No newline at end of file