Compare commits
4 commits
07c91a937e
...
c9cc97bd61
Author | SHA1 | Date | |
---|---|---|---|
c9cc97bd61 | |||
6742b90d01 | |||
8bf2e9b3ec | |||
f9cdcd3638 |
6 changed files with 226 additions and 4 deletions
11
README.md
11
README.md
|
@ -1,6 +1,9 @@
|
|||
# my-scripts
|
||||
|
||||
My personally used scripts
|
||||
My personally or users our LUG-VS used scripts
|
||||
|
||||
See also at [LUG-VS-Wiki Nützliche Scripte](https://lug-vs.org//lugvswiki/index.php?title=Nuetzliche_Scripte) (German)
|
||||
|
||||
|
||||
## Content
|
||||
|
||||
|
@ -8,5 +11,9 @@ My personally used scripts
|
|||
|---|---|
|
||||
|[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|
|
||||
|[make_exif-name.sh](make_exif-name.sh)|Add a comment in all *.jpg files in the actuall and all subfolders|
|
||||
|[write-exif-comment.sh](write-exif-comment.sh)|Write JPEG EXIF comment in all *.jpg pocures|
|
||||
|[utf8.sh](utf8.sh)|Convert text from e.g. Windows latin1 to utf8 text (e.g. in READMEs or other text (not for office documents))|
|
||||
|[SchredderHDD.sh](SchredderHDD.sh)|Delete a mechanical Hard Disk (HDD) in a relayeable way to ensure before forward it to the recycling, that no old data are there|
|
||||
|[wmf2svg.sh](wmf2svg.sh)|Example script converts WMF files in SVG to share it easily in the internet|
|
||||
|
||||
|
|
98
SchredderHDD.sh
Executable file
98
SchredderHDD.sh
Executable file
|
@ -0,0 +1,98 @@
|
|||
#!/bin/sh
|
||||
# Löscht ein komplettes Device
|
||||
# Version 0.2.0
|
||||
# Vom 2012-10-15 Aktualisert am 2021-01-24
|
||||
# (c) LUG-VS (GPL)
|
||||
|
||||
##Status anzeigen:
|
||||
#sudo kill -SIGUSR1 $(pidof dd)
|
||||
|
||||
# teste ob vorhanden
|
||||
if [ "`whoami`" != "root" ] ; then
|
||||
echo 'Nicht ausreichend Rechte - bitte als "root" anmelden!'
|
||||
exit 10
|
||||
fi
|
||||
|
||||
# Überprüft ob Parameter vorhanden
|
||||
if [ $# -lt 1 ] ; then
|
||||
echo 'Device angeben z.B. "'$0' /dev/sdf"'
|
||||
exit 20
|
||||
fi
|
||||
|
||||
# teste ob vorhanden
|
||||
if [ ! -b $1 ] ; then
|
||||
echo 'Device existiert nicht'
|
||||
echo 'Device angeben z.B. "'$0' /dev/sdf"'
|
||||
exit 30
|
||||
fi
|
||||
|
||||
# Device zuweisen
|
||||
OF=$1
|
||||
SIZE=$(fdisk -l ${OF} 2> /dev/null | grep ${OF} | sed -r "s/.*\, (.*) byte.*/\1/I")
|
||||
NAME=$(fdisk -l ${OF} 2> /dev/null | head -n2 | tail -n1 | sed 's/.*: *//' | sed 's/ *//')
|
||||
RNDOM=$(( 20 * 1024 * 1024 )) # Durchsatz bei Zufallszahlen in B/s
|
||||
NULLS=$(( 40 * 1024 * 1024 )) # Durchsatz bei Zufallszahlen in B/s
|
||||
RDURATION=$(( ${SIZE} / ${RNDOM} ))
|
||||
NDURATION=$(( ${SIZE} / ${NULLS} ))
|
||||
DURATION=$(( ${RDURATION} + ${NDURATION} ))
|
||||
#echo "Random=<${RNDOM}> NULLS=<${NULLS}> RDURATION=<${RDURATION}> NDURATION=<${NDURATION}> DURATION=<${DURATION}>"
|
||||
|
||||
# Letze Nachfrage
|
||||
echo -e "Info ($(date '+%A, %T Uhr')): $OF hat eine Größe von $((${SIZE}/1073741824))GB! Damit dauert mit anschließenden schreiben von Nullen bei typischen Durchsatz etwa $((${DURATION}/3600)) Stunden!"
|
||||
echo -en "*** Achtung! Device (Festplatte) ${OF} (${NAME}) wirklich löschen? (j/n) "
|
||||
read -n 1 key
|
||||
echo -e "\n"
|
||||
if [ "${key}" != "j" ] ; then echo 'Antwort nicht "j" => abgebrochen durch Benutzer'; exit 1; fi;
|
||||
|
||||
# Laufwerk aushängen
|
||||
echo -en "Info ($(date '+%A, %T Uhr')): Laufwerk aushängen: "
|
||||
umount -f ${OF}*
|
||||
|
||||
# Zufallszahlen Schreiben bis
|
||||
TIME=$(date "+%A, %T Uhr")
|
||||
RTIME=$(date "+%A um %H:%M Uhr" --date="+${RDURATION} seconds")
|
||||
FTIME=$(date "+%A um %H:%M Uhr" --date="+${DURATION} seconds")
|
||||
echo -e "Info (${TIME}): $OF hat eine Größe von $((${SIZE}/1073741824))GB, was bei typischen Durchsatz von $((${RNDOM}/1048576))MB/s etwa bis ${RTIME} für das schreiben der Zufallszahlen dauert!"
|
||||
echo -e "Info (${TIME}): Damit dauert mit anschließenden schreiben von Nullen bei typischen Durchsatz von $((${NULLS}/1048576))MB/s etwa bis ${FTIME}!"
|
||||
##dd random
|
||||
dd if=/dev/urandom of=${OF} bs=4M iflag=fullblock oflag=direct status=progress
|
||||
sync
|
||||
#echo -e "\n"
|
||||
TIME=$(date "+%A, %T Uhr")
|
||||
NTIME=$(date "+%A um %H:%M Uhr" --date="+${NDURATION} seconds")
|
||||
echo -e "Info (${TIME}): $OF hat eine Größe von ${SIZE} bytes, was bei typischen Durchsatz von $((${NULLS}/1048576))MB/s etwa bis ${NTIME} für das schreiben der Nullen dauert!"
|
||||
##dd null
|
||||
#dd if=/dev/zero of=${OF} bs=64k
|
||||
dd if=/dev/zero of=${OF} bs=4M iflag=fullblock oflag=direct status=progress
|
||||
sync
|
||||
TIME=$(date "+%A, %T Uhr")
|
||||
echo -e "Info (${TIME}): $OF (${NAME}) sicher gelöscht!"
|
||||
|
||||
## Bisher
|
||||
# echo 'Laufwerk aushängen'
|
||||
# umount -f ${OF}*
|
||||
#
|
||||
# Zufallszahlen beschreiben und anschließend löschen
|
||||
# date +"%F %T"
|
||||
# echo 'Schreibe Zufallszahlen auf' ${OF}
|
||||
# dd if=/dev/urandom of=${OF}
|
||||
# dd if=/dev/urandom of=${OF} bs=4M iflag=fullblock oflag=direct status=progress
|
||||
# sync
|
||||
# echo -en "\n"
|
||||
# date +"%F %T"
|
||||
# echo 'Schreibe Nullen auf' ${OF}
|
||||
# dd if=/dev/zero of=${OF} bs=64k
|
||||
# dd if=/dev/zero of=${OF} bs=4M iflag=fullblock oflag=direct status=progress
|
||||
# sync
|
||||
# date +"%F %T"
|
||||
# echo 'Device (Festplatte)' ${OF} 'sicher gelöscht'
|
||||
# OF=
|
||||
#
|
||||
# 4 mal lüten
|
||||
#for (( INDEX=4 ; ${INDEX} ; INDEX=$(( ${INDEX} - 1 )) )) ; do
|
||||
# beep # => beep wird nicht gefunden ist auch kein alias ???!!!
|
||||
# wait
|
||||
#done
|
||||
#INDEX=
|
||||
|
||||
##
|
3
jpg-add-comment.sh → make_exif-name.sh
Normal file → Executable file
3
jpg-add-comment.sh → make_exif-name.sh
Normal file → Executable file
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
# Add a exif-comment to all JPEG-Files from this directory and all subdirectorys
|
||||
#
|
||||
# (c) LUG-VS (GPL)
|
||||
# (c) by Ulf Bartholomäus ub1x@gmx.net
|
||||
VERSION="make_exif-name.sh Version 0.0.2 from 23.10.2005"
|
||||
#
|
||||
# Input: comment text
|
||||
|
@ -29,4 +29,3 @@ echo "Write Comment: <"${COMMENTSTEXT}">"
|
|||
# -p Preserve timestamps (atime + mtime) when doing inplace editing.
|
||||
# -c <text> Set jpeg comment tag to <text>.
|
||||
find . -type f -name "${JPEGFILEFILTER}" -exec exiftran -ibp -c "${COMMENTSTEXT}" {} \;
|
||||
|
32
utf8.sh
Executable file
32
utf8.sh
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
# Script wich converts a file in 'text/plain' from an not utf8 char set to utf8 char set
|
||||
#
|
||||
# (c) by Ulf Bartholom<6F>s ulfbart@gmx.de
|
||||
VERSION="$0 Version 0.1.0 from 20.09.2006"
|
||||
|
||||
|
||||
#
|
||||
if [ "$1" == "" ]; then
|
||||
echo "Please enter Filename as first option which should be converted"
|
||||
echo
|
||||
echo -e "INFO:\n\tTo convert all old latin1 file-names in new utf8 file-names use:"
|
||||
echo -e "\t\t'convmv --notest -r -f latin1 -t utf-8 *'\n"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
myNEWNAME=$1
|
||||
myNEWNAMEsik=$(echo ${myNEWNAME}~)
|
||||
myFILETYPE=$(file -bi ${myNEWNAME} | cut -d';' -f1)
|
||||
myCHARSET=$(file -bi ${myNEWNAME} | cut -d'=' -f2)
|
||||
# if Filetype is convertable
|
||||
if [ "${myFILETYPE}" == "text/plain" ] && [ "${myCHARSET}" != "utf8" ]; then
|
||||
# If sik file exists break with error message
|
||||
test -e ${myNEWNAMEsik} && echo "File <${myNEWNAMEsik}> exists" && exit -2
|
||||
mv ${myNEWNAME} ${myNEWNAMEsik}
|
||||
# Convert the old CharSet in utf8
|
||||
echo "Convert ${myNEWNAME} from ${myCHARSET} to utf8"
|
||||
iconv -f ${myCHARSET} -t utf8 -o ${myNEWNAME} ${myNEWNAMEsik}
|
||||
else
|
||||
# Print error Message
|
||||
echo "Filetype not 'text/plain' (${myFILETYPE}) or char set is 'utf8' (${myCHARSET})"
|
||||
fi
|
59
wmf2svg.sh
Executable file
59
wmf2svg.sh
Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/bin/bash
|
||||
# Simple script to "convert" a grafik file format to an other
|
||||
#
|
||||
# (c) LUG-VS (GPL)
|
||||
VERSION="wmf2svg.sh Version 0.0.2 from 2006-12-27"
|
||||
#
|
||||
# Input: path
|
||||
# Output: changed files
|
||||
#
|
||||
# Changes:
|
||||
# 0.0.2: rebuild with temporary convertion file
|
||||
# 0.0.1: generation
|
||||
#
|
||||
|
||||
FORMATin=.wmf
|
||||
FORMATout=.svg
|
||||
TEMPfile=`dirname $0`/$$.sh
|
||||
EXECpath=.
|
||||
|
||||
# trap is executed if script breaks (remove temporary file if exists)
|
||||
trap "echo '*** TRAP ***' ; test -e ${TEMPfile} && rm ${TEMPfile} ; exit" ERR
|
||||
|
||||
# check if command exists else break
|
||||
which convert > /dev/null || echo "convert not found!" || exit;
|
||||
|
||||
# check if filename exists
|
||||
if [ -e ${TEMPfile} ] ; then
|
||||
echo '${TEMPfile} exists => call this comand a 2-nd time'
|
||||
exit
|
||||
fi
|
||||
|
||||
# if path exists and is a path => use it
|
||||
if [ -d $1 ] ; then
|
||||
EXECpath=$1
|
||||
fi
|
||||
|
||||
# generate temporary script for manipulation and made it executable
|
||||
# change in this sektion what is to do
|
||||
# the "echo" comand writes the comand lines in the ${TEMPfile}
|
||||
echo '#!/bin/bash' > `echo ${TEMPfile}`
|
||||
echo -e 'myFILEin=$1\nmyFILEout=`dirname $1`/`basename $1 '${FORMATin}'`"'${FORMATout}'"' >> `echo ${TEMPfile}`
|
||||
echo -e 'echo convert ${myFILEin} ${myFILEout}' >> `echo ${TEMPfile}`
|
||||
echo -e 'convert ${myFILEin} ${myFILEout}' >> `echo ${TEMPfile}`
|
||||
echo -e '# write what you want to do without coment char "#" in this line' >> `echo ${TEMPfile}`
|
||||
echo -e '# rm ${myFILEin} ;# remove "#" befor rm if you want to delete the source' >> `echo ${TEMPfile}`
|
||||
chmod +x ${TEMPfile}
|
||||
|
||||
# echo what is to do
|
||||
echo 'Start recursive convertion from *'${FORMATin}' in *'${FORMATout}
|
||||
|
||||
# find all files (not case sensitive) that matching filter and execut script
|
||||
find ${EXECpath} -type f -iname "*${FORMATin}" -print0 | xargs -0 -n1 ${TEMPfile}
|
||||
|
||||
# debug => remove this line if not need
|
||||
cat ${TEMPfile}
|
||||
|
||||
# remove the temporary script
|
||||
rm ${TEMPfile}
|
||||
|
27
write-exif-comment.sh
Executable file
27
write-exif-comment.sh
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
# Write a exif-comment to all JPEG-Files from this directory and all subdirectorys
|
||||
#
|
||||
# (c) LUG-VS (GPL)
|
||||
VERSION="write-exif-comment.sh Version 0.0.1 from 16.06.2019"
|
||||
#
|
||||
# Input: InImage [OutImage]
|
||||
# Output: changed files
|
||||
#
|
||||
# Changes:
|
||||
# 0.0.1: generation
|
||||
#
|
||||
test -e $1 || exit -1
|
||||
FilenameFull="$1"
|
||||
if [ $# -gt 1 ] ; then
|
||||
FilenameSik="$2"
|
||||
else
|
||||
Extension="${FilenameFull##*.}"
|
||||
FilenameBase="${FilenameFull%.*}"
|
||||
FilenameSik="${FilenameBase}New.${Extension}"
|
||||
fi
|
||||
CommentsText="$(convert ${FilenameFull} -format "%c\n" info:)"
|
||||
Width=$(identify -format %w ${FilenameFull})
|
||||
High=$(( $(identify -format %h ${FilenameFull}) / 10))
|
||||
echo "EXIF-Kommentar= <${CommentsText}> of <${FilenameFull}> (${Width}x${High} ${FilenameSik})"
|
||||
convert -background '#0008' -fill white -gravity center -size ${Width}x${High} caption:"${CommentsText}" \
|
||||
${FilenameFull} +swap -gravity south -composite ${FilenameSik}
|
Loading…
Reference in a new issue