forked from cybertec-postgresql/patroni-windows-packaging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.bat
156 lines (125 loc) · 4.82 KB
/
make.bat
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
146
147
148
149
150
151
152
153
154
155
156
@ECHO off
SET MD=PES
SET ETCD_REF=https://github.com/etcd-io/etcd/releases/download/v3.5.13/etcd-v3.5.13-windows-amd64.zip
SET PATRONI_REF=https://github.com/zalando/patroni/archive/refs/tags/v3.3.0.zip
SET MICRO_REF=https://github.com/zyedidia/micro/releases/download/v2.0.13/micro-2.0.13-win64.zip
SET WINSW_REF=https://github.com/winsw/winsw/releases/download/v2.12.0/WinSW.NET461.exe
SET VIP_REF=https://github.com/cybertec-postgresql/vip-manager/releases/download/v2.5.0/vip-manager_2.5.0_Windows_x86_64.zip
SET PGSQL_REF=https://get.enterprisedb.com/postgresql/postgresql-16.3-1-windows-x64-binaries.zip
SET PES_REF=https://github.com/cybertec-postgresql/PES/releases/download/v0.2/pes.zip
SET SEVENZIP="C:\Program Files\7-Zip\7z.exe"
@ECHO --- Start bootstrapping ---
RMDIR /Q /S %MD% patroni > nul 2>&1
DEL %MD%.zip > nul 2>&1
DEL %TEMP%\etcd.zip > nul 2>&1
DEL %TEMP%\pes.zip > nul 2>&1
DEL %TEMP%\micro.zip > nul 2>&1
DEL %TEMP%\vip.zip > nul 2>&1
DEL %TEMP%\pgsql.zip > nul 2>&1
DEL %TEMP%\patroni.zip > nul 2>&1
DEL Patroni-Env-Setup.exe > nul 2>&1
MKDIR %MD% || EXIT /B
COPY src\*.bat %MD%\ || EXIT /B
COPY src\*.ps1 %MD%\ || EXIT /B
XCOPY doc %MD%\doc\ /E || EXIT /B
@ECHO --- End bootstrapping ---
@ECHO --- Download ETCD ---
curl %ETCD_REF% --location --output %TEMP%\etcd.zip || EXIT /B
if exist %SEVENZIP% (
%SEVENZIP% x "%TEMP%\etcd.zip" -y -o"%CD%" || EXIT /B
) else (
powershell -Command "Expand-Archive '%TEMP%\etcd.zip' '%CD%'" || EXIT /B
)
REM timeouts are used here to give 7-Zip some time to release output folder and prevent "Access denied" error
TIMEOUT 5
MOVE etcd-* %MD%\etcd || EXIT /B
COPY src\etcd.yaml %MD%\etcd\ || EXIT /B
DEL %TEMP%\etcd.zip || EXIT /B
@ECHO --- ETCD downloaded ---
@ECHO --- Download PES GUI ---
curl %PES_REF% --location --output %TEMP%\pes.zip || EXIT /B
if exist %SEVENZIP% (
%SEVENZIP% x "%TEMP%\pes.zip" -y -o"%MD%"
) else (
powershell -Command "Expand-Archive '%TEMP%\pes.zip' '%MD%'"
)
DEL %TEMP%\pes.zip || EXIT /B
@ECHO --- PES GUI downloaded ---
@ECHO --- Download MICRO ---
curl %MICRO_REF% --location --output %TEMP%\micro.zip || EXIT /B
if exist %SEVENZIP% (
%SEVENZIP% x "%TEMP%\micro.zip" -y -o"%CD%"
) else (
powershell -Command "Expand-Archive '%TEMP%\micro.zip' '%CD%'"
)
TIMEOUT 5
MOVE micro-* %MD%\micro || EXIT /B
DEL %TEMP%\micro.zip || EXIT /B
@ECHO --- MICRO downloaded ---
@ECHO --- Download VIP-MANAGER ---
curl %VIP_REF% --location --output %TEMP%\vip.zip || EXIT /B
if exist %SEVENZIP% (
%SEVENZIP% x "%TEMP%\vip.zip" -y -o"%CD%"
) else (
powershell -Command "Expand-Archive '%TEMP%\vip.zip' '%CD%'"
)
TIMEOUT 5
MOVE vip-manager* %MD%\vip-manager || EXIT /B
DEL %MD%\vip-manager\*.yml || EXIT /B
COPY src\vip.yaml %MD%\vip-manager\ || EXIT /B
DEL %TEMP%\vip.zip || EXIT /B
@ECHO --- VIP-MANAGER downloaded ---
@ECHO --- Download POSTGRESQL ---
curl %PGSQL_REF% --location --output %TEMP%\pgsql.zip || EXIT /B
if exist %SEVENZIP% (
%SEVENZIP% x "%TEMP%\pgsql.zip" -y -o"%CD%"
) else (
powershell -Command "Expand-Archive '%TEMP%\pgsql.zip' '%CD%'"
)
TIMEOUT 5
MOVE pgsql* %MD%\pgsql || EXIT /B
RMDIR /Q /S "%MD%\pgsql\pgAdmin 4" "%MD%\pgsql\symbols" || EXIT /B
DEL %TEMP%\pgsql.zip || EXIT /B
@ECHO --- POSTGRESQL downloaded ---
@ECHO --- Download PATRONI ---
curl %PATRONI_REF% --location --output %TEMP%\patroni.zip || EXIT /B
if exist %SEVENZIP% (
%SEVENZIP% x "%TEMP%\patroni.zip" -y -o"%CD%"
) else (
powershell -Command "Expand-Archive '%TEMP%\patroni.zip' '%CD%'"
)
TIMEOUT 5
MOVE patroni-* %MD%\patroni || EXIT /B
DEL %MD%\patroni\postgres?.yml || EXIT /B
COPY src\patroni.yaml %MD%\patroni\ || EXIT /B
DEL %TEMP%\patroni.zip || EXIT /B
@ECHO --- PATRONI downloaded ---
@ECHO --- Update Python and PIP installation ---
CALL install-env.bat || EXIT /B
MOVE python-install.exe %MD%\ || EXIT /B
@ECHO --- Python and PIP installation updated ---
@ECHO --- Download PATRONI packages ---
CD %MD%\patroni
%PIP% download -r requirements.txt -d .patroni-packages
%PIP% download psycopg2-binary -d .patroni-packages
CD ..\..
@ECHO --- PATRONI packages downloaded ---
@ECHO --- Download WINSW ---
curl %WINSW_REF% --location --output %MD%\patroni\patroni_service.exe || EXIT /B
COPY src\patroni_service.xml %MD%\patroni\ || EXIT /B
COPY %MD%\patroni\patroni_service.exe %MD%\etcd\etcd_service.exe /B || EXIT /B
COPY src\etcd_service.xml %MD%\etcd\ || EXIT /B
COPY %MD%\patroni\patroni_service.exe %MD%\vip-manager\vip_service.exe /B || EXIT /B
COPY src\vip_service.xml %MD%\vip-manager\ || EXIT /B
@ECHO --- WINSW downloaded ---
@ECHO --- Creating windows installer ---
CALL make-installer.bat || EXIT /B
@ECHO --- Installer generated successfully ---
@ECHO --- Prepare archive ---
if exist %SEVENZIP% (
%SEVENZIP% a "%MD%.zip" -y "%MD%"
) else (
powershell -Command "Compress-Archive '%MD%' '%MD%.zip'"
)
@ECHO --- Archive compressed ---
@ECHO --- PACKAGING FINISHED ---