From 1ca52ae8519aadb8ba42f4a7af2b0f13ac6e01ff Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sat, 10 Oct 2020 20:15:01 +0200 Subject: Makefile neu --- .gitignore | 1 + Makefile | 19 +++++++++++++++++++ reboot-if-no-net-connection | 23 ----------------------- reboot-if-no-net-connection.in | 25 +++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 23 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile delete mode 100755 reboot-if-no-net-connection create mode 100755 reboot-if-no-net-connection.in diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2586d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +reboot-if-no-net-connection diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..482c429 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +DESTDIR = +BINDIR = /usr/bin +LIBDIR = /usr/lib + +VERSION = 0.0 + +all: reboot-if-no-net-connection + +%: %.in + sed " \ + s/#VERSION#/$(VERSION)/; \ + " $< > $@ + [ "$@" = "reboot-if-no-net-connection" ] && chmod +x "$@" || true + +.PHONY: install + +install: all + install -D -m0755 -t $(DESTDIR)$(BINDIR) reboot-if-no-net-connection + install -D -m0644 -t $(DESTDIR)$(LIBDIR)/systemd/system reboot-if-no-net-connection.service reboot-if-no-net-connection.timer diff --git a/reboot-if-no-net-connection b/reboot-if-no-net-connection deleted file mode 100755 index bb8c43d..0000000 --- a/reboot-if-no-net-connection +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -for i in {1..300}; do - - default_gateway=$( - ip route \ - | sed ' - s/^default\s\+\S\+\s\+\(\S\+\)\s.*$/\1/ - t - d - ' - ) - - if [ -n "${default_gateway}" ] \ - && ping -c1 "${default_gateway}" >/dev/null 2>&1; then - exit - fi - - sleep 1 - -done - -reboot diff --git a/reboot-if-no-net-connection.in b/reboot-if-no-net-connection.in new file mode 100755 index 0000000..b1d41fb --- /dev/null +++ b/reboot-if-no-net-connection.in @@ -0,0 +1,25 @@ +#!/bin/bash + +# Version #VERSION# + +for i in {1..300}; do + + default_gateway=$( + ip route \ + | sed ' + s/^default\s\+\S\+\s\+\(\S\+\)\s.*$/\1/ + t + d + ' + ) + + if [ -n "${default_gateway}" ] \ + && ping -c1 "${default_gateway}" >/dev/null 2>&1; then + exit + fi + + sleep 1 + +done + +reboot -- cgit v1.2.3-70-g09d2