aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile9
-rw-r--r--service.m42
2 files changed, 7 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 4f1bb3a..8a2cc17 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+SHELL:=/bin/bash
+
define newsetting
@read -p "$(1) [$(3)]: " thisset ; [[ -z "$$thisset" ]] && echo "$(2) $(3)" >> $(4) || echo "$(2) $$thisset" >> $(4)
endef
@@ -25,6 +27,7 @@ install: etc-services
mkdir -p $(call getsetting,tmp/settings.txt,PATH)/lib
find build/ -type f | while read line; do cp $$line $(call getsetting,tmp/settings.txt,PATH)$$(echo $$line | sed 's/^build//g') ; done
(rm /etc/xinetd.d/quickstat && ln -s $(call getsetting,tmp/settings.txt,PATH)/etc/quickstat /etc/xinetd.d/quickstat) || ln -s $(call getsetting,tmp/settings.txt,PATH)/etc/quickstat /etc/xinetd.d/quickstat
+ chmod +x $(call getsetting,tmp/settings.txt,PATH)/bin/quickstat.sh
etc-services:
[[ -z "$$(grep "$(call getsetting,tmp/settings.txt,PORT)/tcp" /etc/services)" ]] && echo -e "quickstat\t$(call getsetting,tmp/settings.txt,PORT)/tcp\t# Added by quickstat Makefile" >> /etc/services
@@ -48,7 +51,7 @@ clean:
rm -rf build
build/etc/quickstat: build/etc tmp/port.ok tmp/m4.ok
- [[ ! -f build/etc/quickstat ]] && m4 -DPORT=$(call getsetting,tmp/settings.txt,PORT) service.m4 > build/etc/quickstat
+ [[ ! -f build/etc/quickstat ]] && m4 -DPORT=$(call getsetting,tmp/settings.txt,PORT) -DPATH="$(call getsetting,tmp/settings.txt,PATH)" service.m4 > build/etc/quickstat
build/lib/monitors.inc.sh: build/lib
[[ ! -f build/lib/monitors.inc.sh ]] && find ./stats -type f | grep -v '.comments' | awk 'function readfile(file) { save_rs = RS; RS = "^$$"; getline tmp < file; close(file); RS = save_rs; return tmp; } { contents = readfile($$0); comments = readfile($$0 ".comments"); printf("%s\ngen%s() {\n%s}\n\n",comments,gensub(/^.*stats\//,"","g",$$0),contents); }' > build/lib/monitors.inc.sh
@@ -73,10 +76,10 @@ tmp/port.ok: tmp/settings.txt
@[[ -z "$$(grep "$(call getsetting,tmp/settings.txt,PORT)" /etc/services)" ]] && touch tmp/port.ok
build/bin/quickstat.sh: build/bin
- [[ ! -f build/bin/quickstat.sh ]] && (echo "define(\`MONLIST',\`" ; find ./stats -type f | grep -v '.comments$$' | sed 's/^\.\/stats\///g;s/^/gen/g;s/$$/\nprintf ","/g' | sed '$$ d' ; echo "')" ; echo -n "define(\`RESLIST',\`" ; find ./stats | sed 's/^\.//g' | tr '\n' ' ' ; echo "')" ; cat quickstat.m4) | m4 -DROOTDIR=/opt | grep -v '^[ \t]*$$' > build/bin/quickstat.sh
+ [[ ! -f build/bin/quickstat.sh ]] && (echo "define(\`MONLIST',\`" ; find ./stats -type f | grep -v '.comments$$' | sed 's/^\.\/stats\///g;s/^/gen/g;s/$$/\nprintf ","/g' | sed '$$ d' ; echo "')" ; echo -n "define(\`RESLIST',\`" ; find ./stats | sed 's/^\.//g' | tr '\n' ' ' ; echo "')" ; cat quickstat.m4) | m4 -DROOTDIR="$(call getsetting,tmp/settings.txt,PATH)" | grep -v '^[ \t]*$$' > build/bin/quickstat.sh
build:
- [[ ! -d build ]] && mkdir build
+ [[ ! -d ./build ]] && mkdir build
tmp:
[[ ! -d tmp ]] && mkdir tmp
diff --git a/service.m4 b/service.m4
index 2173ac7..9cb6464 100644
--- a/service.m4
+++ b/service.m4
@@ -5,5 +5,5 @@ service quickstat
protocol = tcp
wait = no
user = root
- server = /usr/sbin/quickstat.sh
+ server = PATH/bin/quickstat.sh
}