HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: /home/httpd/html/gayreviewsites.com/dead/wp.sh
#!/bin/bash

URL=http://wordpress.org/latest.tar.gz
WGET=`which wget`
TAR=`which tar`
mysql=`which mysql`
passgen=`cat /dev/urandom | tr -dc [A-Z][a-z][0-9]|head -c 12`

#checking if you have the a variable for $1
if [[ x"$1" == x ]] || [[ x"$1" == x--help ]] || [[ x"$1" == x--usage ]]; then
  echo 
  echo "Usage:  ./wp_script.sh <database name>"
  exit 1
fi


echo "Downloading latest wordpress"
$WGET $URL

echo "Extracting tar file"
$TAR -xvf latest.tar.gz

echo "Enter wordpress directory and copy files"
cd wordpress && cp -R * ../; cd ../

# Grab our Salt Keys
wget -O /tmp/wp.keys https://api.wordpress.org/secret-key/1.1/salt/

echo "Creating htaccess file for wp"

cat << EOF > .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
EOF

echo "Creating database and setting permissions"
$mysql -e "create database if not exists $1_wp;";
$mysql -e "grant all on $1_wp.* to $1_wp@localhost identified by '$passgen';"
$mysql -e "flush privileges;"

# Butcher our wp-config.php file
sed -e "s/database_name_here/"$1"/" -e "s/username_here/"$1_wp"/" -e "s/password_here/"$passgen"/" wp-config-sample.php > wp-config.php
sed -i '/#@-/r /tmp/wp.keys' wp-config.php
sed -i "/#@+/,/#@-/d" wp-config.php


#Cleaning up
Echo "Cleaning up install files"
rm  -rf wordpress
rm  -rf /tmp/wp.keys
rm  latest.tar.gz
rm readme.html
rm license.txt

#Setting permissions on files and directories
Echo "Setting permission on files and directories"
chown -R `stat -c %U:%G ../` *
chmod -R g+w wp-content/

echo "Wordpress database username is $1_wp"
echo "Wordpress database password is $passgen"