From 15a5429ac019b6cab83321f820949df57cc82931 Mon Sep 17 00:00:00 2001 From: Lukas Macura Date: Mon, 4 Apr 2016 13:59:26 +0200 Subject: [PATCH] Added example plugins --- fsx/control.zaf | 104 ++++++++++++++++++++++++++++++++++++++++++++ openssh/control.zaf | 67 ++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+) create mode 100644 fsx/control.zaf create mode 100644 openssh/control.zaf diff --git a/fsx/control.zaf b/fsx/control.zaf new file mode 100644 index 0000000..385dd14 --- /dev/null +++ b/fsx/control.zaf @@ -0,0 +1,104 @@ + +Plugin: fsx +Description:: + Plugin which will make deeper look into directory structure using discovery +:: + +Version: 0.1 +Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/fsx +Web: https://github.com/limosek/zaf-plugins/ +Maintainer: Lukas Macura + +# Dependencies +Depends-dpkg: dash curl +Depens-opkg: busybox curl +Depends-rpm: curl +Depends-bin: curl find + +Item discovery: +Description:: + Discovery of files or directories +:: +Parameters: directory mask type depth +Type: string +Script:: +#!/bin/sh + +. $ZAF_LIB_DIR/preload.sh + +[ -z "$1" ] && zaf_err "Directory must be entered." +dir="$1" + +if [ -n "$2" ]; then + mask="-name '$2'" +fi + +if [ -n "$3" ]; then + type="-type $3" +fi + +if [ -n "$4" ]; then + depth="-maxdepth $4" +fi + +zaf_dbg find "$dir" $type $depth $mask +eval find "$dir" $depth $type $mask | zaf_discovery '{#PATH}' + +:: +/Item + +Item pathinfo_type: +Description:: + Type of discovered path (d,f,l) + d - directory + f - file + l - symbolink link +:: +Parameters: discovered_path +Type: character +Script:: + +. $ZAF_LIB_DIR/preload.sh + +[ -z "$1" ] && zaf_err "Directory must be entered." + +[ -f "$1" ] && echo f && exit +[ -d "$1" ] && echo d && exit +[ -l "$1" ] && echo l && exit + +:: +/Item: + +Item pathinfo_du: +Description:: + Disk usage of discovered path in bytes +:: +Parameters: discovered_path +Type: integer +Script:: + +. $ZAF_LIB_DIR/preload.sh + +[ -z "$1" ] && zaf_err "Directory must be entered." + +du -sb "$1" | (read sum dir; echo $sum) +:: +/Item: + +Item pathinfo_items: +Description:: + Number of items in discovered path (dirs+files+rest) +:: +Parameters: discovered_path +Type: integer +Script:: + +. $ZAF_LIB_DIR/preload.sh + +[ -z "$1" ] && zaf_err "Directory must be entered." + +ls -1 "$1" |wc -l +:: +/Item: + + diff --git a/openssh/control.zaf b/openssh/control.zaf new file mode 100644 index 0000000..46ce48b --- /dev/null +++ b/openssh/control.zaf @@ -0,0 +1,67 @@ + +Plugin: openssh +Description:: + Plugin which will discover openssh config options and will return their values. +:: + +Version: 0.1 +Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/openssh +Web: https://github.com/limosek/zaf-plugins/ +Maintainer: Lukas Macura + +# Dependencies +Depends-dpkg: dash +Depens-opkg: busybox +Depends-rpm: grep +Depends-bin: grep tr + +Item discovery: +Description:: + Discovery of enabled openssh config options +:: +Type: script +Parameters: sshd_config_file +Script:: +#!/bin/sh + +. $ZAF_LIB_DIR/preload.sh + + if [ -n "$1" ]; then + cfg="$1" + else + cfg=/etc/ssh/sshd_config + fi + + grep -v '^#' "$cfg" | tr -s '\n' | \ + while read opt; do + [ -n "$opt" ] && echo $opt + done | zaf_discovery '{#OPTION}' +:: +/Item + +Item option_value: +Description:: + Value of enabled openssh config option +:: +Parameters: sshd_config_file optionname +Type: string +Script:: +#!/bin/sh + +. $ZAF_LIB_DIR/preload.sh + + if [ -n "$2" ]; then + cfg="$1" + opt="$2" + shift + else + cfg=/etc/ssh/sshd_config + opt="$1" + fi + + [ -n "$opt" ] && { grep "^$opt " $cfg | cut -d ' ' -f 2- ; } || zaf_err "OptionName missing" +:: +/Item + + +