@@ -85,11 +85,6 @@ cleanup() {
85
85
fi
86
86
fi
87
87
88
- if [ -f " /usr/lib/postgresql/lib/aarch64/libpq.so.5.bak" ]; then
89
- rm /usr/lib/postgresql/lib/aarch64/libpq.so.5
90
- mv /usr/lib/postgresql/lib/aarch64/libpq.so.5.bak /usr/lib/postgresql/lib/aarch64/libpq.so.5
91
- fi
92
-
93
88
if [ " $IS_DRY_RUN " = false ]; then
94
89
echo " Restarting postgresql"
95
90
systemctl enable postgresql
@@ -183,16 +178,6 @@ function initiate_upgrade {
183
178
184
179
chown -R postgres:postgres " /tmp/pg_upgrade_bin/$PGVERSION "
185
180
186
- # Make latest libpq available to pg_upgrade
187
- mkdir -p /usr/lib/aarch64-linux-gnu
188
- if [ -f " /usr/lib/aarch64-linux-gnu/libpq.so.5" ]; then
189
- mv /usr/lib/aarch64-linux-gnu/libpq.so.5 /usr/lib/aarch64-linux-gnu/libpq.so.5.bak
190
- fi
191
- if [ -f " ${PG_UPGRADE_BIN_DIR} /libpq.so.5" ]; then
192
- cp " ${PG_UPGRADE_BIN_DIR} /libpq.so.5" " ${PGLIBNEW} /libpq.so.5"
193
- fi
194
- ln -s " ${PGLIBNEW} /libpq.so.5" /usr/lib/aarch64-linux-gnu/libpq.so.5
195
-
196
181
# upgrade job outputs a log in the cwd; needs write permissions
197
182
mkdir -p /tmp/pg_upgrade/
198
183
chown -R postgres:postgres /tmp/pg_upgrade/
@@ -208,15 +193,21 @@ function initiate_upgrade {
208
193
apt-get update && apt --fix-broken install -y libprotobuf-c1
209
194
fi
210
195
196
+ echo " 4. Setup locale if required"
197
+ if [[ ! " $( cat /etc/locale.gen | grep " ^en_US.UTF-8" ) " ]]; then
198
+ echo " en_US.UTF-8 UTF-8" >> /etc/locale.gen
199
+ locale-gen
200
+ fi
201
+
211
202
if [ " $IS_DRY_RUN " = false ]; then
212
203
# awk NF==3 prints lines with exactly 3 fields, which are the block devices currently not mounted anywhere
213
204
# excluding nvme0 since it is the root disk
214
- echo " 4 . Determining block device to mount"
205
+ echo " 5 . Determining block device to mount"
215
206
BLOCK_DEVICE=$( lsblk -dprno name,size,mountpoint,type | grep " disk" | grep -v " nvme0" | awk ' NF==3 { print $1; }' )
216
207
echo " Block device found: $BLOCK_DEVICE "
217
208
218
209
mkdir -p " $MOUNT_POINT "
219
- echo " 5 . Mounting block device"
210
+ echo " 6 . Mounting block device"
220
211
221
212
sleep 5
222
213
e2fsck -pf " $BLOCK_DEVICE "
@@ -234,10 +225,10 @@ function initiate_upgrade {
234
225
chmod 600 /etc/postgresql-custom/pgsodium_root.key
235
226
fi
236
227
237
- echo " 6 . Disabling extensions and generating post-upgrade script"
228
+ echo " 7 . Disabling extensions and generating post-upgrade script"
238
229
handle_extensions
239
230
240
- echo " 7 . Granting SUPERUSER to postgres user"
231
+ echo " 8 . Granting SUPERUSER to postgres user"
241
232
run_sql -c " ALTER USER postgres WITH SUPERUSER;"
242
233
243
234
if [ -d " /usr/share/postgresql/${PGVERSION} " ]; then
@@ -275,7 +266,7 @@ function initiate_upgrade {
275
266
276
267
export LD_LIBRARY_PATH=" ${PGLIBNEW} "
277
268
278
- echo " 8 . Creating new data directory, initializing database"
269
+ echo " 9 . Creating new data directory, initializing database"
279
270
chown -R postgres:postgres " $MOUNT_POINT /"
280
271
rm -rf " ${PGDATANEW:? } /"
281
272
su -c " $PGBINNEW /initdb -L $PGSHARENEW -D $PGDATANEW /" -s " $SHELL " postgres
297
288
if [ " $IS_DRY_RUN " = true ]; then
298
289
UPGRADE_COMMAND=" $UPGRADE_COMMAND --check"
299
290
else
300
- echo " 9 . Stopping postgres; running pg_upgrade"
291
+ echo " 10 . Stopping postgres; running pg_upgrade"
301
292
302
293
# Extra work to ensure postgres is actually stopped
303
294
# Mostly needed for PG12 projects with odd systemd unit behavior
@@ -312,20 +303,20 @@ EOF
312
303
su -c " $UPGRADE_COMMAND " -s " $SHELL " postgres
313
304
314
305
# copying custom configurations
315
- echo " 10 . Copying custom configurations"
306
+ echo " 11 . Copying custom configurations"
316
307
mkdir -p " $MOUNT_POINT /conf"
317
308
cp -R /etc/postgresql-custom/* " $MOUNT_POINT /conf/"
318
309
319
310
# removing wal-g config as to allow it to be explicitly enabled on the new instance
320
311
rm -f " $MOUNT_POINT /conf/wal-g.conf"
321
312
322
313
# copy sql files generated by pg_upgrade
323
- echo " 11 . Copying sql files generated by pg_upgrade"
314
+ echo " 12 . Copying sql files generated by pg_upgrade"
324
315
mkdir -p " $MOUNT_POINT /sql"
325
316
cp /tmp/pg_upgrade/* .sql " $MOUNT_POINT /sql/" || true
326
317
chown -R postgres:postgres " $MOUNT_POINT /sql/"
327
318
328
- echo " 12 . Cleaning up"
319
+ echo " 13 . Cleaning up"
329
320
cleanup " complete"
330
321
}
331
322
0 commit comments