From fe5e1099ae5b010ee16e050198db041da50f35da Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 8 Jan 2018 09:26:49 +0100 Subject: Makefile --- .gitignore | 2 ++ Makefile | 57 ++++++++++++++++++++++++++++++++++++ check-kernel | 43 --------------------------- check-kernel.in | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 150 insertions(+), 43 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile delete mode 100755 check-kernel create mode 100644 check-kernel.in diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e1d00b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.1 +check-kernel diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..83a64e4 --- /dev/null +++ b/Makefile @@ -0,0 +1,57 @@ +# +# check-kernel - check if the installed kernel is currently running +# +# Copyright (c) 2018 Erich Eckner +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +# USA. +# + +DESTDIR = +ETCDIR = /etc +BINDIR = /usr/bin +MANDIR = /usr/share/man + +VERSION = 0.0 + +all: check-kernel + +%: %.in + sed " \ + s/#VERSION#/$(VERSION)/; \ + s@#BINDIR#@$(BINDIR)@; \ + s@#ETCDIR#@$(ETCDIR)@; \ + s@#HELPTEXT#\(\s\+\)#@ --help \1display this help and exit\n --version\1display version and exit@; \ + " $< > $@ + [ "$@" = "check-kernel" ] && chmod +x "$@" || true + +.PHONY: install dist clean + +install: all + install -D -m0755 check-kernel $(DESTDIR)$(BINDIR)/check-kernel + +clean: + ls -A | \ + grep "^\($(shell sed 's|\.|\\.|; s|\*|.*|; s|$$|\\|' .gitignore | tr '\n' '\|')\)\$$" | \ + xargs -r rm + +dist: clean + git status --porcelain 2> /dev/null | grep -q "\S" && (git add .; git commit -m"neue Version: $(VERSION)") || true + ! git tag -d v$(VERSION) 2> /dev/null + git tag v$(VERSION) + git push + git push --tags + +# End of file diff --git a/check-kernel b/check-kernel deleted file mode 100755 index 5370f49..0000000 --- a/check-kernel +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -if which pacman >/dev/null 2>&1; then - # arch linux - running=$( - uname -r | \ - sed ' - s|-ARCH$|| - ' - ) - installed=$( - pacman -Q linux | \ - cut -d' ' -f2 - ) -elif which apt >/dev/null 2>&1; then - # debian - running=$( - uname -r - ) - installed=$( - dpkg-query -W 'linux-image-*-?86' | \ - cut -f1 | \ - sed ' - s|^linux-image-|| - ' | \ - sort -V | \ - tail -n1 - ) -else - >&2 printf 'Cannot determin installed kernel.\n' - exit 2 -fi - -if [ "${running}" = "${installed}" ]; then - >&2 printf 'The installed kernel (%s) is currently running.\n' \ - "${installed}" - exit 0 -else - >&2 printf 'The installed (%s) and running kernel (%s) differ.\n' \ - "${installed}" \ - "${running}" - exit 1 -fi diff --git a/check-kernel.in b/check-kernel.in new file mode 100644 index 0000000..2354345 --- /dev/null +++ b/check-kernel.in @@ -0,0 +1,91 @@ +#!/bin/sh + +# check-kernel #VERSION# + +verwendung() { + >&2 echo 'check-kernel checks if the installed kernel is currently running' + >&2 echo '' + >&2 echo 'Usage: sendmailadvanced [OPTIONS]' + >&2 echo ' -r,--reboot reboot system if installed kernel is not yet running' + >&2 echo \ +'#HELPTEXT# #' + exit 1 +} + +eval set -- "$( + getopt -o eh:i:st \ + --long encrypt \ + --long help \ + --long version \ + -n "$(basename "$0")" -- "$@" \ + || echo verwendung +)" + +reboot=false +while true; do + case "$1" in + -r|--reboot) + shift + reboot=true + ;; + --help) + verwendung 0 + ;; + --version) + echo '#VERSION#' + exit 0 + ;; + --) + shift + break + ;; + *) + >&2 echo "FEHLER: Verstehe Option \"$1\" doch nicht! Ich beende." + verwendung + ;; + esac + shift +done + + +if which pacman >/dev/null 2>&1; then + # arch linux + running=$( + uname -r | \ + sed ' + s|-ARCH$|| + ' + ) + installed=$( + pacman -Q linux | \ + cut -d' ' -f2 + ) +elif which apt >/dev/null 2>&1; then + # debian + running=$( + uname -r + ) + installed=$( + dpkg-query -W 'linux-image-*-?86' | \ + cut -f1 | \ + sed ' + s|^linux-image-|| + ' | \ + sort -V | \ + tail -n1 + ) +else + >&2 printf 'Cannot determin installed kernel.\n' + exit 2 +fi + +if [ "${running}" = "${installed}" ]; then + >&2 printf 'The installed kernel (%s) is currently running.\n' \ + "${installed}" + exit 0 +else + >&2 printf 'The installed (%s) and running kernel (%s) differ.\n' \ + "${installed}" \ + "${running}" + exit 1 +fi -- cgit v1.2.3-54-g00ecf