-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·80 lines (66 loc) · 2.7 KB
/
setup
File metadata and controls
executable file
·80 lines (66 loc) · 2.7 KB
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
#!/bin/bash
DEFAULT_PLUGINS='["wordpress-importer"]'
configure_db() {
mysql -u root -e "CREATE DATABASE wordpress"
mysql -u root -e "CREATE USER 'wordpressuser'@'127.0.0.1' IDENTIFIED BY 'password'"
mysql -u root -e "GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'127.0.0.1'"
mysql -u root -e "FLUSH PRIVILEGES"
}
configure_wp() {
wp core download --allow-root
wp config create --dbname=wordpress --dbpass=password --dbuser=wordpressuser --dbhost=127.0.0.1 --skip-check --allow-root
wp core install --url="$SITE_URL" --title="$SITE_TITLE" --admin_user="$ADMIN_USER" --admin_email="$ADMIN_EMAIL" --admin_password="$ADMIN_PASSWORD" --allow-root
}
change_max_size() {
php_ini_file=$(php -i | grep "php.ini" | grep -o '=>.*$' | awk '{print $2}' | tail -1)
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 256M/' $php_ini_file
sed -i 's/post_max_size = 8M/post_max_size = 256M/' $php_ini_file
}
configure_ssl() {
conf_file=/etc/apache2/sites-available/default-ssl.conf
mkdir /etc/apache2/ssl
openssl req -x509 -new -days 365 -newkey rsa:4096 -sha256 -nodes \
-out /etc/apache2/ssl/apache.crt \
-keyout /etc/apache2/ssl/apache.key \
-subj "/CN=localhost"
sed -i '/SSLCertificateFile.*snakeoil\.pem/c\SSLCertificateFile \/etc\/apache2\/ssl\/apache.crt' $conf_file
sed -i '/SSLCertificateKeyFile.*snakeoil\.key/cSSLCertificateKeyFile \/etc\/apache2\/ssl\/apache.key' $conf_file
sed -i '/IfModule/d' $conf_file
sed -i '/^<\/VirtualHost>/i Redirect / https://:443/' /etc/apache2/sites-available/000-default.conf
}
configure_apache() {
a2enmod ssl rewrite
configure_ssl
rm index.html
a2ensite default-ssl.conf
service apache2 restart
}
install_plugins() {
wp plugin uninstall $(wp plugin list --field=name --status=inactive --allow-root) --allow-root
wp plugin install $(echo ${DEFAULT_PLUGINS} | jq -r ".[]") --activate --allow-root
if [[ $(echo $PLUGINS | jq -r '. | length') -gt 0 ]]
then
wp plugin install $(echo $1 | jq -r ".[]") --activate --allow-root
fi
if [[ $(ls plugins | wc -l) -gt 0 ]]
then
for plugin in $(ls plugins)
do
wp plugin install plugins/$plugin --activate --allow-root
done
fi
}
import() {
wp post delete $(wp post list --field=ID --format=json --allow-root | jq -r ".[]") --allow-root
wp post delete $(wp post list --post_type=page --field=ID --format=json --allow-root | jq -r ".[]") --allow-root
if [[ $(ls -A templates | wc -l) -gt 1 ]]
then
wp import templates --authors=create --allow-root
fi
}
configure_db
change_max_size
configure_wp
configure_apache
install_plugins
import