From f20a58181bef3b587a55b4e2c33f8c4a0eb3cdb7 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 21 Apr 2008 16:35:57 -0500 Subject: [PATCH] kohabug 1776 - enable daemon controls scripts for 'dev' mode The daemon control scripts (koha-zebra-ctl.sh, koha-zebraqueue-ctl.sh, and koha-pazpar2-ctl.sh) are now copied and installed in a runnable fashion for a 'dev'-mode install. By default they are installed in the bin subdirectory of the runtime directory. Also: * the control scripts now work if the EUID is other than root (as would be expected for a 'dev' or 'single' install). * Split the SCRIPT_DIR installation target into SCRIPT_DIR (scripts to copy regardless of install mode) and SCRIPT_NONDEV_DIR (scripts to copy to SCRIPT_DIR unless the install mode is 'dev'). Signed-off-by: Joshua Ferraro --- Makefile.PL | 30 +++++++++++++++++++----------- misc/bin/koha-pazpar2-ctl.sh | 11 ++++++++--- misc/bin/koha-zebra-ctl.sh | 19 ++++++++++++++----- misc/bin/koha-zebraqueue-ctl.sh | 11 ++++++++--- 4 files changed, 49 insertions(+), 22 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 175eec8632..3a05922bc9 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -197,7 +197,14 @@ things the translation toolkit and RSS feed tools. =item SCRIPT_DIR -Directory for command-line scripts and daemons. +Directory for command-line scripts and daemons to +be set up all for installation modes. + +=item SCRIPT_NONDEV_DIR + +Directory for command-line scripts that should +be installed in the same directory as the +SCRIPT_DIR target except 'dev' installs. =item MAN_DIR @@ -259,7 +266,7 @@ my $target_map = { './Makefile.PL' => 'NONE', './MANIFEST.SKIP' => 'NONE', './members' => 'INTRANET_CGI_DIR', - './misc' => { target => 'SCRIPT_DIR', trimdir => -1 }, + './misc' => { target => 'SCRIPT_NONDEV_DIR', trimdir => -1 }, './misc/bin' => { target => 'SCRIPT_DIR', trimdir => -1 }, './misc/release_notes' => { target => 'DOC_DIR', trimdir => 2 }, './misc/translator' => { target => 'MISC_DIR', trimdir => 2 }, @@ -482,13 +489,11 @@ if ($config{'INSTALL_ZEBRA'} eq "yes") { 'blib/ZEBRA_CONF_DIR/retrieval-info-auth-grs1.xml', 'blib/ZEBRA_CONF_DIR/retrieval-info-auth-dom.xml', ); - if ($config{'INSTALL_MODE'} ne 'dev') { - push @{ $pl_files->{'rewrite-config.PL'} }, ( - 'blib/SCRIPT_DIR/koha-zebra-ctl.sh', - 'blib/SCRIPT_DIR/koha-pazpar2-ctl.sh', - 'blib/SCRIPT_DIR/koha-zebraqueue-ctl.sh', - ); - } + push @{ $pl_files->{'rewrite-config.PL'} }, ( + 'blib/SCRIPT_DIR/koha-zebra-ctl.sh', + 'blib/SCRIPT_DIR/koha-pazpar2-ctl.sh', + 'blib/SCRIPT_DIR/koha-zebraqueue-ctl.sh', + ); if ($config{'INSTALL_PAZPAR2'} eq 'yes') { push @{ $pl_files->{'rewrite-config.PL'} }, ( 'blib/PAZPAR2_CONF_DIR/koha-biblios.xml', @@ -503,7 +508,7 @@ if ($config{'INSTALL_ZEBRA'} eq "yes") { if ($config{'INSTALL_MODE'} ne "dev") { push @{ $pl_files->{'rewrite-config.PL'} }, ( 'blib/PERL_MODULE_DIR/C4/Context.pm', - 'blib/SCRIPT_DIR/kohalib.pl' + 'blib/SCRIPT_NONDEV_DIR/kohalib.pl' ); } @@ -1176,6 +1181,7 @@ sub get_target_directories { $dirmap{'PAZPAR2_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'pazpar2'); $dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc'); $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin'); + $dirmap{'SCRIPT_NONDEV_DIR'} = $dirmap{'SCRIPT_DIR'}; $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man'); $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc'); $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb'); @@ -1203,7 +1209,8 @@ sub get_target_directories { $dirmap{'PAZPAR2_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'pazpar2'); $dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc'); $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin'); - $skipdirs{'SCRIPT_DIR'} = 1; + $dirmap{'SCRIPT_NONDEV_DIR'} = $dirmap{'SCRIPT_DIR'}; + $skipdirs{'SCRIPT_NONDEV_DIR'} = 1; $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man'); $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc'); $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'zebradb'); @@ -1224,6 +1231,7 @@ sub get_target_directories { $dirmap{'PAZPAR2_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package, 'pazpar2'); $dirmap{'MISC_DIR'} = File::Spec->catdir(@basedir, $package, 'misc'); $dirmap{'SCRIPT_DIR'} = File::Spec->catdir(@basedir, $package, 'bin'); + $dirmap{'SCRIPT_NONDEV_DIR'} = $dirmap{'SCRIPT_DIR'}; $dirmap{'MAN_DIR'} = File::Spec->catdir(@basedir, $package, 'man'); $dirmap{'DOC_DIR'} = File::Spec->catdir(@basedir, $package, 'doc'); $dirmap{'ZEBRA_LOCK_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'lock', $package, 'zebradb'); diff --git a/misc/bin/koha-pazpar2-ctl.sh b/misc/bin/koha-pazpar2-ctl.sh index c9a007eab0..c89470236c 100755 --- a/misc/bin/koha-pazpar2-ctl.sh +++ b/misc/bin/koha-pazpar2-ctl.sh @@ -12,18 +12,23 @@ PAZPAR2SRV=/usr/sbin/pazpar2 test -f $PAZPAR2SRV || exit 0 +OTHERUSER='' +if [[ $EUID -eq 0 ]]; then + OTHERUSER="--user=$USER.$GROUP" +fi + case "$1" in start) echo "Starting PazPar2 Server" - daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP -- $PAZPAR2SRV -f $PAZPAR2_CONF + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER -- $PAZPAR2SRV -f $PAZPAR2_CONF ;; stop) echo "Stopping PazPar2 Server" - daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP --stop -- $PAZPAR2SRV -f $PAZPAR2_CONF + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --stop -- $PAZPAR2SRV -f $PAZPAR2_CONF ;; restart) echo "Restarting the PazPar2 Server" - daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP --restart -- $PAZPAR2SRV -f $PAZPAR2_CONF + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --restart -- $PAZPAR2SRV -f $PAZPAR2_CONF ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart}" diff --git a/misc/bin/koha-zebra-ctl.sh b/misc/bin/koha-zebra-ctl.sh index 0681ff4ba8..823084d695 100755 --- a/misc/bin/koha-zebra-ctl.sh +++ b/misc/bin/koha-zebra-ctl.sh @@ -15,6 +15,11 @@ ZEBRASRV=/usr/bin/zebrasrv test -f $ZEBRASRV || exit 0 +OTHERUSER='' +if [[ $EUID -eq 0 ]]; then + OTHERUSER="--user=$USER.$GROUP" +fi + case "$1" in start) echo "Starting Zebra Server" @@ -25,25 +30,29 @@ case "$1" in if [[ ! -d $RUNDIR ]]; then umask 022 mkdir -p $RUNDIR - chown $USER:$GROUP $RUNDIR + if [[ $EUID -eq 0 ]]; then + chown $USER:$GROUP $RUNDIR + fi fi if [[ ! -d $LOCKDIR ]]; then umask 022 mkdir -p $LOCKDIR mkdir -p $LOCKDIR/biblios mkdir -p $LOCKDIR/authorities - chown -R $USER:$GROUP $LOCKDIR + if [[ $EUID -eq 0 ]]; then + chown -R $USER:$GROUP $LOCKDIR + fi fi - daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP -- $ZEBRASRV -f $KOHA_CONF + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER -- $ZEBRASRV -f $KOHA_CONF ;; stop) echo "Stopping Zebra Server" - daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP --stop -- $ZEBRASRV -f $KOHA_CONF + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER --stop -- $ZEBRASRV -f $KOHA_CONF ;; restart) echo "Restarting the Zebra Server" - daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP --restart -- $ZEBRASRV -f $KOHA_CONF + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER --restart -- $ZEBRASRV -f $KOHA_CONF ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart}" diff --git a/misc/bin/koha-zebraqueue-ctl.sh b/misc/bin/koha-zebraqueue-ctl.sh index 7cf49a2797..d3444f0e6e 100755 --- a/misc/bin/koha-zebraqueue-ctl.sh +++ b/misc/bin/koha-zebraqueue-ctl.sh @@ -15,18 +15,23 @@ ZEBRAQUEUE=__SCRIPT_DIR__/zebraqueue_daemon.pl test -f $ZEBRAQUEUE || exit 0 +OTHERUSER='' +if [[ $EUID -eq 0 ]]; then + OTHERUSER="--user=$USER.$GROUP" +fi + case "$1" in start) echo "Starting Zebraqueue Daemon" - daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP -- perl -I $PERL5LIB $ZEBRAQUEUE -f $KOHA_CONF + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER -- perl -I $PERL5LIB $ZEBRAQUEUE -f $KOHA_CONF ;; stop) echo "Stopping Zebraqueue Daemon" - daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP --stop -- perl -I $PERL5LIB $ZEBRAQUEUE -f $KOHA_CONF + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER --stop -- perl -I $PERL5LIB $ZEBRAQUEUE -f $KOHA_CONF ;; restart) echo "Restarting the Zebraqueue Daemon" - daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 --user=$USER.$GROUP --restart -- perl -I $PERL5LIB $ZEBRAQUEUE -f $KOHA_CONF + daemon --name=$NAME --errlog=$ERRLOG --stdout=$STDOUT --output=$OUTPUT --verbose=1 --respawn --delay=30 $OTHERUSER --restart -- perl -I $PERL5LIB $ZEBRAQUEUE -f $KOHA_CONF ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart}" -- 2.39.5