From ffaf96fa9e6fa232eb790509aec40aabb4605e11 Mon Sep 17 00:00:00 2001 From: Grmbl Frechneu Date: Fri, 11 Jan 2013 14:14:36 +0100 Subject: [PATCH] Small script to anonymise data in bug report --- contrib/anonymiser.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 contrib/anonymiser.sh diff --git a/contrib/anonymiser.sh b/contrib/anonymiser.sh new file mode 100755 index 0000000000..a5952091c9 --- /dev/null +++ b/contrib/anonymiser.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# A special file with the list of words to replace. The format is one word per line, with a tabulation as separation +# Example: +# name offuscatedname +# phonenumber 111111 +anonymise_list="Anonymiser" + +# Take the folder to anonymise as argument, and check if it is a folder +if [ $# -gt 0 ] && [ -d $1 ] +then + dossier=$1 +else + echo "Usage: $0 FOLDER" + echo "For example : $0 /tmp/weboob_session_NLSIls/freemobile/" + exit 1 +fi + +if [ ! -f $anonymise_list ] +then + echo "Please create the $anonymise_list file (see documentation)" + exit 1 +fi + +# remove potentials old files +find $dossier -name \*_anonymised -delete +rm -rf $dossier/Anonyme + +for file_to_anonymise in `find $dossier -type f` +do + file=$file_to_anonymise"_anonymised" + cp $file_to_anonymise $file + + cat $anonymise_list | tr '\t' '_' | while read line + do + to_replace=$(echo "$line"|cut -d_ -f1) + replace_with=$(echo "$line"|cut -d_ -f2) + sed -i "s%$to_replace%$replace_with%Ig" $file + done +done +mkdir $dossier/Anonyme + +find $dossier -name \*_anonymised -exec mv \{\} $dossier/Anonyme \; -- GitLab