@@ -164,16 +164,8 @@ func RunMigration(
164164 }
165165
166166 // now that everything is migrated, we need to fix SELinux permission
167- if utils .IsInstalled ("restorecon" ) {
168- for _ , volumeMount := range utils .ServerVolumeMounts {
169- mountPoint , err := GetMountPoint (volumeMount .Name )
170- if err != nil {
171- return nil , utils .Errorf (err , L ("cannot inspect volume %s" ), volumeMount )
172- }
173- if err := utils .RunCmdStdMapping (zerolog .DebugLevel , "restorecon" , "-F" , "-r" , "-v" , mountPoint ); err != nil {
174- return nil , utils .Errorf (err , L ("cannot restore %s SELinux permissions" ), mountPoint )
175- }
176- }
167+ if err := restoreSELinuxContext (); err != nil {
168+ return nil , err
177169 }
178170
179171 dataPath := path .Join (scriptDir , "data" )
@@ -191,6 +183,21 @@ func RunMigration(
191183 return extractedData , nil
192184}
193185
186+ func restoreSELinuxContext () error {
187+ if utils .IsInstalled ("restorecon" ) {
188+ for _ , volumeMount := range utils .ServerVolumeMounts {
189+ mountPoint , err := GetMountPoint (volumeMount .Name )
190+ if err != nil {
191+ return utils .Errorf (err , L ("cannot inspect volume %s" ), volumeMount )
192+ }
193+ if err := utils .RunCmdStdMapping (zerolog .DebugLevel , "restorecon" , "-F" , "-r" , "-v" , mountPoint ); err != nil {
194+ return utils .Errorf (err , L ("cannot restore %s SELinux permissions" ), mountPoint )
195+ }
196+ }
197+ }
198+ return nil
199+ }
200+
194201// RunPgsqlVersionUpgrade perform a PostgreSQL major upgrade.
195202func RunPgsqlVersionUpgrade (
196203 authFile string ,
0 commit comments