-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp.sh
executable file
·91 lines (85 loc) · 2.94 KB
/
wp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Project Name: "
read -e projectname
echo "Database Name: "
read -e dbname
echo "Table Prefix: "
read -e table_prefix
echo "Database User: "
read -e dbuser
echo "Database Password: "
read -s dbpass
echo "run install? (y/n)"
read -e run
if [ "$run" == n ] ; then
exit
else
echo "============================================"
echo "A robot is now installing WordPress for you."
echo "============================================"
#move to webroot
cd /var/www/html
#download wordpress
curl -O https://wordpress.org/latest.tar.gz
#unzip wordpress
tar -zxvf 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 "============================================"
echo "Editing wp-config.php file."
echo "============================================"
mv wp-config-sample.php wp-config.php
#set database details with perl find and replace
perl -pi -e "s/database_name_here/$dbname/g" wp-config.php
perl -pi -e "s/username_here/$dbuser/g" wp-config.php
perl -pi -e "s/password_here/$dbpass/g" wp-config.php
perl -pi -e "s/wp_/$table_prefix/g" wp-config.php
perl -pi -e 'print "define('WP_AUTO_UPDATE_CORE', true ); \n" if $. == 81' wp-config.php
perl -pi -e 'print "define('WP_POST_REVISIONS', false ); \n" if $. == 82' wp-config.php
perl -pi -e 'print "define('FS_METHOD', 'direct'); \n" if $. == 83' wp-config.php
perl -pi -e 'print "define('AUTOSAVE_INTERVAL', 240 ); \n" if $. == 84' wp-config.php
perl -pi -e 'print "define('DISALLOW_FILE_EDIT',true); \n" if $. == 85' wp-config.php
perl -pi -e "s/WP_AUTO_UPDATE_CORE/\'WP_AUTO_UPDATE_CORE\'/g" wp-config.php
perl -pi -e "s/WP_POST_REVISIONS/\'WP_POST_REVISIONS\'/g" wp-config.php
perl -pi -e "s/FS_METHOD/\'FS_METHOD\'/g" wp-config.php
perl -pi -e "s/direct/\'direct\'/g" wp-config.php
perl -pi -e "s/AUTOSAVE_INTERVAL/\'AUTOSAVE_INTERVAL\'/g" wp-config.php
perl -pi -e "s/DISALLOW_FILE_EDIT/\'DISALLOW_FILE_EDIT\'/g" wp-config.php
#set WP salts
perl -i -pe'
BEGIN {
@chars = ("a" .. "z", "A" .. "Z", 0 .. 9);
push @chars, split //, "!@#$%^&*()-_ []{}<>~\`+=,.;:/?|";
sub salt { join "", map $chars[ rand @chars ], 1 .. 64 }
}
s/put your unique phrase here/salt()/ge
' wp-config.php
#create uploads folder and set permissions
mkdir wp-content/uploads
echo "Cleaning..."
#remove zip file
cd ..
rm latest.tar.gz
mv wordpress $projectname
sudo chown -R www-data:www-data $projectname
sudo find $projectname -type d -exec chmod 755 {} \;
sudo find $projectname -type f -exec chmod 644 {} \;
echo "========================="
echo "creating database."
echo "========================="
echo "create database $dbname" | mysql --login-path=$dbuser
echo "========================="
echo "Installation is complete."
echo "========================="
fi