Skip to content

Commit

Permalink
Update wp-config.sh
Browse files Browse the repository at this point in the history
Have the script set up Authentication Unique Keys and Salts
  • Loading branch information
basilhendroff authored Oct 22, 2020
1 parent 84b9c64 commit cdd4a8b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions includes/wp-config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#!usr/local/bin/bash

# File pointers
infile="/usr/local/www/wordpress/wp-config.php"
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)
echo $rnum
}

# wp-config.php adjustments
cat $infile | while IFS= read -r line; do
case $line in
"<?php")
Expand All @@ -21,6 +31,30 @@ cat $infile | while IFS= read -r line; do
done
printf '%s\n' "$line" >> $outfile
;;
*'AUTH_KEY'*)
printf "define( 'AUTH_KEY', '%s' );\n" "$(rand)" >> $outfile
;;
*'SECURE_AUTH_KEY'*)
printf "define( 'SECURE_AUTH_KEY', '%s' );\n" "$(rand)" >> $outfile
;;
*'LOGGED_IN_KEY'*)
printf "define( 'LOGGED_IN_KEY', '%s' );\n" "$(rand)" >> $outfile
;;
*'NONCE_KEY'*)
printf "define( 'NONCE_KEY', '%s' );\n" "$(rand)" >> $outfile
;;
*'AUTH_SALT'*)
printf "define( 'AUTH_SALT', '%s' );\n" "$(rand)" >> $outfile
;;
*'SECURE_AUTH_SALT'*)
printf "define( 'SECURE_AUTH_SALT', '%s' );\n" "$(rand)" >> $outfile
;;
*'LOGGED_IN_SALT'*)
printf "define( 'LOGGED_IN_SALT', '%s' );\n" "$(rand)" >> $outfile
;;
*'NONCE_SALT'*)
printf "define( 'NONCE_SALT', '%s' );\n" "$(rand)" >> $outfile
;;
*)
printf '%s\n' "$line" >> $outfile
;;
Expand Down

0 comments on commit cdd4a8b

Please sign in to comment.