mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 17:23:04 +01:00
fixed a couple of issues with firebird SS install/startup/shutdown/uninstall
This commit is contained in:
parent
1385c7c472
commit
f5c2df7072
@ -31,7 +31,7 @@
|
|||||||
# Contributor(s):
|
# Contributor(s):
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# $Id: postinstall.sh.in,v 1.13 2005-08-16 10:04:11 alexpeshkoff Exp $
|
# $Id: postinstall.sh.in,v 1.13.4.1 2006-04-16 11:51:55 alexpeshkoff Exp $
|
||||||
#
|
#
|
||||||
|
|
||||||
# The post install script for Firebird Classic
|
# The post install script for Firebird Classic
|
||||||
@ -87,7 +87,7 @@
|
|||||||
|
|
||||||
|
|
||||||
# Update ownership and SUID bits for programs.
|
# Update ownership and SUID bits for programs.
|
||||||
chown -R $RunUser.$RunUser $FBRootDir
|
chown -R $RunUser:$RunUser $FBRootDir
|
||||||
|
|
||||||
fixFilePermissions
|
fixFilePermissions
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
FIREBIRD=@prefix@
|
FIREBIRD=@prefix@
|
||||||
FBRunUser=firebird
|
FBRunUser=firebird
|
||||||
FB_OPTS="-start -forever"
|
pidfile=/var/run/firebird/`basename $0`.pid
|
||||||
|
FB_OPTS="-pidfile $pidfile -start -forever"
|
||||||
# WARNING: in a real-world installation, you should not put the
|
# WARNING: in a real-world installation, you should not put the
|
||||||
# SYSDBA password in a publicly-readable file.
|
# SYSDBA password in a publicly-readable file.
|
||||||
# Eventually this file should not need to contain any passwords.
|
# Eventually this file should not need to contain any passwords.
|
||||||
@ -41,7 +42,10 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
echo -n "Stopping Firebird server: "
|
echo -n "Stopping Firebird server: "
|
||||||
killall fbserver
|
if [ -f $pidfile ]
|
||||||
|
then
|
||||||
|
kill `cat $pidfile`
|
||||||
|
fi
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
;;
|
;;
|
||||||
restart|reload)
|
restart|reload)
|
||||||
|
@ -11,13 +11,7 @@
|
|||||||
|
|
||||||
FIREBIRD=@prefix@
|
FIREBIRD=@prefix@
|
||||||
FBRunUser=firebird
|
FBRunUser=firebird
|
||||||
# WARNING: in a real-world installation, you should not put the
|
pidfile=/var/run/firebird/`basename $0`.pid
|
||||||
# SYSDBA password in a publicly-readable file.
|
|
||||||
# Eventually this file should not need to contain any passwords.
|
|
||||||
# as root user alone should be sufficient privledge to stop/start
|
|
||||||
# the server.
|
|
||||||
|
|
||||||
|
|
||||||
export FIREBIRD
|
export FIREBIRD
|
||||||
|
|
||||||
|
|
||||||
@ -30,14 +24,16 @@ export FIREBIRD
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
echo -n "Starting Firebird server: "
|
echo -n "Starting Firebird server: "
|
||||||
echo '$FIREBIRD/bin/fbmgr -start -forever' | su $FBRunUser
|
echo '$FIREBIRD/bin/fbmgr -pidfile $pidfile -start -forever' | su $FBRunUser
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
echo -n "Stopping Firebird server: "
|
echo -n "Stopping Firebird server: "
|
||||||
killall fbserver
|
if [ -f $pidfile ]
|
||||||
|
then
|
||||||
|
kill `cat $pidfile`
|
||||||
|
fi
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
# [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/identd
|
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
RETVAL=0
|
RETVAL=0
|
||||||
|
@ -11,15 +11,14 @@
|
|||||||
|
|
||||||
FIREBIRD=@prefix@
|
FIREBIRD=@prefix@
|
||||||
FBRunUser=firebird
|
FBRunUser=firebird
|
||||||
|
pidfile=/var/run/firebird/`basename $0`.pid
|
||||||
|
FB_OPTS="-pidfile $pidfile -start -forever"
|
||||||
|
|
||||||
# WARNING: in a real-world installation, you should not put the
|
# NOTE: Normally firebird installation creates /etc/gds_hosts.equiv,
|
||||||
# SYSDBA password in a publicly-readable file.
|
# making it possible normal startup procedure to run.
|
||||||
# Eventually this file should not need to contain any passwords.
|
# In case of manually copying, make sure you have localhost in your
|
||||||
# as root user alone should be sufficient privledge to stop/start
|
# /etc/gds_hosts.equiv (or hosts.equiv) file.
|
||||||
# the server.
|
# See next 2 lines for example of hosts.equiv contents:
|
||||||
|
|
||||||
# NOTE: make sure you have localhost in your hosts.equiv file see next 2
|
|
||||||
# lines for example of hosts.equiv contents
|
|
||||||
#localhost.localdomain
|
#localhost.localdomain
|
||||||
#localhost
|
#localhost
|
||||||
|
|
||||||
@ -28,12 +27,14 @@ export FIREBIRD
|
|||||||
|
|
||||||
MANAGER=$FIREBIRD/bin/fbmgr.bin
|
MANAGER=$FIREBIRD/bin/fbmgr.bin
|
||||||
|
|
||||||
start(){
|
start(){
|
||||||
echo -n "Starting Firebird server: "
|
ebegin "Starting firebird server"
|
||||||
echo $MANAGER -start -forever | su $FBRunUser
|
start-stop-daemon --oknodo --start --pidfile $pidfile --chuid $FBRunUser --startas $MANAGER -- $FB_OPTS
|
||||||
}
|
eend $?
|
||||||
|
}
|
||||||
|
|
||||||
stop(){
|
stop(){
|
||||||
echo -n "Stopping Firebird server: "
|
ebegin "Stopping firebird"
|
||||||
killall fbserver
|
start-stop-daemon --stop --pidfile $pidfile --oknodo
|
||||||
}
|
eend $?
|
||||||
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
FIREBIRD=@prefix@
|
FIREBIRD=@prefix@
|
||||||
FBRunUser=firebird
|
FBRunUser=firebird
|
||||||
|
pidfile=/var/run/firebird/`basename $0`.pid
|
||||||
|
|
||||||
export FIREBIRD
|
export FIREBIRD
|
||||||
|
|
||||||
@ -31,14 +32,17 @@ case "$1" in
|
|||||||
start)
|
start)
|
||||||
echo -n "Starting Firebird server: "
|
echo -n "Starting Firebird server: "
|
||||||
|
|
||||||
daemon --user $FBRunUser $FIREBIRD/bin/fbmgr -start -forever
|
daemon --user $FBRunUser $FIREBIRD/bin/fbmgr -pidfile $pidfile -start -forever
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
echo
|
echo
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
echo -n "Stopping Firebird server: "
|
echo -n "Stopping Firebird server: "
|
||||||
|
|
||||||
killall fbserver
|
if [ -f $pidfile ]
|
||||||
|
then
|
||||||
|
kill `cat $pidfile`
|
||||||
|
fi
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
# echo
|
# echo
|
||||||
# [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/identd
|
# [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/identd
|
||||||
|
@ -41,6 +41,7 @@ test "$START_FIREBIRD" = yes || exit 0
|
|||||||
|
|
||||||
FIREBIRD=@prefix@
|
FIREBIRD=@prefix@
|
||||||
FBRunUser=firebird
|
FBRunUser=firebird
|
||||||
|
pidfile=/var/run/firebird/`basename $0`.pid
|
||||||
|
|
||||||
export FIREBIRD
|
export FIREBIRD
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ case "$1" in
|
|||||||
|
|
||||||
# NOTE: startproc return 0, even if service is
|
# NOTE: startproc return 0, even if service is
|
||||||
# already running to match LSB spec.
|
# already running to match LSB spec.
|
||||||
startproc -u $FBRunUser $FIREBIRD/bin/fbguard -forever
|
startproc -u $FBRunUser $FIREBIRD/bin/fbmgr -pidfile $pidfile -start -forever
|
||||||
|
|
||||||
# Remember status and be verbose
|
# Remember status and be verbose
|
||||||
rc_status -v
|
rc_status -v
|
||||||
@ -96,13 +97,12 @@ case "$1" in
|
|||||||
## Stop daemon with killproc(8) and if this fails
|
## Stop daemon with killproc(8) and if this fails
|
||||||
## set echo the echo return value.
|
## set echo the echo return value.
|
||||||
|
|
||||||
# WARNING: in a real-world installation, you should not put the
|
## I had to use generic approach here - I can't test on suse. AP.
|
||||||
# SYSDBA password in a publicly-readable file.
|
if [ -f $pidfile ]
|
||||||
# Eventually this file should not need to contain any passwords.
|
then
|
||||||
# as root user alone should be sufficient privledge to stop/start
|
kill `cat $pidfile`
|
||||||
# the server.
|
fi
|
||||||
|
|
||||||
killall fbserver
|
|
||||||
|
|
||||||
# Remember status and be verbose
|
# Remember status and be verbose
|
||||||
rc_status -v
|
rc_status -v
|
||||||
@ -141,7 +141,7 @@ case "$1" in
|
|||||||
# 3 - service not running
|
# 3 - service not running
|
||||||
|
|
||||||
# NOTE: checkproc returns LSB compliant status values.
|
# NOTE: checkproc returns LSB compliant status values.
|
||||||
checkproc $FIREBIRD/bin/fbguard
|
checkproc $FIREBIRD/bin/fbserver
|
||||||
rc_status -v
|
rc_status -v
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
RunUser=firebird
|
RunUser=firebird
|
||||||
export RunUser
|
export RunUser
|
||||||
|
RunGroup=firebird
|
||||||
|
export RunGroup
|
||||||
|
PidDir=/var/run/firebird
|
||||||
|
export PidDir
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
# Add new user and group
|
# Add new user and group
|
||||||
@ -114,7 +118,7 @@ stopSuperServerIfRunning() {
|
|||||||
then
|
then
|
||||||
init_d=`getInitScriptLocation`
|
init_d=`getInitScriptLocation`
|
||||||
|
|
||||||
if [ $init_d ]
|
if [ -x "$init_d" ]
|
||||||
then
|
then
|
||||||
$init_d stop
|
$init_d stop
|
||||||
fi
|
fi
|
||||||
|
@ -70,7 +70,7 @@ installInitdScript() {
|
|||||||
# Install the firebird init.d script
|
# Install the firebird init.d script
|
||||||
cp $FBRootDir/misc/$srcScript $initScript
|
cp $FBRootDir/misc/$srcScript $initScript
|
||||||
chown root:root $initScript
|
chown root:root $initScript
|
||||||
chmod ug=rx,o= $initScript # contains password hence no world read.
|
chmod ug=rx,o=r $initScript
|
||||||
|
|
||||||
|
|
||||||
# RedHat and Mandrake specific
|
# RedHat and Mandrake specific
|
||||||
@ -101,6 +101,9 @@ installInitdScript() {
|
|||||||
cp $FBRootDir/misc/rc.config.firebird /etc/sysconfig/firebird
|
cp $FBRootDir/misc/rc.config.firebird /etc/sysconfig/firebird
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Create directory to store pidfile
|
||||||
|
mkdir $PidDir
|
||||||
|
chown $RunUser:$RunGroup $PidDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,3 +34,8 @@ then
|
|||||||
rm -f /etc/rc.d/init.d/firebird
|
rm -f /etc/rc.d/init.d/firebird
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -d $PidDir ]
|
||||||
|
then
|
||||||
|
rm -rf $PidDir
|
||||||
|
fi
|
||||||
|
@ -102,7 +102,7 @@ fixFilePermissions() {
|
|||||||
# make examples db's writable by group
|
# make examples db's writable by group
|
||||||
for i in `find . -name '*.fdb' -print`
|
for i in `find . -name '*.fdb' -print`
|
||||||
do
|
do
|
||||||
chown $RunUser.$RunUser $i
|
chown $RunUser:$RunUser $i
|
||||||
chmod ug=rw,o= $i
|
chmod ug=rw,o= $i
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ removeLinksForBackCompatibility() {
|
|||||||
|
|
||||||
MakeFileFirebirdWritable() {
|
MakeFileFirebirdWritable() {
|
||||||
FileName=$1
|
FileName=$1
|
||||||
chown $RunUser.$RunUser $FileName
|
chown $RunUser:$RunUser $FileName
|
||||||
chmod 0644 $FileName
|
chmod 0644 $FileName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ fixFilePermissions() {
|
|||||||
|
|
||||||
# Security database
|
# Security database
|
||||||
# Nobody besides firebird permitted to even read this file
|
# Nobody besides firebird permitted to even read this file
|
||||||
chown $RunUser.$RunUser $SecurityDatabase
|
chown $RunUser:$RunUser $SecurityDatabase
|
||||||
chmod 0600 $SecurityDatabase
|
chmod 0600 $SecurityDatabase
|
||||||
|
|
||||||
# fix up examples' permissions
|
# fix up examples' permissions
|
||||||
@ -61,7 +61,7 @@ fixFilePermissions() {
|
|||||||
# make examples db's writable by group
|
# make examples db's writable by group
|
||||||
for i in `find . -name '*.fdb' -print`
|
for i in `find . -name '*.fdb' -print`
|
||||||
do
|
do
|
||||||
chown $RunUser.$RunUser $i
|
chown $RunUser:$RunUser $i
|
||||||
chmod ug=rw,o= $i
|
chmod ug=rw,o= $i
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# Contributor(s):
|
# Contributor(s):
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# $Id: Makefile.in.client.util,v 1.34 2006-01-15 13:39:56 alexpeshkoff Exp $
|
# $Id: Makefile.in.client.util,v 1.34.4.1 2006-04-16 11:55:15 alexpeshkoff Exp $
|
||||||
#
|
#
|
||||||
ROOT=..
|
ROOT=..
|
||||||
ObjModuleType=std
|
ObjModuleType=std
|
||||||
@ -73,7 +73,7 @@ GSTAT_Files = dba.epp ppg.cpp
|
|||||||
GSTAT_Sources = $(addprefix utilities/gstat/, $(GSTAT_Files)) $(GSTAT_Other_Sources)
|
GSTAT_Sources = $(addprefix utilities/gstat/, $(GSTAT_Files)) $(GSTAT_Other_Sources)
|
||||||
GSTAT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GSTAT_Sources)))) $(CLUMPLETS_Objects)
|
GSTAT_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(GSTAT_Sources)))) $(CLUMPLETS_Objects)
|
||||||
|
|
||||||
FBGUARD_Other_Sources = jrd/isc.cpp
|
FBGUARD_Other_Sources = jrd/isc.cpp jrd/divorce.cpp
|
||||||
FBGUARD_Files = guard.cpp util.cpp
|
FBGUARD_Files = guard.cpp util.cpp
|
||||||
FBGUARD_Sources = $(addprefix utilities/guard/, $(FBGUARD_Files)) $(FBGUARD_Other_Sources)
|
FBGUARD_Sources = $(addprefix utilities/guard/, $(FBGUARD_Files)) $(FBGUARD_Other_Sources)
|
||||||
FBGUARD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBGUARD_Sources))))
|
FBGUARD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBGUARD_Sources))))
|
||||||
|
@ -561,6 +561,7 @@ static THREAD_ENTRY_DECLARE shutdown_thread(THREAD_ENTRY_PARAM arg)
|
|||||||
{
|
{
|
||||||
alreadyClosing = true;
|
alreadyClosing = true;
|
||||||
JRD_shutdown_all(false);
|
JRD_shutdown_all(false);
|
||||||
|
SRVR_shutdown();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
return 0; //make compilers happy
|
return 0; //make compilers happy
|
||||||
|
@ -40,6 +40,7 @@ void SRVR_multi_thread(rem_port*, USHORT);
|
|||||||
bool process_packet(rem_port*, PACKET *, PACKET *, rem_port**);
|
bool process_packet(rem_port*, PACKET *, PACKET *, rem_port**);
|
||||||
void set_server(rem_port*, USHORT);
|
void set_server(rem_port*, USHORT);
|
||||||
THREAD_ENTRY_DECLARE process_connection_thread(THREAD_ENTRY_PARAM);
|
THREAD_ENTRY_DECLARE process_connection_thread(THREAD_ENTRY_PARAM);
|
||||||
|
void SRVR_shutdown();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
@ -32,6 +32,9 @@
|
|||||||
#include "../jrd/common.h"
|
#include "../jrd/common.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
#include "../jrd/ibase.h"
|
#include "../jrd/ibase.h"
|
||||||
#include "../jrd/gdsassert.h"
|
#include "../jrd/gdsassert.h"
|
||||||
#include "../remote/remote.h"
|
#include "../remote/remote.h"
|
||||||
@ -200,6 +203,7 @@ static SLONG extra_threads = 0;
|
|||||||
static SERVER_REQ request_que = NULL;
|
static SERVER_REQ request_que = NULL;
|
||||||
static SERVER_REQ free_requests = NULL;
|
static SERVER_REQ free_requests = NULL;
|
||||||
static SERVER_REQ active_requests = NULL;
|
static SERVER_REQ active_requests = NULL;
|
||||||
|
static bool shutting_down = false;
|
||||||
static SRVR servers;
|
static SRVR servers;
|
||||||
|
|
||||||
#ifdef MULTI_THREAD
|
#ifdef MULTI_THREAD
|
||||||
@ -5029,6 +5033,10 @@ static THREAD_ENTRY_DECLARE loopThread(THREAD_ENTRY_PARAM flags)
|
|||||||
else {
|
else {
|
||||||
REMOTE_TRACE(("got it"));
|
REMOTE_TRACE(("got it"));
|
||||||
}
|
}
|
||||||
|
if (shutting_down)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
THREAD_ENTER();
|
THREAD_ENTER();
|
||||||
--threads_waiting;
|
--threads_waiting;
|
||||||
}
|
}
|
||||||
@ -5046,6 +5054,35 @@ static THREAD_ENTRY_DECLARE loopThread(THREAD_ENTRY_PARAM flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void SRVR_shutdown()
|
||||||
|
{
|
||||||
|
/**************************************
|
||||||
|
*
|
||||||
|
* S R V R _ s h u t d o w n
|
||||||
|
*
|
||||||
|
**************************************
|
||||||
|
*
|
||||||
|
* Functional description
|
||||||
|
* Shutdown working threads, waiting for work
|
||||||
|
* Function is called when shutdowm thread ENTERed,
|
||||||
|
* and will never EXIT
|
||||||
|
*
|
||||||
|
**************************************/
|
||||||
|
shutting_down = true;
|
||||||
|
|
||||||
|
#ifdef MULTI_THREAD
|
||||||
|
int limit = threads_waiting;
|
||||||
|
for (int i=0; i<limit; i++)
|
||||||
|
{
|
||||||
|
requests_semaphore.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
// let them terminate
|
||||||
|
sleep(1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ISC_STATUS rem_port::transact_request(P_TRRQ* trrq, PACKET* sendL)
|
ISC_STATUS rem_port::transact_request(P_TRRQ* trrq, PACKET* sendL)
|
||||||
{
|
{
|
||||||
/**************************************
|
/**************************************
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
* Contributor(s): ______________________________________.
|
* Contributor(s): ______________________________________.
|
||||||
* $Id: guard.cpp,v 1.8 2004-05-18 00:45:46 brodsom Exp $
|
* $Id: guard.cpp,v 1.8.12.1 2006-04-16 11:48:20 alexpeshkoff Exp $
|
||||||
*/
|
*/
|
||||||
/* contains the main() and not shared routines for ibguard */
|
/* contains the main() and not shared routines for ibguard */
|
||||||
|
|
||||||
@ -35,7 +35,16 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_ERRNO_H
|
||||||
|
#include <errno.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../jrd/common.h"
|
#include "../jrd/common.h"
|
||||||
|
#include "../jrd/divorce.h"
|
||||||
#include "../jrd/isc_proto.h"
|
#include "../jrd/isc_proto.h"
|
||||||
#include "../jrd/gds_proto.h"
|
#include "../jrd/gds_proto.h"
|
||||||
#include "../jrd/file_params.h"
|
#include "../jrd/file_params.h"
|
||||||
@ -71,6 +80,7 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
|||||||
USHORT option = FOREVER; /* holds FOREVER or ONETIME or IGNORE */
|
USHORT option = FOREVER; /* holds FOREVER or ONETIME or IGNORE */
|
||||||
bool done = true;
|
bool done = true;
|
||||||
const TEXT* prog_name = argv[0];
|
const TEXT* prog_name = argv[0];
|
||||||
|
TEXT* pidfilename = 0;
|
||||||
|
|
||||||
const TEXT* const* const end = argc + argv;
|
const TEXT* const* const end = argc + argv;
|
||||||
argv++;
|
argv++;
|
||||||
@ -87,9 +97,12 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
|||||||
case 'S':
|
case 'S':
|
||||||
option = IGNORE;
|
option = IGNORE;
|
||||||
break;
|
break;
|
||||||
|
case 'P':
|
||||||
|
pidfilename = *argv++;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Usage: %s [-signore | -onetime | -forever (default)]\n",
|
"Usage: %s [-signore | -onetime | -forever (default)] [-pidfile filename]\n",
|
||||||
prog_name);
|
prog_name);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
break;
|
break;
|
||||||
@ -135,6 +148,9 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
|||||||
TEXT* server_args[2];
|
TEXT* server_args[2];
|
||||||
server_args[0] = process_name;
|
server_args[0] = process_name;
|
||||||
server_args[1] = NULL;
|
server_args[1] = NULL;
|
||||||
|
|
||||||
|
// detach from controlling tty
|
||||||
|
divorce_terminal(0);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int ret_code;
|
int ret_code;
|
||||||
@ -151,6 +167,25 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
|||||||
UTIL_ex_unlock(fd_guard);
|
UTIL_ex_unlock(fd_guard);
|
||||||
exit(-4);
|
exit(-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pidfilename) {
|
||||||
|
FILE *pf = fopen(pidfilename, "w");
|
||||||
|
if (pf)
|
||||||
|
{
|
||||||
|
fprintf(pf, "%d", child_pid);
|
||||||
|
fclose(pf);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gds__log("%s: guardian could not open %s for writing, error %d\n",
|
||||||
|
pidfilename,
|
||||||
|
#ifdef HAVE_ERRNO_H
|
||||||
|
errno
|
||||||
|
#else
|
||||||
|
-1
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* wait for child to die, and evaluate exit status */
|
/* wait for child to die, and evaluate exit status */
|
||||||
ret_code = UTIL_wait_for_child(child_pid);
|
ret_code = UTIL_wait_for_child(child_pid);
|
||||||
@ -193,6 +228,11 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
|||||||
}
|
}
|
||||||
} while (!done);
|
} while (!done);
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
if (pidfilename) {
|
||||||
|
unlink(pidfilename);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
UTIL_ex_unlock(fd_guard);
|
UTIL_ex_unlock(fd_guard);
|
||||||
exit(0);
|
exit(0);
|
||||||
} /* main */
|
} /* main */
|
||||||
|
@ -162,6 +162,9 @@ int CLIB_ROUTINE main( int argc, char **argv)
|
|||||||
ibmgr_data.attached = 0;
|
ibmgr_data.attached = 0;
|
||||||
ibmgr_data.reattach |= (REA_HOST | REA_USER | REA_PASSWORD);
|
ibmgr_data.reattach |= (REA_HOST | REA_USER | REA_PASSWORD);
|
||||||
|
|
||||||
|
/* No pidfile by default
|
||||||
|
*/
|
||||||
|
ibmgr_data.pidfile[0] = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -379,6 +382,13 @@ static SSHORT get_switches(
|
|||||||
ibmgr_data->reattach |= REA_USER;
|
ibmgr_data->reattach |= REA_USER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IN_SW_IBMGR_PIDFILE:
|
||||||
|
{
|
||||||
|
Firebird::PathName pf(string);
|
||||||
|
pf.copyTo(ibmgr_data->pidfile, sizeof(ibmgr_data->pidfile));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IN_SW_IBMGR_0:
|
case IN_SW_IBMGR_0:
|
||||||
SRVRMGR_msg_get(MSG_INVPAR, msg);
|
SRVRMGR_msg_get(MSG_INVPAR, msg);
|
||||||
fprintf(OUTFILE, "%s\n", msg);
|
fprintf(OUTFILE, "%s\n", msg);
|
||||||
@ -781,6 +791,7 @@ static void print_help(void)
|
|||||||
fprintf(OUTFILE, " show show host and user\n");
|
fprintf(OUTFILE, " show show host and user\n");
|
||||||
fprintf(OUTFILE, " user <user_name> set user name\n");
|
fprintf(OUTFILE, " user <user_name> set user name\n");
|
||||||
fprintf(OUTFILE, " password <password> set DBA password\n");
|
fprintf(OUTFILE, " password <password> set DBA password\n");
|
||||||
|
fprintf(OUTFILE, " pidfile <filename> file to save fbserver's PID\n");
|
||||||
fprintf(OUTFILE, " help prints help text\n");
|
fprintf(OUTFILE, " help prints help text\n");
|
||||||
fprintf(OUTFILE, " quit quit prompt mode\n\n");
|
fprintf(OUTFILE, " quit quit prompt mode\n\n");
|
||||||
fprintf(OUTFILE,
|
fprintf(OUTFILE,
|
||||||
|
@ -93,6 +93,7 @@ struct ibmgr_data_t {
|
|||||||
passwd or user has been changed */
|
passwd or user has been changed */
|
||||||
isc_svc_handle attached; /* !=NULL if we attached to service */
|
isc_svc_handle attached; /* !=NULL if we attached to service */
|
||||||
TEXT print_file[MAXPATHLEN];/* Dump file name */
|
TEXT print_file[MAXPATHLEN];/* Dump file name */
|
||||||
|
TEXT pidfile[MAXPATHLEN]; // fbserver's PID file name
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
* Contributor(s): ______________________________________.
|
* Contributor(s): ______________________________________.
|
||||||
* $Id: ibmgrswi.h,v 1.4 2004-05-17 00:28:58 brodsom Exp $
|
* $Id: ibmgrswi.h,v 1.4.12.1 2006-04-16 11:48:21 alexpeshkoff Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IBMGR_IBMGRSWI_H
|
#ifndef IBMGR_IBMGRSWI_H
|
||||||
@ -55,6 +55,9 @@ const int IN_SW_IBMGR_POOL = 18; /* Print pool */
|
|||||||
|
|
||||||
const int IN_SW_IBMGR_SIGNORE = 19; /* start server, restart when it dies, even if it was a start up error */
|
const int IN_SW_IBMGR_SIGNORE = 19; /* start server, restart when it dies, even if it was a start up error */
|
||||||
|
|
||||||
|
// Let startup script specify file to save fbserver's pid - AP 2006
|
||||||
|
const int IN_SW_IBMGR_PIDFILE = 20; /* Pid file name */
|
||||||
|
|
||||||
|
|
||||||
const int IN_SW_IBMGR_AMBIG = 99; /* ambiguous switch */
|
const int IN_SW_IBMGR_AMBIG = 99; /* ambiguous switch */
|
||||||
|
|
||||||
@ -75,6 +78,7 @@ static const struct in_sw_tab_t ibmgr_in_sw_table [] =
|
|||||||
/* {IN_SW_IBMGR_IGNORE, 0, "IGN", 0, 0, 0, FALSE, 0, 1, NULL}, *//* do not shutdown */
|
/* {IN_SW_IBMGR_IGNORE, 0, "IGN", 0, 0, 0, FALSE, 0, 1, NULL}, *//* do not shutdown */
|
||||||
{IN_SW_IBMGR_PASSWORD, 0, "PASSWORD", 0, 0, 0, FALSE, 0, 2, NULL}, /* DB admin's password */
|
{IN_SW_IBMGR_PASSWORD, 0, "PASSWORD", 0, 0, 0, FALSE, 0, 2, NULL}, /* DB admin's password */
|
||||||
{IN_SW_IBMGR_USER, 0, "USER", 0, 0, 0, FALSE, 0, 1, NULL}, /* user's name */
|
{IN_SW_IBMGR_USER, 0, "USER", 0, 0, 0, FALSE, 0, 1, NULL}, /* user's name */
|
||||||
|
{IN_SW_IBMGR_PIDFILE, 0, "PIDFILE", 0, 0, 0, FALSE, 0, 1, NULL}, /* file for fbserver's PID */
|
||||||
|
|
||||||
/* We can shutdown any server, but can start only local
|
/* We can shutdown any server, but can start only local
|
||||||
thus we do not allow to change host for time being
|
thus we do not allow to change host for time being
|
||||||
|
@ -483,8 +483,9 @@ static bool start_server( ibmgr_data_t* data)
|
|||||||
static char option_o[] = "-o";
|
static char option_o[] = "-o";
|
||||||
static char option_s[] = "-s";
|
static char option_s[] = "-s";
|
||||||
static char option_f[] = "-f";
|
static char option_f[] = "-f";
|
||||||
|
static char option_p[] = "-p";
|
||||||
|
|
||||||
TEXT *argv[4];
|
TEXT *argv[5];
|
||||||
argv[0] = path;
|
argv[0] = path;
|
||||||
if (data->suboperation == SOP_START_ONCE)
|
if (data->suboperation == SOP_START_ONCE)
|
||||||
argv[1] = option_o;
|
argv[1] = option_o;
|
||||||
@ -494,6 +495,11 @@ static bool start_server( ibmgr_data_t* data)
|
|||||||
argv[1] = option_f;
|
argv[1] = option_f;
|
||||||
argv[2] = NULL;
|
argv[2] = NULL;
|
||||||
argv[3] = NULL;
|
argv[3] = NULL;
|
||||||
|
if (data->pidfile[0]) {
|
||||||
|
argv[2] = option_p;
|
||||||
|
argv[3] = data->pidfile;
|
||||||
|
}
|
||||||
|
argv[4] = NULL;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("Argument list:\n\"%s\"\n\"%s\"\n", argv[0], argv[1]);
|
printf("Argument list:\n\"%s\"\n\"%s\"\n", argv[0], argv[1]);
|
||||||
|
Loading…
Reference in New Issue
Block a user