blob: 0781c71c6590507b7067dda6c7afa0aa2c04e393 (
plain)
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
|
#!/bin/bash
TEMPLATE=ichimisushiandgrill.com
OUTPUT=${1:-ichimisushi-thai.com}
SANITIZED=${OUTPUT//[-.]/_}
DB_USER=$SANITIZED
TABLE_NAME=wordpress_$SANITIZED
PATH=$PWD:$PATH
set -ex
[ "$OUTPUT" != "$TEMPLATE" ]
# Create new apache virtual host
if [ ! -e /etc/apache2/sites-enabled/$OUTPUT.conf ]
then
[ -e /etc/apache2/sites-available/$TEMPLATE.conf ]
mkdir /srv/$OUTPUT /srv/$OUTPUT/public_html /srv/$OUTPUT/logs
cd /etc/apache2/sites-available/
sed -e "s/$TEMPLATE/$OUTPUT/g" < "$TEMPLATE".conf > "$OUTPUT".conf
a2ensite $OUTPUT
systemctl reload apache2
fi
# Install wordpress content to apache htdocs directory
if [ ! -e /srv/"$OUTPUT"/public_html/wordpress/wp-config.php ]
then
cd /srv/"$OUTPUT"/public_html
curl https://wordpress.org/latest.tar.gz | tar -zx
cd wordpress
wp-conf.sh "$TABLE_NAME" "$DB_USER" > wp-config.php
chown www-data.www-data -R .
chown nobody.nogroup wp-config.php
fi
# Set up database
if true
then
pwline=$(grep DB_PASSWORD /srv/$OUTPUT/public_html/wordpress/wp-config.php)
DB_PASSWORD=$(php -r "$pwline echo DB_PASSWORD;")
mysqladmin create "$TABLE_NAME"
mysql "$TABLE_NAME" <<END
grant all privileges on \`$TABLE_NAME\`.* to "$DB_USER" identified by "$DB_PASSWORD";
END
fi
|