-
Notifications
You must be signed in to change notification settings - Fork 2
/
SiteImporter.xml
128 lines (103 loc) · 5.37 KB
/
SiteImporter.xml
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
<?xml version="1.0"?>
<project name="SiteImporter" basedir="Tasks" default="">
<!--
==============================================
Dump database
==============================================
-->
<target name="show" depends="">
<echo>-----------------------------</echo>
<echo>Phing Configuration</echo>
<echo>-----------------------------</echo>
<echo>local.user: ${local.user}</echo>
<echo>local.domain: ${local.domain}</echo>
<echo>local.directory.home: ${local.directory.home}</echo>
<echo>local.database.credentials: ${local.database.credentials}</echo>
<echo></echo>
<echo>remote.domain: ${remote.domain}</echo>
<echo>remote.directory.home: ${remote.directory.home}</echo>
<echo>remote.database.credentials: ${remote.database.credentials}</echo>
</target>
<!--
==============================================
Dump database
==============================================
-->
<target name="d" depends="import-dump"/>
<target name="import-dump" depends="">
<echo>-----------------------------</echo>
<echo>Dump database</echo>
<echo>-----------------------------</echo>
<echo>Fetching remote database credentials...</echo>
<fetchProperties/>
<echo>Dumping remote database...</echo>
<dumpRemote/>
<echo>Fetching dump...</echo>
<rsync remoteDirectory="${remote.directory.temp}/${remote.database.name}.${local.user}.bz2"
localDirectory="${local.directory.temp}/"/>
<echo>Extracting file...</echo>
<commandLocal
command="tar -C ${local.directory.temp}/ -xjf ${local.directory.temp}/${remote.database.name}.${local.user}.bz2"/>
<echo>Reset database...</echo>
<commandLocal
command="${mysql.local} -e "DROP DATABASE IF EXISTS ${local.database.name}; CREATE DATABASE ${local.database.name};""/>
<echo>Import dump...</echo>
<commandLocal command="${mysql.local} ${local.database.name} < ${local.directory.temp}/${remote.database.name}.${local.user}.sql"/>
<echo>Fine tunes database...</echo>
<commandLocal
command="${mysql.local} -e "UPDATE sys_domain SET domainName = REPLACE(domainName, '${remote.domain}', '${local.domain}');" ${local.database.name}"/>
<commandLocal
command="${mysql.local} -e "UPDATE sys_template SET title = REPLACE(title, '${remote.domain}', '${local.domain}');" ${local.database.name}"/>
<commandLocal
command="${mysql.local} -e "UPDATE sys_template SET config = REPLACE(config, '${remote.domain}', '${local.domain}');" ${local.database.name}"/>
<commandLocal
command="${mysql.local} -e "UPDATE sys_template SET constants = REPLACE(constants, '${remote.domain}', '${local.domain}');" ${local.database.name}"/>
<commandLocal
command="${mysql.local} -e "UPDATE pages SET title = REPLACE(title, '${remote.domain}', '${local.domain}');" ${local.database.name}"/>
<!-- reset database password for admin user -->
<commandLocal
command="${mysql.local} -e "DELETE FROM be_users WHERE username = 'admin';" ${local.database.name}"/>
<commandLocal
command="${mysql.local} -e "INSERT INTO be_users (username, password, admin) VALUES ('admin', '$argon2i$v=19$m=16384,t=16,p=2$aUF1aDNNYlZYVmZDMmxqUg$cZHoi0WmnmzPizsrpX6KhyHzbbm7l0yIv85GJwlt9Yo', 1) " ${local.database.name}"/>
<commandLocal
command="${mysql.local} -e "INSERT INTO fe_users (username, password, first_name, last_name, email, usergroup, pid) VALUES ('admin', '$argon2i$v=19$m=16384,t=16,p=2$aUF1aDNNYlZYVmZDMmxqUg$cZHoi0WmnmzPizsrpX6KhyHzbbm7l0yIv85GJwlt9Yo', 'Admin', 'istrator', '[email protected]', (SELECT GROUP_CONCAT(uid SEPARATOR ',') FROM fe_groups where hidden = 0 and deleted = 0), (SELECT max(pid) FROM fe_groups)) " ${local.database.name}"/>
<echo>Clean up environment...</echo>
<commandLocal command="rm -f ${local.directory.temp}/${remote.database.name}.${local.user}.bz2"/>
<commandLocal command="rm -f ${local.directory.temp}/${remote.database.name}.${local.user}.sql"/>
<commandRemote command="rm ${remote.directory.temp}/${remote.database.name}.${local.user}.sql"/>
<commandRemote command="rm ${remote.directory.temp}/${remote.database.name}.${local.user}.bz2"/>
<!-- delete processed files -->
<delete>
<fileset refid="processedFiles"/>
</delete>
</target>
<!--
==============================================
Synchronize files
==============================================
-->
<target name="uploads" depends="">
<echo>-----------------------------</echo>
<echo>Fetch uploads|</echo>
<echo>-----------------------------</echo>
<echo>fetching files...</echo>
<rsync remoteDirectory="${remote.directory.documentRoot}/uploads"
localDirectory="${local.directory.documentRoot}/"/>
</target>
<target name="user_upload" depends="">
<echo>-----------------------------</echo>
<echo>Fetch resources files</echo>
<echo>-----------------------------</echo>
<echo>fetching files...</echo>
<rsync remoteDirectory="${remote.directory.documentRoot}/fileadmin/user_upload"
localDirectory="${local.directory.documentRoot}/fileadmin"/>
</target>
<target name="fileadmin" depends="">
<echo>-----------------------------</echo>
<echo>Fetch fileadmin files</echo>
<echo>-----------------------------</echo>
<echo>fetching files...</echo>
<rsync remoteDirectory="${remote.directory.documentRoot}/fileadmin"
localDirectory="${local.directory.documentRoot}/"/>
</target>
</project>