-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysqlwp.sh
79 lines (62 loc) · 1.95 KB
/
mysqlwp.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
#!/bin/bash
if [ $(id -u) -ne 0 ]
then
sudo $0
exit 0
fi
if [ $(uname) = "Linux" ]
then
while [ -z "$database" ];
do
echo -n "Enter name of database: "
read database
done
while [ -z "$username" ];
do
echo -n "Enter username: "
read username
done
while [ -z "$prefix" ];
do
echo -n "Enter prefix: "
read prefix
done
while [ -z "$password" ];
do
echo -n "Enter password: "
read password
done
while [ -z "$sitename" ];
do
echo -n "Enter sitename: "
read sitename
done
while [ -z "$ruser" ];
do
echo -n "Root user (you): "
read ruser
done
fi
DB="CREATE DATABASE $database;"
USN="CREATE USER $username@localhost IDENTIFIED BY '$password';"
PWD="GRANT ALL PRIVILEGES ON $database.* TO $username@localhost;"
FL="FLUSH PRIVILEGES;"
CREATE="${DB}${USN}${PWD}${FL};"
sudo -u "$ruser" mysql -e "$CREATE"
cp "/home/$ruser/wordpress/wp-config-sample.php" "/home/$ruser/wordpress/wp-config.php"
sed -i -e "s/database_name_here/$database/g" "/home/$ruser/wordpress/wp-config.php"
sed -i -e "s/username_here/$username/g" "/home/$ruser/wordpress/wp-config.php"
sed -i -e "s/password_here/$password/g" "/home/$ruser/wordpress/wp-config.php"
sed -i -e "s/wp_/$prefix/g" "/home/$ruser/wordpress/wp-config.php"
cp -r "/home/$ruser/wordpress/*" "/srv/www/$sitename/public/"
chown -R scdadmin:www-data "/srv/www/$sitename/public/"
mkdir -p "/srv/www/$sitename/public/wp-content/uploads"
chown -R scdadmin:www-data "/srv/www/$sitename/public/wp-content/uploads"
# nginx server blocks, must use provided default
# wget https://raw.githubusercontent.com/LuciferIAm/ScriptsnStuff/master/autodef ~/etc/nginx/sites-available/
cp "/etc/nginx/sites-available/autodef" "/etc/nginx/sites-available/$sitename"
sed -i -e "s/example.com/$sitename/g" "/etc/nginx/sites-available/$sitename"
ln -s "/etc/nginx/sites-available/$sitename" "/etc/nginx/sites-enabled/"
service nginx restart
service php5-fpm restart
#install finished! just go to your site now!