Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6cc2185 authored by thilo's avatar thilo
Browse files

Add new file: bootstrap-commons.sh

parent af91a4ed
Loading
Loading
Loading
Loading

bootstrap-commons.sh

0 → 100644
+15 −0
Original line number Diff line number Diff line
function getRandomString {
        LENGTH=$1
        cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $LENGTH | head -n 1
}

function replaceTokensWithRandomStrings {
        INPUT="$1"
        echo $INPUT
        TOBEREPLACED=$(echo "$INPUT" | grep -o '@@@generate@@@:[0-9]\+@')
        echo $TOBEREPLACED
        REPLACEMENT_LENGTH=$(echo "$TOBEREPLACED" | awk -F: '{ print $NF }' | sed 's/@$//g')
        echo "$REPLACEMENT_LENGTH"
        RANDOMPART=$(getRandomString $REPLACEMENT_LENGTH)
        echo "$INPUT" | sed "s/$TOBEREPLACED/$RANDOMPART/g"
}
 No newline at end of file