Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9e4e33c

Browse files
committed
This patch is to add more comments
to postgres.init.sh , clairify the optionsavailable, and to add easy supportfor installation of postgres into therunlevel system."sh postgres.init.sh install"Will now install "postgres" in the/etc/rc.d/init.d directory and execute/sbin/chkconfig to hook up the symboliclinks. An uninstall option is also added.Enclosed is the patch and the patched fileClark
1 parent40457df commit9e4e33c

File tree

1 file changed

+134
-47
lines changed

1 file changed

+134
-47
lines changed

‎contrib/linux/postgres.init.sh

Lines changed: 134 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,162 @@
11
#!/bin/sh
22
#
3-
# postgres.init Start postgres back end system.
3+
# postgres.init.sh - This script is used to start/stop
4+
# the postgreSQL listener process.
45
#
5-
# Author: Thomas Lockhart <lockhart@alumni.caltech.edu>
6-
# modified from other startup files in the RedHat Linux distribution
6+
# Usage
77
#
8-
# This version can log backend output through syslog using the local5 facility.
9-
# To enable this, edit /etc/syslog.conf to include a line similar to:
10-
# local5.* /var/log/postgres
11-
# and then set USE_SYSLOG to "yes" below
8+
# You can use this script manually, and/or you
9+
# can install this script into the runlevel system
10+
# by running "sh postgres.init.sh install"
11+
#
12+
# Credits
13+
#
14+
# Thomas Lockhart <lockhart@alumni.caltech.edu>
15+
# modified from other startup files in the
16+
# RedHat Linux distribution
17+
#
18+
# Clark Evans <cce@clarkevans.com>
19+
# cleaned up, added comments, etc.
20+
#
21+
# RedHat Stuff
22+
#
23+
# chkconfig: 345 85 15
24+
# description: Starts and stops the PostgreSQL backend daemon\
25+
# that handles all database requests.
26+
# processname: postmaster
27+
# pidfile: /var/run/postmaster.pid
28+
#
29+
#
30+
# Note
31+
#
32+
# This version can log backend output through syslog using
33+
# the local5 facility. To enable this, set USE_SYSLOG to "yes"
34+
# below and then edit /etc/syslog.conf to include a line
35+
# similar to:
36+
#
37+
# local5.* /var/log/postgres
38+
#
39+
# Config Variables
40+
#
41+
PGACCOUNT="postgres"
42+
#
43+
# The non-root user account which will be used to run the
44+
# PostgreSQL executeable. For this script to work, the
45+
# shell for this account must be SH/BASH.
46+
#
47+
# The following lines should be in this account's .bash_profile
48+
#
49+
# PATH=$PATH:$HOME/bin
50+
# MANPATH=$MANPATH:/opt/pgsql/man
51+
# PGLIB=/opt/pgsql/lib
52+
# PGDATA=/opt/pgsql/data
53+
#
54+
POSTMASTER="postmaster"
55+
#
56+
# The executable program which is to be run, in this case
57+
# it is the listener, which waits for requests on the port
58+
# specified during configuration.
59+
#
60+
USE_SYSLOG="yes"
61+
#
62+
# "yes" to enable syslog, "no" to go to /tmp/postgres.log
63+
#
64+
FACILITY="local5"
65+
#
66+
# can assign local0-local7 as the facility for logging
67+
#
68+
PGLOGFILE="/tmp/postgres.log"
69+
#
70+
# only used if syslog is disabled
1271
#
13-
#PGBIN="/opt/postgres/current/bin"# not used
14-
PGACCOUNT="postgres"# the postgres account (you called it something else?)
15-
POSTMASTER="postmaster"# this probably won't change
16-
17-
USE_SYSLOG="yes"# "yes" to enable syslog, "no" to go to /tmp/postgres.log
18-
FACILITY="local5"# can assign local0-local7 as the facility for logging
19-
PGLOGFILE="/tmp/postgres.log"# only used if syslog is disabled
20-
2172
PGOPTS="-B 256"
22-
#PGOPTS="-i -B 256"# -i to enable TCP/IP rather than Unix socket
73+
#
74+
# The B option sets the number of shared buffers
75+
#
76+
# Add the "-i" option to enable TCP/IP sockets in addition
77+
# to unix domain sockets. This is needed for Java's JDBC
78+
#
79+
# PGOPTS="-i -B 256"
80+
#
81+
# Add the -D option if you want to ovverride the PGDATA
82+
# environment variable defined in
83+
#
84+
# PGOPTS="-B 256 -D/opt/pgsql/data
85+
#
86+
# Add the -p option if you would like the listener to
87+
# attach to a port other than the one configured (5432?)
88+
#
89+
# PGOPTS="-B 256 -D/opt/pgsql_beta/data -p 5433"
90+
#
2391

2492
# Source function library.
2593
. /etc/rc.d/init.d/functions
2694

2795
# Get config.
2896
. /etc/sysconfig/network
2997

98+
#
3099
# Check that networking is up.
31100
# Pretty much need it for postmaster.
101+
#
32102
if [${NETWORKING}="no" ]
33103
then
34-
exit 0
104+
exit 0
35105
fi
36106

37-
#[ -f${PGBIN}/${POSTMASTER} ] || exit 0
107+
#[ -f/opt/pgsq//bin/postmaster ] || exit 0
38108

109+
#
39110
# See how we were called.
111+
#
40112
case"$1"in
41113
start)
42-
if [-f${PGLOGFILE} ]
43-
then
44-
mv${PGLOGFILE}${PGLOGFILE}.old
45-
fi
46-
echo -n"Starting postgres:"
47-
# force full login to get path names
48-
# my postgres runs SH/BASH so use proper syntax in redirection...
49-
if [${USE_SYSLOG}="yes" ];then
50-
su -${PGACCOUNT} -c"(${POSTMASTER}${PGOPTS} 2>&1 | logger -p${FACILITY}.notice) &"> /dev/null2>&1&
51-
else
52-
su -${PGACCOUNT} -c"${POSTMASTER}${PGOPTS} 2>>&1${PGLOGFILE} &"> /dev/null2>&1&
53-
fi
54-
sleep 5
55-
pid=`pidof${POSTMASTER}`
56-
echo -n"${POSTMASTER} [$pid]"
57-
#touch /var/lock/subsys/${POSTMASTER}
58-
echo
59-
;;
114+
if [-f${PGLOGFILE} ]
115+
then
116+
mv${PGLOGFILE}${PGLOGFILE}.old
117+
fi
118+
echo -n"Starting postgres:"
119+
#
120+
# force full login to get PGDATA and PGLIB path names
121+
# Since the login script for ${PGACCOUNT} is SH/BASH compliant,
122+
# we use proper redirection syntax...
123+
#
124+
if [${USE_SYSLOG}="yes" ];then
125+
su -${PGACCOUNT} -c"(${POSTMASTER}${PGOPTS} 2>&1 | logger -p${FACILITY}.notice) &"> /dev/null2>&1&
126+
else
127+
su -${PGACCOUNT} -c"${POSTMASTER}${PGOPTS} 2>>&1${PGLOGFILE} &"> /dev/null2>&1&
128+
fi
129+
sleep 5
130+
pid=`pidof${POSTMASTER}`
131+
echo -n"${POSTMASTER} [$pid]"
132+
# touch /var/lock/subsys/${POSTMASTER}
133+
echo
134+
;;
60135
stop)
61-
echo -n"Stopping postgres:"
62-
pid=`pidof${POSTMASTER}`
63-
if ["$pid"!="" ];then
64-
echo -n"${POSTMASTER} [$pid]"
65-
kill -TERM$pid
66-
sleep 1
67-
fi
68-
echo
69-
;;
136+
echo -n"Stopping postgres:"
137+
pid=`pidof${POSTMASTER}`
138+
if ["$pid"!="" ];then
139+
echo -n"${POSTMASTER} [$pid]"
140+
kill -TERM$pid
141+
sleep 1
142+
fi
143+
echo
144+
;;
145+
install)
146+
echo"Adding postgres to runlevel system."
147+
cp$0 /etc/rc.d/init.d/postgres
148+
/sbin/chkconfig --add postgres
149+
echo
150+
;;
151+
uninstall)
152+
echo"Deleting postgres from runlevel system."
153+
/sbin/chkconfig --del postgres
154+
rm /etc/rc.d/init.d/postgres
155+
echo
156+
;;
70157
*)
71-
echo"Usage:$0 {start|stop}"
72-
exit 1
158+
echo"Usage:$0 {start|stop|install|uninstall}"
159+
exit 1
73160
esac
74161

75162
exit 0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp