@@ -208,11 +208,15 @@ spec:
208208 (sed "/^postgres:x:/ d; /^[^:]*:x:${uid}:/ d" /etc/passwd
209209 echo "postgres:x:${uid}:${gid%% *}::${data_volume}:") > "${NSS_WRAPPER_PASSWD}"
210210 export LD_PRELOAD='libnss_wrapper.so' NSS_WRAPPER_GROUP NSS_WRAPPER_PASSWD
211+ id; [[ "$(id -nu)" == 'postgres' && "$(id -ng)" == 'postgres' ]]
212+ [[ -x /usr/pgsql-"${old_version}"/bin/postgres ]]
213+ [[ -x /usr/pgsql-"${new_version}"/bin/initdb ]]
214+ [[ -d /pgdata/pg"${old_version}" ]]
211215 cd /pgdata || exit
212216 echo -e "Step 1: Making new pgdata directory...\n"
213217 mkdir /pgdata/pg"${new_version}"
214218 echo -e "Step 2: Initializing new pgdata directory...\n"
215- /usr/pgsql-"${new_version}"/bin/initdb -k -D /pgdata/pg"${new_version}"
219+ /usr/pgsql-"${new_version}"/bin/initdb --allow-group-access - k -D /pgdata/pg"${new_version}"
216220 echo -e "\nStep 3: Setting the expected permissions on the old pgdata directory...\n"
217221 chmod 750 /pgdata/pg"${old_version}"
218222 echo -e "Step 4: Copying shared_preload_libraries setting to new postgresql.conf file...\n"
@@ -263,7 +267,7 @@ status: {}
263267
264268 tdeJob := reconciler .generateUpgradeJob (ctx , upgrade , startup , "echo testKey" )
265269 assert .Assert (t , cmp .MarshalContains (tdeJob ,
266- `/usr/pgsql-"${new_version}"/bin/initdb -k -D /pgdata/pg"${new_version}" --encryption-key-command "echo testKey"` ))
270+ `/usr/pgsql-"${new_version}"/bin/initdb --allow-group-access - k -D /pgdata/pg"${new_version}" --encryption-key-command "echo testKey"` ))
267271}
268272
269273func TestGenerateRemoveDataJob (t * testing.T ) {
0 commit comments