From 0632591996893fe136a1f2fe44d9b9f404f41f3e Mon Sep 17 00:00:00 2001 From: Harald Pfeiffer Date: Thu, 1 Nov 2018 13:30:58 +0100 Subject: Initial commit --- aux/fett/fett.svg | 1 + aux/git-checkers/.filelistgen-nonsysv | 122 ++++++++++++++++++++++++++++++++++ aux/git-checkers/.readme.md-head | 22 ++++++ aux/git-checkers/.readmegen-debian | 13 ++++ aux/git-checkers/.readmegen-suse | 14 ++++ aux/git-checkers/Makefile.readme | 10 +++ aux/git-checkers/bashlist | 14 ++++ aux/git-checkers/ecmalist | 0 aux/git-checkers/filelistgen | 1 + aux/git-checkers/kornlist | 0 aux/git-checkers/logrotchecker | 16 +++++ aux/git-checkers/makelist | 3 + aux/git-checkers/poshlist | 7 ++ aux/git-checkers/readmegen | 11 +++ aux/git-checkers/sudoerschecker | 9 +++ aux/git-checkers/systemdchecker | 17 +++++ aux/git-checkers/tidylist | 3 + 17 files changed, 263 insertions(+) create mode 100644 aux/fett/fett.svg create mode 100755 aux/git-checkers/.filelistgen-nonsysv create mode 100644 aux/git-checkers/.readme.md-head create mode 100755 aux/git-checkers/.readmegen-debian create mode 100755 aux/git-checkers/.readmegen-suse create mode 100644 aux/git-checkers/Makefile.readme create mode 100644 aux/git-checkers/bashlist create mode 100644 aux/git-checkers/ecmalist create mode 120000 aux/git-checkers/filelistgen create mode 100644 aux/git-checkers/kornlist create mode 100755 aux/git-checkers/logrotchecker create mode 100644 aux/git-checkers/makelist create mode 100644 aux/git-checkers/poshlist create mode 100755 aux/git-checkers/readmegen create mode 100755 aux/git-checkers/sudoerschecker create mode 100755 aux/git-checkers/systemdchecker create mode 100644 aux/git-checkers/tidylist (limited to 'aux') diff --git a/aux/fett/fett.svg b/aux/fett/fett.svg new file mode 100644 index 0000000..4a0ae7c --- /dev/null +++ b/aux/fett/fett.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/aux/git-checkers/.filelistgen-nonsysv b/aux/git-checkers/.filelistgen-nonsysv new file mode 100755 index 0000000..a400beb --- /dev/null +++ b/aux/git-checkers/.filelistgen-nonsysv @@ -0,0 +1,122 @@ +#!/bin/bash + +RETVAL=0 +declare -x NCURSINST SCDIR GROOTDIR BASHLIST KORNLIST ECMALIST TIDYLIST +command -v tput >/dev/null 2>&1&&NCURSINST=1||NCURSINST=0 +SCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# I AM G(IT)ROOT! +GROOTDIR="$(git rev-parse --show-toplevel)"||exit 1 +BASHLIST="$GROOTDIR/aux/git-checkers/bashlist" +KORNLIST="$GROOTDIR/aux/git-checkers/kornlist" +POSHLIST="$GROOTDIR/aux/git-checkers/poshlist" +ECMALIST="$GROOTDIR/aux/git-checkers/ecmalist" +TIDYLIST="$GROOTDIR/aux/git-checkers/tidylist" +MAKELIST="$GROOTDIR/aux/git-checkers/makelist" + +function initmimick { + [ -z "$1" ]&&echo "crit_fail in initmimick(): no parameter passed" >&2&&exit 1 + [ -z "$2" ]&&echo "crit_fail in initmimick(): no string passed" >&2&&exit 2 + case "$1" in + 0) + echo -en "\\033[999D";echo -en "\\033[K" + case "$NCURSINST" in + 1)echo -en "[ $(tput setaf 2)$(tput bold)OK$(tput sgr0) ] $2.";; + *)echo -en "[ OK ] $2.";; + esac + echo " $3" + ;; + *) + echo -en "\\033[999D";echo -en "\\033[K" + case "$NCURSINST" in + 1)echo -en "[ $(tput setaf 1)$(tput bold)FAIL$(tput sgr0) ] $2:";; + *)echo -en "[ FAIL ] $2:";; + esac + echo " $3" + ;; + esac +} +STAGECMD="Generating Bash code list" +echo -n "[....] $STAGECMD" +if [ "$(find "$GROOTDIR" -type f -exec file '{}' \;|grep Bourne-Again|grep -vE "tmp/|aux/github-markdown"|sed "s|:.*||g;s|$GROOTDIR/||g"|grep -vcP "$(tr '\n' '|' < "$GROOTDIR/.gitignore"|sed 's/|$//g')")" -gt 0 ];then + if [ -e "$GROOTDIR/.gitignore" ];then + find "$GROOTDIR" -type f -exec file '{}' \;|grep Bourne-Again|grep -vE "tmp/|aux/github-markdown"|sed "s|:.*||g;s|$GROOTDIR/||g"|grep -vP "$(tr '\n' '|' < "$GROOTDIR/.gitignore"|sed 's/|$//g')" > "$BASHLIST" + else + find "$GROOTDIR" -type f -exec file '{}' \;|grep Bourne-Again|grep -vE "tmp/|aux/github-markdown"|sed "s|:.*||g;s|$GROOTDIR/||g"> "$BASHLIST" + fi +else + true>"$BASHLIST" +fi +CRETVAL="$?" +case "$CRETVAL" in + 0) initmimick 0 "$STAGECMD" "...$(wc -l "$BASHLIST"|awk '{print $1}') found";; + *) initmimick 1 "$STAGECMD" "...$(wc -l "$BASHLIST"|awk '{print $1}') found";((++RETVAL));; +esac +STAGECMD="Generating KSH code list" +echo -n "[....] $STAGECMD" +if [ "$(find "$GROOTDIR" -type f -exec file '{}' \;|grep Korn\ shell|grep -vE "/tmp/|aux/github-markdown"|sed "s|:.*||g;s|$GROOTDIR/||g"|grep -vcP "$(tr '\n' '|' < "$GROOTDIR/.gitignore"|sed 's/|$//g')")" -gt 0 ];then + if [ -e "$GROOTDIR/.gitignore" ];then + find "$GROOTDIR" -type f -exec file '{}' \;|grep Korn\ shell|grep -vE "/tmp/|aux/github-markdown"|sed "s|:.*||g;s|$GROOTDIR/||g"|grep -vP "$(tr '\n' '|' < "$GROOTDIR/.gitignore"|sed 's/|$//g')" > "$KORNLIST" + else + find "$GROOTDIR" -type f -exec file '{}' \;|grep Korn\ shell|grep -vE "/tmp/|aux/github-markdown"|sed "s|:.*||g;s|$GROOTDIR/||g" > "$KORNLIST" + fi +else + true>"$KORNLIST" +fi +CRETVAL="$?" +case "$CRETVAL" in + 0) initmimick 0 "$STAGECMD" "...$(wc -l "$KORNLIST"|awk '{print $1}') found";; + *) initmimick 1 "$STAGECMD" "...$(wc -l "$KORNLIST"|awk '{print $1}') found";((++RETVAL));; +esac +STAGECMD="Generating POSIX shell code list" +echo -n "[....] $STAGECMD" +if [ "$(find "$GROOTDIR" -type f -exec file '{}' \;|grep POSIX\ shell|grep -vE "/tmp/|aux/github-markdown|\.git/"|sed "s|:.*||g;s|$GROOTDIR/||g"|grep -vcP "$(tr '\n' '|' < "$GROOTDIR/.gitignore"|sed 's/|$//g')")" -gt 0 ];then + if [ -e "$GROOTDIR/.gitignore" ];then + find "$GROOTDIR" -type f -exec file '{}' \;|grep POSIX\ shell|grep -vE "/tmp/|aux/github-markdown|\.git/"|sed "s|:.*||g;s|$GROOTDIR/||g"|grep -vP "$(tr '\n' '|' < "$GROOTDIR/.gitignore"|sed 's/|$//g')" > "$POSHLIST" + else + find "$GROOTDIR" -type f -exec file '{}' \;|grep POSIX\ shell|grep -vE "/tmp/|aux/github-markdown|\.git/"|sed "s|:.*||g;s|$GROOTDIR/||g" > "$POSHLIST" + fi +else + true>"$POSHLIST" +fi +CRETVAL="$?" +case "$CRETVAL" in + 0) initmimick 0 "$STAGECMD" "...$(wc -l "$POSHLIST"|awk '{print $1}') found";; + *) initmimick 1 "$STAGECMD" "...$(wc -l "$POSHLIST"|awk '{print $1}') found";((++RETVAL));; +esac +STAGECMD="Generating ECMA script list" +echo -n "[....] $STAGECMD" +if [ "$(find "$GROOTDIR" -type f -name "*.js"|sed "s|$GROOTDIR/||g"|grep -vcE "/tmp/")" -gt 0 ];then + find "$GROOTDIR" -type f -name "*.js"|sed "s|$GROOTDIR/||g"|grep -vE "/tmp/" > "$ECMALIST" 2>/dev/null +else + true>"$ECMALIST" +fi +CRETVAL="$?" +case "$CRETVAL" in + 0) initmimick 0 "$STAGECMD" "...$(wc -l "$ECMALIST"|awk '{print $1}') found";; + *) initmimick 1 "$STAGECMD" "...$(wc -l "$ECMALIST"|awk '{print $1}') found";((++RETVAL));; +esac +STAGECMD="Generating PHP and HTML code list" +echo -n "[....] $STAGECMD" +if [ "$(find "$GROOTDIR" -type f -exec file '{}' \;|grep -E 'PHP script|HTML document'|sed "s|:.*||g;s|$GROOTDIR/||g"|wc -l)" -gt 0 ];then + find "$GROOTDIR" -type f -exec file '{}' \;|grep -E 'PHP script|HTML document'|sed "s|:.*||g;s|$GROOTDIR/||g" > "$TIDYLIST" 2>/dev/null +else + true>"$TIDYLIST" +fi +CRETVAL="$?" +case "$CRETVAL" in + 0) initmimick 0 "$STAGECMD" "...$(wc -l "$TIDYLIST"|awk '{print $1}') found";; + *) initmimick 1 "$STAGECMD" "...$(wc -l "$TIDYLIST"|awk '{print $1}') found";((++RETVAL));; +esac +STAGECMD="Generating Makefile code list" +echo -n "[....] $STAGECMD" +if [ "$(find "$GROOTDIR" -type f -exec file '{}' \;|grep makefile\ script|sed "s|:.*||g;s|$GROOTDIR/||g"|wc -l)" -gt 0 ];then + find "$GROOTDIR" -type f -exec file '{}' \;|grep makefile\ script|sed "s|:.*||g;s|$GROOTDIR/||g" > "$MAKELIST" +else + true>"$MAKELIST" +fi +CRETVAL="$?" +case "$CRETVAL" in + 0) initmimick 0 "$STAGECMD" "...$(wc -l "$MAKELIST"|awk '{print $1}') found";; + *) initmimick 1 "$STAGECMD" "...$(wc -l "$MAKELIST"|awk '{print $1}') found";((++RETVAL));; +esac +exit $RETVAL diff --git a/aux/git-checkers/.readme.md-head b/aux/git-checkers/.readme.md-head new file mode 100644 index 0000000..6435b70 --- /dev/null +++ b/aux/git-checkers/.readme.md-head @@ -0,0 +1,22 @@ +META LAYER +========== + +Meta layer here means: this is a git folder about its git repository. Here I'll +explicitly push the code with which I administer my git folders. + +Τα [**μεταδεδομένα**] (https://el.wikipedia.org/wiki/%CE%9C%CE%B5%CF%84%CE%B1%CE%B4%CE%B5%CE%B4%CE%BF%CE%BC%CE%AD%CE%BD%CE%B1) (μετάφραση του όρου metadata, ο οποίος σχηματίζεται από την ελληνική λέξη μετά και τη λατινική λέξη data "δεδομένα") είναι δεδομένα τα οποία περιγράφουν άλλα δεδομένα. + +Content +------- + +* ***Makefile*** for the folder itself building up a readme, prose goes in +.readme-head and **README.md** will then be **generated with a file list with +http links**. +Currently only works with my aniline repository, abstraction will follow. +* ***filelistgen*** which generates "bashlist" and "kornlist", lists of shell scripts which will then be parsed through gitlab CI runner scripts to ensure validity (not in terms of commands but in case of abstract shell code) +* ***logrotchecker*** and ***sudoerschecker*** which will be used to parse logrotate and sudoers files in a gitlab CI runner to ensure their basical validity +* ***.gitlab-ci.yml*** - Gitlab YAML to trigger all CI runner checks, including all of the above plus a Makefile checker for the root directory's Makefile + +Files +----- + diff --git a/aux/git-checkers/.readmegen-debian b/aux/git-checkers/.readmegen-debian new file mode 100755 index 0000000..e44d915 --- /dev/null +++ b/aux/git-checkers/.readmegen-debian @@ -0,0 +1,13 @@ +#!/bin/bash + +. /lib/lsb/init-functions +log_begin_msg "Generating Readme.md" +cat .readme.md-head>README.md +[ "$?" -ne 0 ]&&log_end_msg 1&&exit 1 +# @echo '```'>>README.md +tree -f "$(pwd)" >> README.md +[ "$?" -ne 0 ]&&log_end_msg 1&&exit 1 +./urlinjector README.md +[ "$?" -ne 0 ]&&log_end_msg 1&&exit 1 +# @echo '```'>>README.md +log_end_msg 0&&exit 0 diff --git a/aux/git-checkers/.readmegen-suse b/aux/git-checkers/.readmegen-suse new file mode 100755 index 0000000..06af767 --- /dev/null +++ b/aux/git-checkers/.readmegen-suse @@ -0,0 +1,14 @@ +#!/bin/bash + +. /lib/lsb/init-functions +rc_reset +echo -n "Generating Readme.md" +cat .readme.md-head>README.md +[ "$?" -ne 0 ]&&(false;rc_status -v)&&exit 1 +# @echo '```'>>README.md +tree -f "$(pwd)" >> README.md +[ "$?" -ne 0 ]&&(false;rc_status -v)&&exit 1 +./urlinjector README.md +[ "$?" -ne 0 ]&&(false;rc_status -v)&&exit 1 +# @echo '```'>>README.md +rc_status -v&&exit 0 diff --git a/aux/git-checkers/Makefile.readme b/aux/git-checkers/Makefile.readme new file mode 100644 index 0000000..094b651 --- /dev/null +++ b/aux/git-checkers/Makefile.readme @@ -0,0 +1,10 @@ +VERSION = 3.81 + +all: tree + +tree: tree-exists + @./readmegen +readme: tree + +tree-exists: + @command -v tree >/dev/null 2>&1 diff --git a/aux/git-checkers/bashlist b/aux/git-checkers/bashlist new file mode 100644 index 0000000..4632cb1 --- /dev/null +++ b/aux/git-checkers/bashlist @@ -0,0 +1,14 @@ +aux/git-checkers/.readmegen-suse +aux/git-checkers/sudoerschecker +aux/git-checkers/.readmegen-debian +aux/git-checkers/logrotchecker +aux/git-checkers/.filelistgen-nonsysv +aux/git-checkers/readmegen +aux/git-checkers/systemdchecker +localfs/usr/local/bin/virtmc +documentation/aux/block-inventory +documentation/aux/kvm-inventory +documentation/aux/ctrl-c +documentation/aux/git-inventory +documentation/aux/dnf-history +documentation/.update diff --git a/aux/git-checkers/ecmalist b/aux/git-checkers/ecmalist new file mode 100644 index 0000000..e69de29 diff --git a/aux/git-checkers/filelistgen b/aux/git-checkers/filelistgen new file mode 120000 index 0000000..acd0c7a --- /dev/null +++ b/aux/git-checkers/filelistgen @@ -0,0 +1 @@ +.filelistgen-nonsysv \ No newline at end of file diff --git a/aux/git-checkers/kornlist b/aux/git-checkers/kornlist new file mode 100644 index 0000000..e69de29 diff --git a/aux/git-checkers/logrotchecker b/aux/git-checkers/logrotchecker new file mode 100755 index 0000000..4f16efe --- /dev/null +++ b/aux/git-checkers/logrotchecker @@ -0,0 +1,16 @@ +#!/bin/bash + +# No way to push this to gitlab's CI runner YAML for now, so here's the script: +RETVAL=0 + +LOGROTS="$(find . -name "logrotate*" -type d|wc -l)" +[ "$LOGROTS" -eq 0 ]&&echo "No directory with a name starting with logrotate found."&&exit 0 + +for i in $(find . -name "logrotate*" -type d)/*;do + ERRCNT="$(/usr/sbin/logrotate -ds /tmp/logrotcheck "$i" 2>&1|grep '^error:'|grep -vcE 'unknown group|found error')" + echo "$i: $ERRCNT errors" + [ "$ERRCNT" -ne 0 ]&&((++RETVAL)) + continue +done + +exit $RETVAL diff --git a/aux/git-checkers/makelist b/aux/git-checkers/makelist new file mode 100644 index 0000000..f5a5da7 --- /dev/null +++ b/aux/git-checkers/makelist @@ -0,0 +1,3 @@ +aux/git-checkers/Makefile.readme +Makefile +documentation/Makefile diff --git a/aux/git-checkers/poshlist b/aux/git-checkers/poshlist new file mode 100644 index 0000000..425ea9f --- /dev/null +++ b/aux/git-checkers/poshlist @@ -0,0 +1,7 @@ +fakeenv/usr/bin/guestmount +fakeenv/usr/bin/guestunmount +fakeenv/bin/virsh +localfs/usr/local/sbin/brightness-up +localfs/usr/local/sbin/brightness-down +localfs/usr/local/bin/batman +.environ-prep diff --git a/aux/git-checkers/readmegen b/aux/git-checkers/readmegen new file mode 100755 index 0000000..40c2dfa --- /dev/null +++ b/aux/git-checkers/readmegen @@ -0,0 +1,11 @@ +#!/bin/bash + +[ ! -r /etc/os-release ]&&echo "/etc/os-release not readable. Wrong OS or deprecated OS?"&&exit 1 +LOCOS=$(grep ^ID= /etc/os-release |awk -F= '{print $NF}'|tr '[:upper:]' '[:lower:]') + +case $LOCOS in + debian|ubuntu) ./.readmegen-debian;; + *suse|*sles*) ./.readmegen-suse;; + redhat|fedora) echo "Red Hat / Fedora not implemented yet!";exit 1;; + *) echo "Unknown OS!";exit 1;; +esac diff --git a/aux/git-checkers/sudoerschecker b/aux/git-checkers/sudoerschecker new file mode 100755 index 0000000..1d7e7ed --- /dev/null +++ b/aux/git-checkers/sudoerschecker @@ -0,0 +1,9 @@ +#!/bin/bash + +GITROOT="$(git rev-parse --show-toplevel)"||exit 1 +SUDOERSDINV=( $(find "$GITROOT" -name sudoers.d -type d) ) +SUDOERSD=1 +[ "${#SUDOERSDINV[@]}" -eq 0 ]&&echo "No directory called sudoers.d found."&&SUDOERSD=0 + +[ "$SUDOERSD" -eq 1 ]&&for i in "${SUDOERSDINV[@]}"/*;do /usr/sbin/visudo -cf "$i";done +find "$GITROOT" -name sudoers -type f -exec /usr/sbin/visudo -cf '{}' \; diff --git a/aux/git-checkers/systemdchecker b/aux/git-checkers/systemdchecker new file mode 100755 index 0000000..85cb24e --- /dev/null +++ b/aux/git-checkers/systemdchecker @@ -0,0 +1,17 @@ +#!/bin/bash + +GITROOT="$(git rev-parse --show-toplevel)"||exit 1 + +echo -n "Locating systemd units..." +SVCFILES=( $(find "$GITROOT" -name "*.service" -exec grep -l '\[Unit\]' '{}' \;) ) +TGTFILES=( $(find "$GITROOT" -name "*.target" -exec grep -l '\[Unit\]' '{}' \;) ) +TMRFILES=( $(find "$GITROOT" -name "*.timer" -exec grep -l '\[Unit\]' '{}' \;) ) +MNTFILES=( $(find "$GITROOT" -name "*.mount" -exec grep -l '\[Unit\]' '{}' \;) ) +SYSTEMDFILES=( ${SVCFILES[@]} ${TGTFILES[@]} ${TMRFILES[@]} ${MNTFILES[@]} ) +echo " found ${#SYSTEMDFILES[@]} unit$([ "${#SYSTEMDFILES[@]}" -gt 1 ]&&echo -n "s") to check." + +export LOOPRV=0 +for i in "${SYSTEMDFILES[@]}";do + systemd-analyze verify "$i"&&echo "$i: $(tput -Txterm smul)OK$(tput -Txterm rmul)"||((++LOOPRV)) +done +exit $LOOPRV diff --git a/aux/git-checkers/tidylist b/aux/git-checkers/tidylist new file mode 100644 index 0000000..05b9997 --- /dev/null +++ b/aux/git-checkers/tidylist @@ -0,0 +1,3 @@ +localfs/var/www/vhosts/jango104.domain.de/index.html +documentation/kvm-details/domain-arch.xml +documentation/kvm-details/domain-jango105.xml -- cgit v1.2.3