Ver Fonte

Revert "Remove unneeded crap"

This reverts commit 1b834d3df779bf96ef55a969cd74d568ff88e650.
Andy Baugh há 5 anos atrás
pai
commit
9f82e04ea7
1 ficheiros alterados com 25 adições e 0 exclusões
  1. 25 0
      lib/Troglodyne/API/Postgres.pm

+ 25 - 0
lib/Troglodyne/API/Postgres.pm

@@ -285,6 +285,31 @@ sub _real_install {
     $exit = _saferun( $lh, qw{systemctl enable}, "postgresql-$ver2install" );
     return _cleanup("$exit", $lh) if $exit;
 
+    # Update alternatives. Should be fine to use --auto, as no other alternatives will exist for the installed version.
+    # Create alternatives for pg_ctl, etc. as those don't get made by the RPM.
+    print $lh "# [INFO] Updating alternatives to ensure the newly installed version is considered canonical...\n";
+    my @normie_alts = qw{pg_ctl initdb pg_config pg_upgrade};
+    my @manual_alts = qw{clusterdb createdb createuser dropdb droplang dropuser pg_basebackup pg_dump pg_dumpall pg_restore psql psql-reindexdb vaccumdb};
+    foreach my $alt ( @normie_alts ) {
+        $exit = _saferun( $lh, qw{update-alternatives --install}, "/usr/bin/$alt", "pgsql-$alt", "/usr/pgsql-$ver2install/bin/$alt", "50" );
+        return _cleanup("$exit", $lh) if $exit;
+        $exit = _saferun( $lh, qw{update-alternatives --auto}, "pgsql-$alt" );
+        return _cleanup("$exit", $lh) if $exit;
+    }
+    foreach my $alt ( @manual_alts ) {
+        $exit = _saferun( $lh, qw{update-alternatives --auto}, "pgsql-$alt" );
+        return _cleanup("$exit", $lh) if $exit;
+        $exit = _saferun( $lh, qw{update-alternatives --auto}, "pgsql-${alt}man" );
+        return _cleanup("$exit", $lh) if $exit;
+    }
+
+    print $lh "# [INFO] Writing new .bash_profile for the 'postgres' user...\n";
+    my $bash_profile = "[ -f /etc/profile ] && source /etc/profile
+PGDATA=/var/lib/pgsql/$ver2install/data
+export PGDATA
+[ -f /var/lib/pgsql/.pgsql_profile ] && source /var/lib/pgsql/.pgsql_profile
+export PATH=\$PATH:/usr/pgsql-$ver2install/bin\n";
+    File::Slurper::write_text( '/var/lib/pgsql/.bash_profile', $bash_profile );
     if($ccs_installed && $ccs_enabled) {
         print $lh "# [INFO] Re-Enabling cpanel-ccs-calendarserver...\n";
         $exit = _saferun( $lh, qw{/usr/local/cpanel/bin/whmapi1 configureservice service=cpanel-ccs enabled=1 monitored=1} );