diff --git a/README.md b/README.md index 2ac042a..0c01d28 100644 --- a/README.md +++ b/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 @@ -11,4 +14,5 @@ My personally used scripts |[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| diff --git a/SchredderHDD.sh b/SchredderHDD.sh new file mode 100755 index 0000000..c1e0886 --- /dev/null +++ b/SchredderHDD.sh @@ -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= + +## diff --git a/wmf2svg.sh b/wmf2svg.sh new file mode 100755 index 0000000..2817911 --- /dev/null +++ b/wmf2svg.sh @@ -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} +