Обсуждение: startup scripts don't function properly

Поиск
Список
Период
Сортировка

startup scripts don't function properly

От
VASQUEZ_JASON@LILLY.COM
Дата:
There are 2 problems:

1.  The "su" commands for start/stop/restart/status are in the form of "su
-".  This picks up the environment of the postgres user, which wipes out
the environment variables that were set earlier in this script (e.g.,
PGDATA).  Quick solution is to remove the extra dashes.

2.  (Not necessarily a problem!) Scripts default to not allow TCP/IP
connections.  Adding -o "-i" to start and restart fixed this problem. This
is understandable from a security standpoint.  Maybe an environment
variable could be set in the "Editable" portion of the script which would
turn this on or off, or at least a set of parameters to pass to
postmaster.

Here's a diff against 7.1 (release) that represents my current startup
script:


$ diff -u /usr/local/src/postgresql-7.1/contrib/start-scripts/linux
/etc/rc.d/init.d/postgres
--- /usr/local/src/postgresql-7.1/contrib/start-scripts/linux   Thu Feb  8
14:53:33 2001
+++ /etc/rc.d/init.d/postgres   Wed Apr 18 07:48:53 2001
@@ -64,21 +64,21 @@
 case $1 in
   start)
        $ECHO_N "Starting PostgreSQL: "$ECHO_C
-       su - $PGUSER -c "$DAEMON start -s -l $PGLOG"
+       su $PGUSER -c "$DAEMON start -o "-i" -s -l $PGLOG"
        echo "ok"
        ;;
   stop)
        echo -n "Stopping PostgreSQL: "
-       su - $PGUSER -c "$DAEMON stop -s -m fast"
+       su $PGUSER -c "$DAEMON stop -s -m fast"
        echo "ok"
        ;;
   restart)
        echo -n "Restarting PostgreSQL: "
-       su - $PGUSER -c "$DAEMON restart -s -m fast"
+       su $PGUSER -c "$DAEMON restart -o "-i" -s -m fast"
        echo "ok"
        ;;
   status)
-       su - $PGUSER -c "$DAEMON status"
+       su $PGUSER -c "$DAEMON status"
        ;;
   *)
        # Print help

Re: startup scripts don't function properly

От
Lamar Owen
Дата:
VASQUEZ_JASON@LILLY.COM wrote:
> 2.  (Not necessarily a problem!) Scripts default to not allow TCP/IP
> connections.  Adding -o "-i" to start and restart fixed this problem.
>  This is understandable from a security standpoint.  Maybe an
> environment variable could be set in the "Editable" portion of the
> script which would turn this on or off, or at least a set of
> parameters to pass to postmaster.

See the file postgresql.conf in the database directory.
--
Lamar Owen
WGCR Internet Radio
1 Peter 4:11

Re: startup scripts don't function properly

От
Peter Eisentraut
Дата:
VASQUEZ_JASON@LILLY.COM writes:

> 1.  The "su" commands for start/stop/restart/status are in the form of "su
> -".  This picks up the environment of the postgres user, which wipes out
> the environment variables that were set earlier in this script (e.g.,
> PGDATA).  Quick solution is to remove the extra dashes.

I have added -D options to the pg_ctl invocation.  Leaving in the '-' is
probably a good idea.

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter