-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathmain
More file actions
executable file
·145 lines (114 loc) · 6.05 KB
/
main
File metadata and controls
executable file
·145 lines (114 loc) · 6.05 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash -ex
WPROOT=/var/www/wordpress
CONFIG_FILE=$WPROOT/wp-config.php
NAME=wordpress
DB_PREFIX=wp_
DB_PASSWORD=$(mcookie)
ADMIN_USER=admin
ADMIN_PASS=turnkey
ADMIN_MAIL=admin@example.com
# increase php running limits
PHPINI=/etc/php/7.0/fpm/php.ini
sed -i "s|^memory_limit.*|memory_limit = 128M|" $PHPINI
sed -i "s|^upload_max_filesize.*|upload_max_filesize = 16M|" $PHPINI
sed -i "s|^post_max_size.*|post_max_size = 48M|" $PHPINI
sed -i "s|^allow_url_fopen.*|allow_url_fopen = On|" $PHPINI
# unpack wordpress
tar -zxf /usr/local/src/latest.tar.gz -C $(dirname $WPROOT)
rm /usr/local/src/latest.tar.gz
# write the config file
cat > $CONFIG_FILE << EOF
<?php
define('DB_NAME', '$NAME');
define('DB_USER', '$NAME');
define('DB_PASSWORD', '$DB_PASSWORD');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
define('AUTH_KEY', '$(mcookie)$(mcookie)');
define('AUTH_SALT', '$(mcookie)$(mcookie)');
define('SECURE_AUTH_KEY', '$(mcookie)$(mcookie)');
define('SECURE_AUTH_SALT', '$(mcookie)$(mcookie)');
define('LOGGED_IN_KEY', '$(mcookie)$(mcookie)');
define('LOGGED_IN_SALT', '$(mcookie)$(mcookie)');
define('NONCE_KEY', '$(mcookie)$(mcookie)');
define('NONCE_SALT', '$(mcookie)$(mcookie)');
define('DISABLE_WP_CRON', true);
\$table_prefix = '$DB_PREFIX';
// WordPress Localized Language, defaults to English.
define ('WPLANG', '');
// WordPress debugging mode (for developers).
define('WP_DEBUG', false);
// WordPress update method
define('FS_METHOD', 'direct');
// WordPress update policy
define('AUTOMATIC_UPDATER_DISABLED', false);
define('WP_AUTO_UPDATE_CORE', 'minor');
// Single-Site (serves any hostname)
// For Multi-Site, see: https://www.turnkeylinux.org/docs/wordpress/multisite
define('WP_SITEURL', 'http://'.\$_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://'.\$_SERVER['HTTP_HOST']);
/* That's all, stop editing! Happy blogging. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
require_once(ABSPATH . 'wp-settings.php');
EOF
chgrp www-data "${CONFIG_FILE}"
# start mysql server
service mysql start
# create the database and user
mysql --defaults-extra-file=/etc/mysql/debian.cnf <<EOF
CREATE DATABASE $NAME;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
ON $NAME.*
TO $NAME@localhost
IDENTIFIED BY '$DB_PASSWORD';
FLUSH PRIVILEGES;
EOF
# setup apache configuration and complete wordpress installation
a2dissite 000-default
a2ensite wordpress
a2enmod rewrite
cat >$WPROOT/wp-admin/turnkey-install.php<<EOF
<?php
define('WP_INSTALLING', true);
require_once('$WPROOT/wp-config.php');
require_once('$WPROOT/wp-admin/includes/upgrade.php');
//install system
wp_install("TurnKey Linux", '$ADMIN_USER', '$ADMIN_MAIL', 1);
//set admin password to something not random
\$user = get_userdatabylogin('$ADMIN_USER');
\$user = add_magic_quotes(get_object_vars(\$user));
\$user['user_pass'] = '$ADMIN_PASS';
wp_update_user(\$user);
?>
EOF
php $WPROOT/wp-admin/turnkey-install.php
rm $WPROOT/wp-admin/turnkey-install.php
# edit first post to include useful information
mysql --defaults-extra-file=/etc/mysql/debian.cnf <<EOF
USE $NAME;
UPDATE ${DB_PREFIX}posts SET post_title = 'Welcome to WordPress!' WHERE ID = '1';
UPDATE ${DB_PREFIX}posts SET post_content = 'Getting started...<ul><li><a href="/wp-login.php">Login</a> as <b>admin</b> and get blogging!</li><li>Refer to the <a href="http://www.turnkeylinux.org/wordpress">TurnKey WordPress release notes</a></li><li>Refer to the <a href="http://codex.wordpress.org/Getting_Started_with_WordPress">Wordpress Getting Started Codex</a></li><li>Check out some of the numerous WordPress plugins: <ul>
<li><a href="http://yoast.com/wordpress/seo/">Wordpress-SEO</a>: Optimizes your WordPress blog for search engines and XML sitemaps.</li>
<li><a href="http://wordpress.org/extend/plugins/nextgen-gallery/">NextGEN Gallery</a>: Easy to use image gallery with a Flash slideshow option.</li>
<li><a href="http://wordpress.org/extend/plugins/jetpack/">JetPack for WordPress</a>: Jetpack adds powerful features previously only available to WordPress.com users including customization, traffic, mobile, content, and performance tools.</li>
<li><a href="http://wordpress.org/extend/plugins/wp-super-cache/">WP Super Cache</a>: Accelerates your blog by serving 99% of your visitors via static HTML files.</li>
<li><a href="http://wordpress.org/extend/plugins/ultimate-social-media-icons/">Ultimate Social Media Icons</a>: Promote your content by adding links to social sharing and bookmarking sites.</li>
<li><a href="http://wordpress.org/extend/plugins/simple-tags/">Simple Tags</a>: automatically adds tags and related posts to your content.</li>
<li><a href="http://wordpress.org/extend/plugins/backupwordpress/">BackupWordPress</a>: easily backup your core WordPress tables.</li>
<li><a href="http://yoast.com/wordpress/google-analytics/">Google Analytics for WordPress</a>: track visitors, AdSense clicks, outgoing links, and search queries.</li>
<li><a href="http://wordpress.org/extend/plugins/wp-polls/">WP-Polls</a>: Adds an easily customizable AJAX poll system to your blog.</li>
<li><a href="http://wordpress.org/extend/plugins/wp-updates-notifier/">WP-PageNavi</a>: Adds more advanced paging navigation.</li>
<li><a href="http://wordpress.org/extend/plugins/wp-pagenavi/">Ozh admin dropdown menu</a>: Creates a drop down menu with all admin links.</li>
<li><a href="http://wordpress.org/extend/plugins/ozh-admin-drop-down-menu/">Contact From 7</a>: Customizable contact forms supporting AJAX, CAPTCHA and Akismet integration.</li>
<li><a href="http://wordpress.org/extend/plugins/contact-form-7/">WP-Update-Notifier</a>: Sends email to notify you if there are any updates for your WordPress site. Can notify about core, plugin and theme updates.</li>
<li><a href="http://wordpress.org/extend/plugins/seriously-simple-podcasting/">Seriously Simple Podcasting</a>: Simple Podcasting from your WordPress site.</li>
</ul></li></ul>' WHERE ID = '1';
EOF
# fix permissions for updates
chown -R www-data:www-data $WPROOT
find $WPROOT -type d -exec chmod 755 {} \;
find $WPROOT -type f -exec chmod 644 {} \;
# stop mysql server
service mysql stop