Skip to content

Commit

Permalink
Update wp-config.sh
Browse files Browse the repository at this point in the history
Streamline random number generator
  • Loading branch information
basilhendroff authored Oct 24, 2020
1 parent 7319e6f commit 2a017ce
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions includes/wp-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ outfile="/usr/local/www/wordpress/wp-config.tmp"

# Random number generator
rand() {
local rnum=$(LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom | head -c 64 ; echo)
local rnum=$(LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom | head -c "$1" ; echo)
echo $rnum
}

Expand All @@ -32,28 +32,28 @@ cat $infile | while IFS= read -r line; do
printf '%s\n' "$line" >> $outfile
;;
*'AUTH_KEY'*)
printf "define( 'AUTH_KEY', '%s' );\n" "$(rand)" >> $outfile
printf "define( 'AUTH_KEY', '%s' );\n" "$(rand 64)" >> $outfile
;;
*'SECURE_AUTH_KEY'*)
printf "define( 'SECURE_AUTH_KEY', '%s' );\n" "$(rand)" >> $outfile
printf "define( 'SECURE_AUTH_KEY', '%s' );\n" "$(rand 64)" >> $outfile
;;
*'LOGGED_IN_KEY'*)
printf "define( 'LOGGED_IN_KEY', '%s' );\n" "$(rand)" >> $outfile
printf "define( 'LOGGED_IN_KEY', '%s' );\n" "$(rand 64)" >> $outfile
;;
*'NONCE_KEY'*)
printf "define( 'NONCE_KEY', '%s' );\n" "$(rand)" >> $outfile
printf "define( 'NONCE_KEY', '%s' );\n" "$(rand 64)" >> $outfile
;;
*'AUTH_SALT'*)
printf "define( 'AUTH_SALT', '%s' );\n" "$(rand)" >> $outfile
printf "define( 'AUTH_SALT', '%s' );\n" "$(rand 64)" >> $outfile
;;
*'SECURE_AUTH_SALT'*)
printf "define( 'SECURE_AUTH_SALT', '%s' );\n" "$(rand)" >> $outfile
printf "define( 'SECURE_AUTH_SALT', '%s' );\n" "$(rand 64)" >> $outfile
;;
*'LOGGED_IN_SALT'*)
printf "define( 'LOGGED_IN_SALT', '%s' );\n" "$(rand)" >> $outfile
printf "define( 'LOGGED_IN_SALT', '%s' );\n" "$(rand 64)" >> $outfile
;;
*'NONCE_SALT'*)
printf "define( 'NONCE_SALT', '%s' );\n" "$(rand)" >> $outfile
printf "define( 'NONCE_SALT', '%s' );\n" "$(rand 64)" >> $outfile
;;
*)
printf '%s\n' "$line" >> $outfile
Expand Down

0 comments on commit 2a017ce

Please sign in to comment.