Update test.sh
This commit is contained in:
parent
ad1d7a31ba
commit
3edd3309eb
17
test.sh
17
test.sh
|
@ -4,15 +4,13 @@
|
|||
DB_NAME="wordpress"
|
||||
DB_USER="wordpressuser"
|
||||
DB_PASSWORD="Change-me123@!"
|
||||
DB_ROOT_PASSWORD="RootSecure123!@#" # New root password for MySQL
|
||||
DB_ROOT_PASSWORD="RootSecure123!@#"
|
||||
|
||||
# ====== Update & Install Packages ======
|
||||
apt update && apt upgrade -y
|
||||
apt install -y apache2 mysql-server php libapache2-mod-php php-mysql curl rsync unzip
|
||||
apt install -y apache2 mysql-server php libapache2-mod-php php-mysql curl rsync unzip expect
|
||||
|
||||
# ====== Secure MySQL Installation ======
|
||||
echo "Securing MySQL..."
|
||||
|
||||
mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '${DB_ROOT_PASSWORD}'; FLUSH PRIVILEGES;"
|
||||
|
||||
SECURE_MYSQL=$(expect -c "
|
||||
|
@ -54,11 +52,20 @@ tar xzvf latest.tar.gz
|
|||
|
||||
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
|
||||
|
||||
# Update wp-config.php with DB info
|
||||
# Replace DB credentials in wp-config.php
|
||||
sed -i "s/database_name_here/${DB_NAME}/" /tmp/wordpress/wp-config.php
|
||||
sed -i "s/username_here/${DB_USER}/" /tmp/wordpress/wp-config.php
|
||||
sed -i "s/password_here/${DB_PASSWORD}/" /tmp/wordpress/wp-config.php
|
||||
|
||||
# Fetch and set WordPress salts
|
||||
SALTS=$(curl -s https://api.wordpress.org/secret-key/1.1/salt/)
|
||||
if [ -n "$SALTS" ]; then
|
||||
sed -i "/AUTH_KEY/d;/SECURE_AUTH_KEY/d;/LOGGED_IN_KEY/d;/NONCE_KEY/d;/AUTH_SALT/d;/SECURE_AUTH_SALT/d;/LOGGED_IN_SALT/d;/NONCE_SALT/d" /tmp/wordpress/wp-config.php
|
||||
echo "$SALTS" | tee -a /tmp/wordpress/wp-config.php > /dev/null
|
||||
else
|
||||
echo "⚠️ Failed to fetch salts from WordPress API."
|
||||
fi
|
||||
|
||||
# ====== Deploy WordPress ======
|
||||
rsync -avP /tmp/wordpress/ /var/www/html/
|
||||
chown -R www-data:www-data /var/www/html/
|
||||
|
|
Loading…
Reference in New Issue