diff options
author | Pavel Raiskup <praiskup@redhat.com> | 2015-02-10 10:49:36 +0100 |
---|---|---|
committer | Pavel Raiskup <praiskup@redhat.com> | 2015-02-10 10:49:36 +0100 |
commit | 84219fefff0b9d00c94c72cf0cd903611b1cf05f (patch) | |
tree | 264b76025c5b9536123def9a3990bc7922cc3213 | |
parent | 82b9bab207ea3cc351581bab89abce48cff2ad12 (diff) | |
download | postgresql-setup-84219fefff0b9d00c94c72cf0cd903611b1cf05f.tar.gz postgresql-setup-84219fefff0b9d00c94c72cf0cd903611b1cf05f.tar.xz postgresql-setup-84219fefff0b9d00c94c72cf0cd903611b1cf05f.zip |
configury: use one single variable SU_POSTGRES
We use 'su' only for 'postgres' user purposes. So have one,
configure-time-proven command. Also, in the previous commit I
forgot to fix sysvinit file.
* configure.ac (SU_POSTGRES): New variable.
* postgresql-setup.in ($SU_POSTGRES): Use detected @SU_POSTGRES@.
($SU, $SU_L_POSTGRES): Avoid usage of those.
* postgresql.init.in: Likewise.
* .gitignore: Remove typoed ignore.
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | postgresql-setup.in | 9 | ||||
-rw-r--r-- | postgresql.init.in | 19 |
4 files changed, 14 insertions, 21 deletions
@@ -21,9 +21,8 @@ postgresql*-ctl postgresql*.service postgresql*-setup postgresql*-setup.1 -postgresql*.init README.rpm-dist testsuite testsuite.dir/ initdb -upgrade
\ No newline at end of file +upgrade diff --git a/configure.ac b/configure.ac index 792dcff..a793a07 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,7 @@ sed_subst_var_pattern(POSTGRES_HOMEDIR) sed_subst_var_pattern(PREVMAJORVERSION) sed_subst_var_pattern(PREVPGENGINE) sed_subst_var_pattern(README_DIST) -sed_subst_var_pattern(SU) +sed_subst_var_pattern(SU_POSTGRES) sed_subst_var_pattern(systemdunitsdir) sed_subst_var_pattern(userunitsdir) sed_subst_var_pattern(TEST_GEN_FILES_LIST) @@ -82,6 +82,8 @@ test -z "$ac_cv_path_SED" && AC_PATH_PROGS([SU], [runuser su]) test -z "$ac_cv_path_SU" && AC_MSG_ERROR([Neither 'runuser' nor 'su' program found]) +SU_POSTGRES="$SU -s /bin/sh -l postgres" +AC_SUBST([SU_POSTGRES]) PGSETUP_PACKAGING_INIT diff --git a/postgresql-setup.in b/postgresql-setup.in index 959ee06..f457636 100644 --- a/postgresql-setup.in +++ b/postgresql-setup.in @@ -27,9 +27,8 @@ README_DIST=@README_DIST@ # Home directory of postgres user POSTGRES_HOMEDIR=@POSTGRES_HOMEDIR@ -SU=@SU@ - -SU_L_POSTGRES="$SU -s /bin/sh -l postgres" +# Convenient tool-aliases +SU_POSTGRES="@SU_POSTGRES@" # The where PostgreSQL server listens by default PGPORT_DEF=5432 @@ -126,7 +125,7 @@ perform_initdb() initdbcmd="$PGENGINE/initdb --pgdata='$pgdata' --auth='ident'" initdbcmd+=" $PGSETUP_INITDB_OPTIONS" - $SU_L_POSTGRES -c "$initdbcmd" >> "$initdb_log" 2>&1 < /dev/null + $SU_POSTGRES -c "$initdbcmd" >> "$initdb_log" 2>&1 < /dev/null # Create directory for postmaster log files mkdir "$pgdata/pg_log" @@ -223,7 +222,7 @@ upgrade() # Create empty new-format database if perform_initdb; then # Do the upgrade - $SU_L_POSTGRES -c "$PGENGINE/pg_upgrade \ + $SU_POSTGRES -c "$PGENGINE/pg_upgrade \ '--old-bindir=$PREVPGENGINE' \ '--new-bindir=$PGENGINE' \ '--old-datadir=$pgdataold' \ diff --git a/postgresql.init.in b/postgresql.init.in index f3e21c8..b183486 100644 --- a/postgresql.init.in +++ b/postgresql.init.in @@ -46,14 +46,7 @@ then NAME=${NAME:3} fi -# For SELinux we need to use 'runuser' not 'su' -if [ -x /sbin/runuser ] -then - SU=runuser -else - SU=su -fi - +SU_POSTGRES="@SU_POSTGRES@" # Set defaults for configuration variables PGENGINE=/usr/bin @@ -120,7 +113,7 @@ start(){ echo -n "$PSQL_START" test x"$PG_OOM_ADJ" != x && echo "$PG_OOM_ADJ" > /proc/self/oom_adj - $SU -l postgres -c "$PGENGINE/postmaster -p '$PGPORT' -D '$PGDATA' ${PGOPTS} &" >> "$PGLOG" 2>&1 < /dev/null + $SU_POSTGRES -c "$PGENGINE/postmaster -p '$PGPORT' -D '$PGDATA' ${PGOPTS} &" >> "$PGLOG" 2>&1 < /dev/null sleep 2 pid=`head -n 1 "$PGDATA/postmaster.pid" 2>/dev/null` if [ "x$pid" != x ] @@ -140,7 +133,7 @@ stop(){ echo -n $"Stopping ${NAME} service: " if [ -e "$lockfile" ] then - $SU -l postgres -c "$PGENGINE/pg_ctl stop -D '$PGDATA' -s -m fast" > /dev/null 2>&1 < /dev/null + $SU_POSTGRES -c "$PGENGINE/pg_ctl stop -D '$PGDATA' -s -m fast" > /dev/null 2>&1 < /dev/null ret=$? if [ $ret -eq 0 ] then @@ -168,7 +161,7 @@ condrestart(){ } reload(){ - $SU -l postgres -c "$PGENGINE/pg_ctl reload -D '$PGDATA' -s" > /dev/null 2>&1 < /dev/null + $SU_POSTGRES -c "$PGENGINE/pg_ctl reload -D '$PGDATA' -s" > /dev/null 2>&1 < /dev/null } # code shared between initdb and upgrade actions @@ -192,7 +185,7 @@ perform_initdb(){ fi # Initialize the database - $SU -l postgres -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'" >> "$PGLOG" 2>&1 < /dev/null + $SU_POSTGRES -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'" >> "$PGLOG" 2>&1 < /dev/null # Create directory for postmaster log mkdir "$PGDATA/pg_log" @@ -267,7 +260,7 @@ upgrade(){ if perform_initdb then # Do the upgrade - $SU -l postgres -c "$PGENGINE/pg_upgrade \ + $SU_POSTGRES -c "$PGENGINE/pg_upgrade \ '--old-bindir=$PREVPGENGINE' \ '--new-bindir=$PGENGINE' \ '--old-datadir=$PGDATAOLD' \ |