-
-
Save dhornbein/5708249 to your computer and use it in GitHub Desktop.
Install latest wordpress to current directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Database Name: " | |
read -e DBNAME | |
echo "Database User: " | |
read -e DBUSER | |
echo "Database Password: " | |
read -e DBPASS | |
echo -e " | |
DB Name: '$DBNAME' | |
DB User: '$DBUSER' | |
DB Pass: '$DBPASS' | |
run install? (Y/n)" | |
read -e RUN | |
if [ "$RUN" == n ] ; then | |
exit | |
else | |
#download wordpress | |
echo "Downloading wordpress..." | |
curl -O http://wordpress.org/latest.tar.gz | |
#unzip wordpress | |
echo -e "Extracting wordpress to: \n$(pwd)" | |
tar -zxf latest.tar.gz | |
#change dir to wordpress | |
cd wordpress | |
#copy file to parent dir | |
cp -rf . .. | |
#move back to parent dir | |
cd .. | |
#remove files from wordpress folder | |
rm -R wordpress | |
#create wp config | |
echo "Creating wp-config.php..." | |
cp wp-config-sample.php wp-config.php | |
#set database details with perl find and replace | |
sed -i "s/database_name_here/$DBNAME/g" wp-config.php | |
sed -i "s/username_here/$DBUSER/g" wp-config.php | |
sed -i "s/password_here/$DBPASS/g" wp-config.php | |
#Update the secret key in wp-config.php | |
echo "Downloading and updating secret key..." | |
SECRETKEYS=$(curl -L https://api.wordpress.org/secret-key/1.1/salt/) | |
EXISTINGKEYS='put your unique phrase here' | |
printf '%s\n' "g/$EXISTINGKEYS/d" a "$SECRETKEYS" . w | ed -s wp-config.php | |
#create uploads folder and set permissions | |
echo "Creating wp-content/uploads" | |
mkdir wp-content/uploads | |
chmod 777 wp-content/uploads | |
#remove zip file | |
echo "removing latest.tar.gz" | |
rm latest.tar.gz | |
fi |
Trouble is that pwgen might not be installed (not a huge issue). Also, how do I restrict it from making strings with single quotes '
, these break the php code in wp-config.php
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could do this without needing to call out remotely to get salts, a potential security concern with:
for i in$(seq 1 $ (grep -c "put your unique phrase here" wp-config-s.php));
do
salt=$(pwgen -y -n -s 64 -N 1) &&
sed -i "0,/put your unique phrase here/s/put your unique phrase here/$salt/" wp-config-s.php;
done