I have a bit of bash that I use to "install" a wordpress site on a server.
In it, I do a curl request to get the randomized SALTs via SALTS=$(curl -L https://api.wordpress.org/secret-key/1.1/salt/);
And I put a "token" in my wp-config.php file ##WP_SALTS##
It seems that my sed
statement is not proper, as it keeps throwing me an error:
sed: -e expression #1, char 99: unknown option to `s'
I have tried:
sed -i "s+##WP_SALTS##+$SALTS+g" $WPCONFIG
As well:
sed -i "s/##WP_SALTS##/$SALTS/g" $WPCONFIG
Still the error presents. What am I doing wrong?
the response from the curl
request are random each time, but are similar to:
define('AUTH_KEY', ':a>?5od_kaveFKaIB8px|!vgF-W/6/AQX04=&>Tu.-q3ehGOh59=SX+qc9sWk|gG'); define('SECURE_AUTH_KEY', ':tw+w! Sn2n~Rt0ReVA6#eWqsUXW5elHo@V~ oiRhTH4k]kg{<k`:An`]z==K@wZ'); define('LOGGED_IN_KEY', 'mD,JT*4pa3}zfGEpXFR}9jlzF,iD ;:]|>yu]T}&8Uy~(-5ml/AEBTG4|7QYCB|j'); define('NONCE_KEY', '@{Q`.7T a)S?0DTutE}D5Is(UlwnG4NuoQiFHas&i@qz%-HTd7-8[v50Nx<]akuT'); define('AUTH_SALT', 'es*7hCVnh/+c-cecgmZ?%QZ_KN^kaA[jD]N}{A8sK|~MH@Vl|(6-|{3EIGMhksy['); define('SECURE_AUTH_SALT', '}AF@:i!hy#C5,Q_5c4yhycm~i|fc53@+|h7r5H9y(/&4VBeX&sOrKC-6+AqeZ|L>'); define('LOGGED_IN_SALT', '4,}H+&[@qN#^!B+?3a+Mh0+?pURhP|v.CV/]4F-6G!TncU*Pd=GMSRPf?58j5Sv0'); define('NONCE_SALT', 'Dlo,7F[:EaWQT57-P0Q+x</nUf4UD&LH=-0wS6l._2Fx!-jR0KBJ-U_1*{sXo?>Q');
EDIT Now implementing a way to randomly generate the 64 character salts with the following:
RSTR=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-64} | head -n 1);
SALTS="define('AUTH_KEY', '$RSTR');
define('SECURE_AUTH_KEY', '$RSTR');
define('LOGGED_IN_KEY', '$RSTR');
define('NONCE_KEY', '$RSTR');
define('AUTH_SALT', '$RSTR');
define('SECURE_AUTH_SALT', '$RSTR');
define('LOGGED_IN_SALT', '$RSTR');
define('NONCE_SALT', '$RSTR');";
sed -i "s/##WP_SALTS##/$SALTS/g" $WPCONFIG
I've replaced the delimiter with +, ~, /, &, * and they all still generate this same error.