8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 13:23:02 +01:00

fixed a couple of issues with firebird SS install/startup/shutdown/uninstall

This commit is contained in:
alexpeshkoff 2006-04-16 11:55:15 +00:00
parent 1385c7c472
commit f5c2df7072
21 changed files with 171 additions and 53 deletions

View File

@ -31,7 +31,7 @@
# 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
@ -87,7 +87,7 @@
# Update ownership and SUID bits for programs.
chown -R $RunUser.$RunUser $FBRootDir
chown -R $RunUser:$RunUser $FBRootDir
fixFilePermissions

View File

@ -17,7 +17,8 @@
FIREBIRD=@prefix@
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
# SYSDBA password in a publicly-readable file.
# Eventually this file should not need to contain any passwords.
@ -41,7 +42,10 @@ case "$1" in
;;
stop)
echo -n "Stopping Firebird server: "
killall fbserver
if [ -f $pidfile ]
then
kill `cat $pidfile`
fi
RETVAL=$?
;;
restart|reload)

View File

@ -11,13 +11,7 @@
FIREBIRD=@prefix@
FBRunUser=firebird
# WARNING: in a real-world installation, you should not put the
# 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.
pidfile=/var/run/firebird/`basename $0`.pid
export FIREBIRD
@ -30,14 +24,16 @@ export FIREBIRD
case "$1" in
start)
echo -n "Starting Firebird server: "
echo '$FIREBIRD/bin/fbmgr -start -forever' | su $FBRunUser
echo '$FIREBIRD/bin/fbmgr -pidfile $pidfile -start -forever' | su $FBRunUser
RETVAL=$?
;;
stop)
echo -n "Stopping Firebird server: "
killall fbserver
if [ -f $pidfile ]
then
kill `cat $pidfile`
fi
RETVAL=$?
# [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/identd
;;
status)
RETVAL=0

View File

@ -11,15 +11,14 @@
FIREBIRD=@prefix@
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
# 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.
# NOTE: make sure you have localhost in your hosts.equiv file see next 2
# lines for example of hosts.equiv contents
# NOTE: Normally firebird installation creates /etc/gds_hosts.equiv,
# making it possible normal startup procedure to run.
# In case of manually copying, make sure you have localhost in your
# /etc/gds_hosts.equiv (or hosts.equiv) file.
# See next 2 lines for example of hosts.equiv contents:
#localhost.localdomain
#localhost
@ -28,12 +27,14 @@ export FIREBIRD
MANAGER=$FIREBIRD/bin/fbmgr.bin
start(){
echo -n "Starting Firebird server: "
echo $MANAGER -start -forever | su $FBRunUser
}
start(){
ebegin "Starting firebird server"
start-stop-daemon --oknodo --start --pidfile $pidfile --chuid $FBRunUser --startas $MANAGER -- $FB_OPTS
eend $?
}
stop(){
echo -n "Stopping Firebird server: "
killall fbserver
}
stop(){
ebegin "Stopping firebird"
start-stop-daemon --stop --pidfile $pidfile --oknodo
eend $?
}

View File

@ -17,6 +17,7 @@
FIREBIRD=@prefix@
FBRunUser=firebird
pidfile=/var/run/firebird/`basename $0`.pid
export FIREBIRD
@ -31,14 +32,17 @@ case "$1" in
start)
echo -n "Starting Firebird server: "
daemon --user $FBRunUser $FIREBIRD/bin/fbmgr -start -forever
daemon --user $FBRunUser $FIREBIRD/bin/fbmgr -pidfile $pidfile -start -forever
RETVAL=$?
echo
;;
stop)
echo -n "Stopping Firebird server: "
killall fbserver
if [ -f $pidfile ]
then
kill `cat $pidfile`
fi
RETVAL=$?
# echo
# [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/identd

View File

@ -41,6 +41,7 @@ test "$START_FIREBIRD" = yes || exit 0
FIREBIRD=@prefix@
FBRunUser=firebird
pidfile=/var/run/firebird/`basename $0`.pid
export FIREBIRD
@ -86,7 +87,7 @@ case "$1" in
# NOTE: startproc return 0, even if service is
# 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
rc_status -v
@ -96,13 +97,12 @@ case "$1" in
## Stop daemon with killproc(8) and if this fails
## set echo the echo return value.
# WARNING: in a real-world installation, you should not put the
# 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.
killall fbserver
## I had to use generic approach here - I can't test on suse. AP.
if [ -f $pidfile ]
then
kill `cat $pidfile`
fi
# Remember status and be verbose
rc_status -v
@ -141,7 +141,7 @@ case "$1" in
# 3 - service not running
# NOTE: checkproc returns LSB compliant status values.
checkproc $FIREBIRD/bin/fbguard
checkproc $FIREBIRD/bin/fbserver
rc_status -v
;;

View File

@ -2,6 +2,10 @@
RunUser=firebird
export RunUser
RunGroup=firebird
export RunGroup
PidDir=/var/run/firebird
export PidDir
#------------------------------------------------------------------------
# Add new user and group
@ -114,7 +118,7 @@ stopSuperServerIfRunning() {
then
init_d=`getInitScriptLocation`
if [ $init_d ]
if [ -x "$init_d" ]
then
$init_d stop
fi

View File

@ -70,7 +70,7 @@ installInitdScript() {
# Install the firebird init.d script
cp $FBRootDir/misc/$srcScript $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
@ -101,6 +101,9 @@ installInitdScript() {
cp $FBRootDir/misc/rc.config.firebird /etc/sysconfig/firebird
fi
# Create directory to store pidfile
mkdir $PidDir
chown $RunUser:$RunGroup $PidDir
}

View File

@ -34,3 +34,8 @@ then
rm -f /etc/rc.d/init.d/firebird
fi
fi
if [ -d $PidDir ]
then
rm -rf $PidDir
fi

View File

@ -102,7 +102,7 @@ fixFilePermissions() {
# make examples db's writable by group
for i in `find . -name '*.fdb' -print`
do
chown $RunUser.$RunUser $i
chown $RunUser:$RunUser $i
chmod ug=rw,o= $i
done

View File

@ -497,7 +497,7 @@ removeLinksForBackCompatibility() {
MakeFileFirebirdWritable() {
FileName=$1
chown $RunUser.$RunUser $FileName
chown $RunUser:$RunUser $FileName
chmod 0644 $FileName
}

View File

@ -40,7 +40,7 @@ fixFilePermissions() {
# Security database
# Nobody besides firebird permitted to even read this file
chown $RunUser.$RunUser $SecurityDatabase
chown $RunUser:$RunUser $SecurityDatabase
chmod 0600 $SecurityDatabase
# fix up examples' permissions
@ -61,7 +61,7 @@ fixFilePermissions() {
# make examples db's writable by group
for i in `find . -name '*.fdb' -print`
do
chown $RunUser.$RunUser $i
chown $RunUser:$RunUser $i
chmod ug=rw,o= $i
done

View File

@ -27,7 +27,7 @@
# 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=..
ObjModuleType=std
@ -73,7 +73,7 @@ GSTAT_Files = dba.epp ppg.cpp
GSTAT_Sources = $(addprefix utilities/gstat/, $(GSTAT_Files)) $(GSTAT_Other_Sources)
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_Sources = $(addprefix utilities/guard/, $(FBGUARD_Files)) $(FBGUARD_Other_Sources)
FBGUARD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(FBGUARD_Sources))))

View File

@ -561,6 +561,7 @@ static THREAD_ENTRY_DECLARE shutdown_thread(THREAD_ENTRY_PARAM arg)
{
alreadyClosing = true;
JRD_shutdown_all(false);
SRVR_shutdown();
exit(0);
}
return 0; //make compilers happy

View File

@ -40,6 +40,7 @@ void SRVR_multi_thread(rem_port*, USHORT);
bool process_packet(rem_port*, PACKET *, PACKET *, rem_port**);
void set_server(rem_port*, USHORT);
THREAD_ENTRY_DECLARE process_connection_thread(THREAD_ENTRY_PARAM);
void SRVR_shutdown();
#ifdef __cplusplus
} // extern "C"

View File

@ -32,6 +32,9 @@
#include "../jrd/common.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "../jrd/ibase.h"
#include "../jrd/gdsassert.h"
#include "../remote/remote.h"
@ -200,6 +203,7 @@ static SLONG extra_threads = 0;
static SERVER_REQ request_que = NULL;
static SERVER_REQ free_requests = NULL;
static SERVER_REQ active_requests = NULL;
static bool shutting_down = false;
static SRVR servers;
#ifdef MULTI_THREAD
@ -5029,6 +5033,10 @@ static THREAD_ENTRY_DECLARE loopThread(THREAD_ENTRY_PARAM flags)
else {
REMOTE_TRACE(("got it"));
}
if (shutting_down)
{
return 0;
}
THREAD_ENTER();
--threads_waiting;
}
@ -5046,6 +5054,35 @@ static THREAD_ENTRY_DECLARE loopThread(THREAD_ENTRY_PARAM flags)
#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)
{
/**************************************

View File

@ -15,7 +15,7 @@
*
* All Rights Reserved.
* 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 */
@ -35,7 +35,16 @@
#include <sys/stat.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "../jrd/common.h"
#include "../jrd/divorce.h"
#include "../jrd/isc_proto.h"
#include "../jrd/gds_proto.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 */
bool done = true;
const TEXT* prog_name = argv[0];
TEXT* pidfilename = 0;
const TEXT* const* const end = argc + argv;
argv++;
@ -87,9 +97,12 @@ int CLIB_ROUTINE main( int argc, char **argv)
case 'S':
option = IGNORE;
break;
case 'P':
pidfilename = *argv++;
break;
default:
fprintf(stderr,
"Usage: %s [-signore | -onetime | -forever (default)]\n",
"Usage: %s [-signore | -onetime | -forever (default)] [-pidfile filename]\n",
prog_name);
exit(-1);
break;
@ -135,6 +148,9 @@ int CLIB_ROUTINE main( int argc, char **argv)
TEXT* server_args[2];
server_args[0] = process_name;
server_args[1] = NULL;
// detach from controlling tty
divorce_terminal(0);
do {
int ret_code;
@ -151,6 +167,25 @@ int CLIB_ROUTINE main( int argc, char **argv)
UTIL_ex_unlock(fd_guard);
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 */
ret_code = UTIL_wait_for_child(child_pid);
@ -193,6 +228,11 @@ int CLIB_ROUTINE main( int argc, char **argv)
}
} while (!done);
#ifdef HAVE_UNISTD_H
if (pidfilename) {
unlink(pidfilename);
}
#endif
UTIL_ex_unlock(fd_guard);
exit(0);
} /* main */

View File

@ -162,6 +162,9 @@ int CLIB_ROUTINE main( int argc, char **argv)
ibmgr_data.attached = 0;
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;
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:
SRVRMGR_msg_get(MSG_INVPAR, 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, " user <user_name> set user name\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, " quit quit prompt mode\n\n");
fprintf(OUTFILE,

View File

@ -93,6 +93,7 @@ struct ibmgr_data_t {
passwd or user has been changed */
isc_svc_handle attached; /* !=NULL if we attached to service */
TEXT print_file[MAXPATHLEN];/* Dump file name */
TEXT pidfile[MAXPATHLEN]; // fbserver's PID file name
};

View File

@ -19,7 +19,7 @@
*
* All Rights Reserved.
* 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
@ -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 */
// 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 */
@ -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_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_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
thus we do not allow to change host for time being

View File

@ -483,8 +483,9 @@ static bool start_server( ibmgr_data_t* data)
static char option_o[] = "-o";
static char option_s[] = "-s";
static char option_f[] = "-f";
static char option_p[] = "-p";
TEXT *argv[4];
TEXT *argv[5];
argv[0] = path;
if (data->suboperation == SOP_START_ONCE)
argv[1] = option_o;
@ -494,6 +495,11 @@ static bool start_server( ibmgr_data_t* data)
argv[1] = option_f;
argv[2] = NULL;
argv[3] = NULL;
if (data->pidfile[0]) {
argv[2] = option_p;
argv[3] = data->pidfile;
}
argv[4] = NULL;
#ifdef DEBUG
printf("Argument list:\n\"%s\"\n\"%s\"\n", argv[0], argv[1]);