Skip to content
This repository was archived by the owner on Sep 23, 2022. It is now read-only.

Commit f1f04d8

Browse files
committed
Finalize the full initialization suite
Now users can install a new wordpress, check configurations, backup, restore all they need Signed-off-by: Stéphane HULARD <[email protected]>
1 parent e44007a commit f1f04d8

File tree

7 files changed

+61
-58
lines changed

7 files changed

+61
-58
lines changed

build.xml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<property file="config/build.properties"/>
1414
</then>
1515
<else>
16-
<fail message="Property file does not defined! Please create build.properties from SAMPLE.build.properties" />
16+
<fail message="Property file does not defined! Please create build.properties from config/samples/SAMPLE.build.properties" />
1717
</else>
1818
</if>
1919
</else>
@@ -32,15 +32,27 @@
3232
<echo msg="Feel free to use db:help, wp:help, helper:help for more details on each one." />
3333
<echo msg="" />
3434
<echo msg="These shortcuts are available:" />
35-
<echo msg=' - help -> Print tool command description' />
36-
<echo msg=' - env:init -> Initialize current environment by preparing configurations and dependencies' />
37-
<echo msg=' - env:restore -> Restore backuped date in the current environement' />
38-
<echo msg=' - env:backup -> Backup current data' />
35+
<echo msg=' - help -> Print tool command description' />
36+
<echo msg=' - env:init -> Initialize current environment by preparing configurations and dependencies' />
37+
<echo msg=' - env:restore -> Restore backuped date in the current environement' />
38+
<echo msg=' - env:backup -> Backup current data' />
39+
<echo msg=' - env:wp:install -> Initialize WordPress database from the defined configuration' />
3940
</target>
4041
<!--################################################################################-->
4142
<target name="env:init" description="Initialize current environment by preparing configurations and dependencies">
43+
<exec command="git submodule update --force" logoutput="true" />
4244
<phingcall target="wp:init" />
4345
</target>
46+
<!--################################################################################-->
47+
<target name="env:install" description="Install current environment">
48+
<exec command="git submodule update --force" logoutput="true" />
49+
<phingcall target="wp:init" />
50+
<phingcall target="wp:install" />
51+
</target>
52+
<!--################################################################################-->
53+
<target name="env:wp:update" description="Update local wordpress version instance to the most recent one">
54+
<exec command="cd public/wp-cms &amp;&amp; git fetch --tags &amp;&amp; git checkout `git tag | tail -1`" logoutput="true" />
55+
</target>
4456
<!--################################################################################-->
4557
<target name="env:restore" description="Restore backuped date in the current environement">
4658
<phingcall target="db:restore" />

config/phing/wordpress.xml

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@
2828
<not><equals arg1="${server.port}" arg2="" /></not>
2929
</and>
3030
<then>
31-
<property name="server.hostname" value="${server.hostname}:${server.port}" override="true" />
31+
<property name="server.qualified-hostname" value="${server.hostname}:${server.port}" override="true" />
3232
</then>
3333
</if>
3434

3535
<!--################################################################################-->
3636
<target name="wp:help" description="Print help for current phing command">
3737
<echo msg="Specific wordpress commands:" />
3838
<echo msg=' - wp:help -> Print current help' />
39-
<echo msg=' - wp:init -> Build wp-config.php file from the SAMPLE.wp-config.php example (maybe with regexp can be done from wp-config-sample.php)' />
39+
<echo msg=' - wp:init -> Build wp-config.php file from the config/samples/SAMPLE.wp-config.php example (maybe with regexp can be done from wp-config-sample.php)' />
4040
<echo msg=' - wp:uploads:backup -> Backup uploads content inside the data folder' />
4141
<echo msg=' - wp:uploads:restore -> Restore uploads content from the data folder archive' />
4242
<echo msg=' - wp:migrate -> Migrate wordpress from an environment to another' />
4343
</target>
4444
<!--################################################################################-->
45-
<target name="wp:init" depends="wp:check-configuration" description="Initialize wordpress configuration in the current environment from build.properties">
46-
<copy file="public/SAMPLE.wp-config.php" tofile="public/wp-config.php" overwrite="true"/>
47-
<copy file="public/SAMPLE.htaccess" tofile="public/.htaccess" overwrite="true"/>
45+
<target name="wp:init" depends="wp:check-configuration,db:check-configuration" description="Initialize wordpress configuration in the current environment from build.properties">
46+
<copy file="config/samples/SAMPLE.wp-config.php" tofile="public/wp-config.php" overwrite="true"/>
47+
<copy file="config/samples/SAMPLE.htaccess" tofile="public/.htaccess" overwrite="true"/>
4848

4949
<reflexive>
5050
<fileset dir="public">
@@ -53,35 +53,22 @@
5353
</fileset>
5454

5555
<filterchain>
56-
<replacetokens begintoken="{" endtoken="}">
57-
<token key="server.protocol" value="${server.protocol}" />
58-
<token key="server.hostname" value="${server.hostname}" />
59-
<token key="server.pathname" value="${server.pathname}" />
60-
<token key="db.host" value="${db.host}" />
61-
<token key="db.user" value="${db.user}" />
62-
<token key="db.pass" value="${db.pass}" />
63-
<token key="db.name" value="${db.name}" />
64-
<token key="db.charset" value="${db.charset}" />
65-
<token key="db.collate" value="${db.collate}" />
66-
<token key="db.prefix" value="${db.prefix}" />
67-
<token key="wp.debug" value="${wp.debug}" />
68-
<token key="wp.lang" value="${wp.lang}" />
69-
<token key="wp.theme" value="${wp.theme}" />
70-
<token key="wp.key.auth" value="${wp.key.auth}" />
71-
<token key="wp.key.secure_auth" value="${wp.key.secure_auth}" />
72-
<token key="wp.key.logged_in" value="${wp.key.logged_in}" />
73-
<token key="wp.key.nonce" value="${wp.key.nonce}" />
74-
<token key="wp.salt.auth" value="${wp.salt.auth}" />
75-
<token key="wp.salt.secure_auth" value="${wp.salt.secure_auth}" />
76-
<token key="wp.salt.logged_in" value="${wp.salt.logged_in}" />
77-
<token key="wp.salt.nonce" value="${wp.salt.nonce}" />
78-
<token key="wp.salt.nonce" value="${wp.salt.nonce}" />
79-
<token key="ga.tracker" value="${ga.tracker}" />
80-
<token key="mail.contact" value="${mail.contact}" />
81-
</replacetokens>
56+
<expandproperties />
8257
</filterchain>
8358
</reflexive>
8459
</target>
60+
<!--################################################################################-->
61+
<target name="wp:install" depends="wp:check-configuration,db:check-configuration" description="Initialize wordpress database in the current environment from properties">
62+
<trycatch property="foo">
63+
<try>
64+
<exec command="bin/wp core is-installed" checkreturn="true" />
65+
</try>
66+
67+
<catch>
68+
<exec command="bin/wp core install --url=${server.protocol}://${server.qualified-hostname}/${server.pathname} --admin_user=${wp.admin.user} --admin_password=${wp.admin.pass} --admin_email=${wp.admin.mail} --title='${wp.title}'" logoutput="true" checkreturn="true" />
69+
</catch>
70+
</trycatch>
71+
</target>
8572
<!--################################################################################-->
8673
<target name="wp:uploads:backup" depends="wp:check-configuration" description="Save current uploads folder to a ZIP">
8774
<tar destfile="${wp.path.data}/uploads.tar.gz" basedir="public/wp-content/uploads" compression="gzip" />
File renamed without changes.
File renamed without changes.

public/SAMPLE.htaccess renamed to config/samples/SAMPLE.htaccess

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<IfModule mod_rewrite.c>
22
RewriteEngine On
33

4-
RewriteBase "/{server.pathname}"
4+
RewriteBase "/${server.pathname}"
55

66
#If the URL start with public stop redirect
77
RewriteRule wp\-cms\/index\.php$ - [L]

public/SAMPLE.wp-config.php renamed to config/samples/SAMPLE.wp-config.php

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@
1616

1717
// ** MySQL settings - You can get this info from your web host ** //
1818
/** The name of the database for WordPress */
19-
define('DB_NAME', '{db.name}');
19+
define('DB_NAME', '${db.name}');
2020

2121
/** MySQL database username */
22-
define('DB_USER', '{db.user}');
22+
define('DB_USER', '${db.user}');
2323

2424
/** MySQL database password */
25-
define('DB_PASSWORD', '{db.pass}');
25+
define('DB_PASSWORD', '${db.pass}');
2626

2727
/** MySQL hostname */
28-
define('DB_HOST', '{db.host}');
28+
define('DB_HOST', '${db.host}');
2929

3030
/** Database Charset to use in creating database tables. */
31-
define('DB_CHARSET', '{db.charset}');
31+
define('DB_CHARSET', '${db.charset}');
3232

3333
/** The Database Collate type. Don't change this if in doubt. */
34-
define('DB_COLLATE', '{db.collate}');
34+
define('DB_COLLATE', '${db.collate}');
3535

3636
/**#@+
3737
* Authentication Unique Keys and Salts.
@@ -42,14 +42,14 @@
4242
*
4343
* @since 2.6.0
4444
*/
45-
define('AUTH_KEY', '{wp.key.auth}');
46-
define('SECURE_AUTH_KEY', '{wp.key.secure_auth}');
47-
define('LOGGED_IN_KEY', '{wp.key.logged_in}');
48-
define('NONCE_KEY', '{wp.key.nonce}');
49-
define('AUTH_SALT', '{wp.salt.auth}');
50-
define('SECURE_AUTH_SALT', '{wp.salt.secure_auth}');
51-
define('LOGGED_IN_SALT', '{wp.salt.logged_in}');
52-
define('NONCE_SALT', '{wp.salt.nonce}');
45+
define('AUTH_KEY', '${wp.key.auth}');
46+
define('SECURE_AUTH_KEY', '${wp.key.secure_auth}');
47+
define('LOGGED_IN_KEY', '${wp.key.logged_in}');
48+
define('NONCE_KEY', '${wp.key.nonce}');
49+
define('AUTH_SALT', '${wp.salt.auth}');
50+
define('SECURE_AUTH_SALT', '${wp.salt.secure_auth}');
51+
define('LOGGED_IN_SALT', '${wp.salt.logged_in}');
52+
define('NONCE_SALT', '${wp.salt.nonce}');
5353

5454
/**#@-*/
5555

@@ -59,7 +59,7 @@
5959
* You can have multiple installations in one database if you give each a unique
6060
* prefix. Only numbers, letters, and underscores please!
6161
*/
62-
$table_prefix = '{db.prefix}';
62+
$table_prefix = '${db.prefix}';
6363

6464
/**
6565
* WordPress Localized Language, defaults to English.
@@ -69,7 +69,7 @@
6969
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
7070
* language support.
7171
*/
72-
define('WPLANG', '{wp.lang}');
72+
define('WPLANG', '${wp.lang}');
7373

7474
/**
7575
* For developers: WordPress debugging mode.
@@ -81,14 +81,13 @@
8181
define('WP_DEBUG', false);
8282

8383
//Define specific website URL
84-
define('WP_HOME', '{server.protocol}://{server.hostname}/{server.pathname}');
85-
define('WP_SITEURL', '{server.protocol}://{server.hostname}/{server.pathname}');
84+
define('WP_HOME', '${server.protocol}://${server.qualified-hostname}/${server.pathname}');
85+
define('WP_SITEURL', '${server.protocol}://${server.qualified-hostname}/${server.pathname}');
8686

8787
define('WP_CONTENT_DIR', dirname(__FILE__).'/wp-content');
88-
define('WP_CONTENT_URL', '{server.protocol}://{server.hostname}/{server.pathname}wp-content');
89-
define('WP_DEFAULT_THEME', '{wp.theme}');
88+
define('WP_CONTENT_URL', '${server.protocol}://${server.qualified-hostname}/${server.pathname}wp-content');
89+
define('WP_DEFAULT_THEME', '${wp.theme}');
9090

91-
define('GA_TRACKER', 'UA-34900512-1');
9291
/* That's all, stop editing! Happy blogging. */
9392

9493
/** Absolute path to the WordPress directory. */

config/SAMPLE.wp.properties renamed to config/samples/SAMPLE.wp.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ wp.debug=false
1313
wp.theme=##Theme name here
1414
wp.lang=
1515

16+
wp.title=
17+
wp.admin.user=admin
18+
wp.admin.pass=admin
19+
wp.admin.mail=
20+
1621
# Authentication Unique Keys and Salts.
1722
# Change these to different unique phrases!
1823
# You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}

0 commit comments

Comments
 (0)