From 07c91a937e22814b85089dbbbcf543d331107d9b Mon Sep 17 00:00:00 2001 From: ub1x Date: Sun, 31 Oct 2021 01:14:10 +0200 Subject: [PATCH] Added two additional scripts as example (see also ) --- README.md | 4 ++-- diskfree.sh | 38 ++++++++++++++++++++++++++++++++++++++ jpg-add-comment.sh | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100755 diskfree.sh create mode 100644 jpg-add-comment.sh diff --git a/README.md b/README.md index 10ebe7f..290394a 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,6 @@ My personally used scripts |Script|Description| |---|---| |[duc-index.sh](duc-index.sh)|Script to be added e.g. as cronjob, which generate an index w/o nfs and dfs filesystem mounted files| - - +|[diskfree.sh](diskfree.sh)|Script shows the free memory of all mounted filesystems beside *tmpfs| +|[jpg-add-comment.sh](jpg-add-comment.sh)|Add a comment in all *.jpg files in the actuall and all subfolders| diff --git a/diskfree.sh b/diskfree.sh new file mode 100755 index 0000000..12bfe3d --- /dev/null +++ b/diskfree.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# df with some options and colored if Alert levels are exceeded +# (c) GPL by Ulf Bartolomäus +VERSION="Version 0.1.1 from 13.02.2021" + +# 0.1.1 +# Initial based on whatch_new + +MyDfC='df -hTx tmpfs -x devtmpfs' ## df - command - w/o *tenpfs +MyDfCnN='df -hTx tmpfs -x devtmpfs -x fuse -x nfs4' ## df - command - w/o *tenpfs, fusa and nfs4 +#MyDfC="${MyDfCnN}" ## zweite verusion statt erste +MyDfAlert1=80 ## alert level of df +MyDfAlert2=90 ## critical alert level of df + +## Escape secences for color +esc=$(echo -en "\033") ## define esc secence +dick="${esc}[1m" ## define bold secence +rot="${esc}[1;31m" ## define red secence +gruen="${esc}[1;32m" ## define green secence +gelb="${esc}[1;33m" ## define yelow secence +blau="${esc}[1;34m" ## define blue secence +lila="${esc}[1;35m" ## define purple secence +norm=$(echo -en "${esc}[m\017") ## define default secence + +## DiskFree (only if not the same device => uniq check first 40 characters +${MyDfC} | uniq -w40 | while read MyOutput; do ## Execute df and filter doublicates - for each row stored in MyOutput + MyDfUsage=$(echo ${MyOutput} | awk '{ print $6}' | cut -d'%' -f1 ) ## Search Usage in % + if [[ ! $( echo "${MyDfUsage}" | grep [[:digit:]] ) ]] ; then ## If first row + echo -e ${dick}"${MyOutput}"${norm} ## Echo in bold + elif [ $(( ${MyDfUsage} )) -ge ${MyDfAlert2} ]; then ## If critical level excided + echo -e ${rot}"${MyOutput}"${norm} ## Echo in red + elif [ $(( ${MyDfUsage} )) -ge ${MyDfAlert1} ]; then ## If alert level excided + echo -e ${gelb}"${MyOutput}"${norm} ## Echo in yelow + else ## default + echo -e ${gruen}"${MyOutput}"${norm} ## Echo in green + fi +done diff --git a/jpg-add-comment.sh b/jpg-add-comment.sh new file mode 100644 index 0000000..5783867 --- /dev/null +++ b/jpg-add-comment.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Add a exif-comment to all JPEG-Files from this directory and all subdirectorys +# +# (c) LUG-VS (GPL) +VERSION="make_exif-name.sh Version 0.0.2 from 23.10.2005" +# +# Input: comment text +# Output: changed files +# +# Changes: +# 0.0.2: comment as parameter from commandline +# 0.0.1: generation +# + +COMMENTSTEXT=$* +JPEGFILEFILTER=*.jpg + +# trap is executed if script breaks +trap "echo '*** TRAP ***' ; exit" ERR + +# check if command exists else break +which exiftran > /dev/null || echo "exiftran not found!" || exit; + +echo "Write Comment: <"${COMMENTSTEXT}">" +# for each file in JPEGFILEFILTER do +# exiftran - transform digital camera jpeg images and use the libexif-Library +# -i Enable inplace editing of the images. +# -b Create a backup file when doing inplace editing. +# -p Preserve timestamps (atime + mtime) when doing inplace editing. +# -c Set jpeg comment tag to . +find . -type f -name "${JPEGFILEFILTER}" -exec exiftran -ibp -c "${COMMENTSTEXT}" {} \; +