forked from jelastic-jps/file-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanifest.jps
146 lines (132 loc) · 6.61 KB
/
manifest.jps
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
145
type: update
logo: images/icon.png
homepage: http://docs.jelastic.com/file-synchronization
version: '1.1'
baseUrl: https://raw.githubusercontent.com/layershift/file-sync/master/
targetNodes:
nodeType:
- storage
- apache
- apache2
- nginxphp
- nginxphp-dockerized
- tomcat
- tomcat7
- tomcat6
- tomee
- tomee-dockerized
description: Lsyncd is a light-weight, live mirror solution used to synchronize app servers. Being wisely coupled with inotify, lsyncd initiates file sync only if it has detected any actual changes in the system. In such a way, the load on CPU is decreased and you do not burn up many resources on processing the synchronization.
name: File Synchronization
id: file-sync
onInstall: installRsyncDaemon
settings:
fields:
- default: one_env
values:
one_env:
en: One environment synchronization
two_envs:
en: Two environments synchronization
name: optional
showIf:
one_env:
- placeholder: relative to ${WEBROOT} for cp layer or /data for storage
name: path
caption: Sync path
type: string
required: false
- default: '10'
name: delay
caption: Sync delay (sec)
type: string
required: false
two_envs:
- placeholder: relative to ${WEBROOT} for cp layer or /data for storage
name: path
caption: Sync path
type: string
required: false
- default: '10'
name: delay
caption: Sync delay (sec)
type: string
required: false
- placeholder: optional
name: address
caption: IP second environment
type: string
- placeholder: optional
name: password
caption: Password
type: string
type: radio-fieldset
onAfterCloneNodes: installRsyncDaemon
onAfterDeploy: installRsyncDaemon
onBeforeDeploy:
cmd [${targetNodes.nodeGroup}]:
- killall rsync lsyncd 2>&1
onAfterRemoveNode: installRsyncDaemon
actions:
removeLsyncd:
- cmd [${targetNodes.nodeGroup}]: |-
killall rsync lsyncd 2>&1
[ "${targetNodes.nodeGroup}" == "storage" ] && lsyndPath="/data" || lsyndPath="/var/www/webroot"
rm -rf ${lsyndPath}/lsyncd* 2>&1
crontab -l | sed "/lsyncd/d" | crontab -
- script: "${baseUrl}scripts/firewallRules.js"
param: uninstall
installRsyncDaemon:
- script: scripts/firewallRules.js
param: install
- script: scripts/installRsyncDaemon.js
installLsync:
- cmd [${this.nodeId}]: |-
rm -rf ${this.lsyncdPath}lsyncd; mkdir -p ${this.lsyncdPath}lsyncd
curl "${baseUrl}dumps/sync2.tar.gz" -o ${this.lsyncdPath}lsyncd/sync.tar
tar -xf ${this.lsyncdPath}lsyncd/sync.tar -C ${this.lsyncdPath}lsyncd/
sed -i "s|{SERVER_WEBROOT}|${this.lsyncdPath}${this.settingsPath}|g" ${this.lsyncdPath}lsyncd/etc/lsyncd.conf
sed -i "s|{LSYNCD_TMP}|lsyncd_tmp/|g" ${this.lsyncdPath}lsyncd/etc/lsyncd.conf
sed -i "s|{DELAY}|${settings.delay}|g" ${this.lsyncdPath}lsyncd/etc/lsyncd.conf
sed -i "s|{SERVER_WEBROOT}|${this.lsyncdPath}/${this.settingsPath}|g" ${this.lsyncdPath}lsyncd/etc/rsync.conf
sed -i "s|--temp-dir=/|--temp-dir=/lsyncd_tmp|g" ${this.lsyncdPath}lsyncd/etc/lsyncd.conf
curl "${baseUrl}scripts/checkROOTZDT.sh" -o ${this.lsyncdPath}/zdt.sh 2>&1
bash ${this.lsyncdPath}zdt.sh ${this.lsyncdPath} 2>&1
rm ${this.lsyncdPath}zdt.sh
rm -rf ${this.lsyncdPath}lsyncd_tmp
mkdir ${this.lsyncdPath}/${this.settingsPath}/lsyncd_tmp
rm -rf /tmp/lsyncd_tmp
ln -s ${this.lsyncdPath}/${this.settingsPath}/lsyncd_tmp/ /tmp/
sed -i "s|_MIRROR_SERVER_IP|${this.mirrorServerIp}|g" ${this.lsyncdPath}lsyncd/etc/lsyncd.conf
sed -i "s|_USER|admin|g" ${this.lsyncdPath}lsyncd/etc/lsyncd.conf
sed -i "s|_INSTALL_DIRECTORY|${this.lsyncdPath}lsyncd|g" ${this.lsyncdPath}lsyncd/etc/rsync.conf
sed -i "s|apache|${this.user}|g" ${this.lsyncdPath}lsyncd/etc/rsync.conf
sed -i "s|name|syncmodule|g" ${this.lsyncdPath}lsyncd/etc/lsyncd.conf
sed -i "s|_NAME|syncmodule|g" ${this.lsyncdPath}lsyncd/etc/rsync.conf
sed -i "s|_USER|admin|g" ${this.lsyncdPath}lsyncd/etc/rsync.conf
sed -i "s|_USER|admin|g" ${this.lsyncdPath}lsyncd/etc/lsyncd.conf
sed -i "s|_INSTALL_DIRECTORY|${this.lsyncdPath}lsyncd|g" ${this.lsyncdPath}lsyncd/etc/lsyncd.conf
sed -i "s|_USER|admin|g" ${this.lsyncdPath}lsyncd/etc/rsyncd.secrets
sed -i "s|_INSTALL_DIRECTORY|${this.lsyncdPath}lsyncd/|g" ${this.lsyncdPath}lsyncd/init.sh
- cmd [${this.nodeId}]: |-
wget https://raw.githubusercontent.com/layershift/file-sync/master/scripts/lsyncd.logrotate -O /etc/logrotate.d/lsyncd
group=$(grep 700 /etc/group | cut -d ":" -f 1);if [ -z "$group" ];then sed -i "s/create 0640 jelastic apache/create 0640 jelastic root/g" /etc/logrotate.d/lsyncd; else sed -i "s/create 0640 jelastic apache/create 0640 jelastic $group/g" /etc/logrotate.d/lsyncd; fi
sed -i "s#/var/www/webroot/lsyncd/var/log/#${this.lsyncdPath}lsyncd/var/log#g" /etc/logrotate.d/lsyncd
sed -i "s#/var/www/webroot/lsyncd/init.sh#${this.lsyncdPath}lsyncd/init.sh#g" /etc/logrotate.d/lsyncd
user: root
- cmd [${this.nodeId}]: |-
cd ${this.lsyncdPath}lsyncd/
chmod 600 etc/rsyncd.pass etc/rsyncd.secrets
chmod 755 usr/bin/lsyncd
chown ${this.user} etc/*
killall rsync lsyncd 2>&1
/usr/bin/rsync --daemon --config=${this.lsyncdPath}lsyncd/etc/rsync.conf --port=7755 &>>${this.lsyncdPath}lsyncd/var/log/rsyncd_start.log & echo $! > ${this.lsyncdPath}lsyncd/bg.pid
[ ${this.syncPassword} ] && password=${this.syncPassword} || password=defaultPassword; echo ${password} > ${this.lsyncdPath}lsyncd/etc/rsyncd.pass; echo "admin:${password}" > ${this.lsyncdPath}/lsyncd/etc/rsyncd.secrets
- cmd [${this.nodeId}]: |-
curl -fsS "${baseUrl}scripts/twoEnvs.sh" -o ${this.lsyncdPath}lsyncd/addSecondEnv.sh 2>&1
bash -x ${this.lsyncdPath}lsyncd/addSecondEnv.sh "${this.secondEnvAddress}" "${this.settingsPath}" "${this.lsyncdPath}" 2>&1 ${this.lsyncdPath}lsyncd/2Env.log
rm -rf ${this.lsyncdPath}addSecondEnv.sh
- cmd [${this.nodeId}]: |-
[ -d '${this.lsyncdPath}${this.settingsPath}' ] && (${this.lsyncdPath}lsyncd/usr/bin/lsyncd ${this.lsyncdPath}lsyncd/etc/lsyncd.conf &>>${this.lsyncdPath}lsyncd/var/log/lsyncd_start.log) || echo 0
(crontab -l 2>/dev/null | grep -q init.sh || { crontab -l 2>/dev/null | { cat; echo "*/3 * * * * /bin/bash ${this.lsyncdPath}lsyncd/init.sh check"; } | crontab - ; } ; )
onUninstall: removeLsyncd
success: Lsyncd is installed on your environment.<br>You can find config files and logs at the webroot directory for compute nodes or data directory for storage.