@@ -, +, @@ shell scripts do. Run koha-foreach echo Hi Run koha-upgrade-schema yourinstance Run koha-shell yourinstance If you have plack, run koha-plack --start|--stop yourinstance Run koha-sitemap --generate yourinstance Run koha-start-sip yourinstance Run koha-stop-sip yourinstance Run koha-upgrade-schema yourinstance Run koha-shell yourinstance If you have plack: koha-plack --start|--stop yourinstance Run koha-sitemap --generate yourinstance Run koha-start-sip yourinstance Run koha-stop-sip yourinstance You should no longer see occurrences in debian/scripts except: koha-translate: see report 16749 koha-upgrade-to-3.4: left out intentionally You should only see hits for lines with koha-functions in the debian scripts except: koha-upgrade-to-3.4: left out intentionally --- debian/scripts/koha-foreach | 17 +++++++++++++++-- debian/scripts/koha-plack | 23 +++++++++++++++++------ debian/scripts/koha-shell | 18 +++++++++++++++++- debian/scripts/koha-sitemap | 12 ++++++++++-- debian/scripts/koha-start-sip | 23 +++++++++++++++++++++-- debian/scripts/koha-stop-sip | 9 +-------- debian/scripts/koha-upgrade-schema | 25 ++++++++++++++++++++----- debian/templates/plack.psgi | 8 +++----- 8 files changed, 104 insertions(+), 31 deletions(-) --- a/debian/scripts/koha-foreach +++ a/debian/scripts/koha-foreach @@ -15,9 +15,19 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . - set -e +# Read configuration variable file if it is present +[ -r /etc/default/koha-common ] && . /etc/default/koha-common + +# include helper functions +if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then + . "/usr/share/koha/bin/koha-functions.sh" +else + echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2 + exit 1 +fi + listopts="" while [ ! -z "$1" ] do @@ -39,11 +49,14 @@ done for name in $(koha-list $listopts) do + # Optionally use alternative paths for a dev install + adjust_paths_dev_install $name + cmd=`echo "$@" | sed -e s/__instancename__/${name}/g` ( exec 3>&1 sudo -u "$name-koha" \ - env PERL5LIB=/usr/share/koha/lib \ + env PERL5LIB=$PERL5LIB \ KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml" \ ${cmd} 2>&1 >&3 | sed -e "s/^/$name: /" >&2 3>&- exec 3>&- --- a/debian/scripts/koha-plack +++ a/debian/scripts/koha-plack @@ -213,6 +213,22 @@ set_action() fi } +adjust_paths() +{ + # Optionally use alternative paths for a dev install + adjust_paths_dev_install $1 + + # PERL5LIB has been read from etc/default, add lib/installer + # export some vars (for plack.psgi) + export KOHA_HOME + if [ "$DEV_INSTALL" = "" ]; then + export PERL5LIB=$PERL5LIB:$KOHA_HOME/lib/installer + else + export DEV_INSTALL + export PERL5LIB=$PERL5LIB:$KOHA_HOME/installer + fi +} + STARMAN=$(which starman) op="" quiet="no" @@ -250,12 +266,6 @@ while [ $# -gt 0 ]; do done -if [ -z $PERL5LIB ]; then - PERL5LIB="/usr/share/koha/lib" -fi - -export PERL5LIB - [ "${quiet}" != "yes" ] && check_env_and_warn if [ $# -gt 0 ]; then @@ -264,6 +274,7 @@ if [ $# -gt 0 ]; then if is_instance $name; then + adjust_paths $name case $op in "start") start_plack $name --- a/debian/scripts/koha-shell +++ a/debian/scripts/koha-shell @@ -41,6 +41,7 @@ if ( !-e "/etc/koha/sites/$instance" ) { my $shell = $opts{shell} || $ENV{SHELL} || '/bin/sh'; # Now we're set up, build the 'su' command +my $perl5lib = read_perl5lib( $instance ); my @su_args; push @su_args, '/usr/bin/sudo'; push @su_args, '--preserve-env' if $opts{'preserve-environment'}; @@ -49,7 +50,7 @@ push @su_args, "-u", "$instance-koha"; push @su_args, "env " . "KOHA_CONF=/etc/koha/sites/$instance/koha-conf.xml " - . "PERL5LIB=/usr/share/koha/lib $shell" + . "PERL5LIB=$perl5lib $shell" . ( $opts{command} ? " -c '$opts{command}'" : '' ); print "Command: '".join("' '",@su_args)."'\n" if $opts{verbose}; @@ -70,6 +71,21 @@ sub show_help { print $fh $_ while ; } +sub read_perl5lib { + my ( $instance ) = @_; + + # This simulates what the debian shell scripts do: + # Read /etc/default/koha-common + # Check dev_install in koha-conf.xml + + my $result = `grep "^PERL5LIB=" /etc/default/koha-common`; + chomp $result; + $result =~ s/^PERL5LIB=\s*//; + my $dev_install = `xmlstarlet sel -t -v 'yazgfs/config/dev_install' /etc/koha/sites/$instance/koha-conf.xml`; + chomp $dev_install; + return $dev_install || $result; +} + __DATA__ koha-shell -- gives you a shell with your Koha environment set up --- a/debian/scripts/koha-sitemap +++ a/debian/scripts/koha-sitemap @@ -108,9 +108,9 @@ generate_sitemap() fi if sudo -u "$instance-koha" -H \ - env PERL5LIB=/usr/share/koha/lib \ + env PERL5LIB=$PERL5LIB \ KOHA_CONF="/etc/koha/sites/$instance/koha-conf.xml" \ - /usr/share/koha/bin/cronjobs/sitemap.pl \ + $KOHA_BINDIR/cronjobs/sitemap.pl \ --dir $sitemapdir ; then return 0 else @@ -171,6 +171,14 @@ while [ $# -gt 0 ]; do done +# Optionally use alternative paths for a dev install +adjust_paths_dev_install $1 +if [ "$DEV_INSTALL" = "" ]; then + KOHA_BINDIR=$KOHA_HOME/bin +else + KOHA_BINDIR=$KOHA_HOME/misc +fi + if [ $# -gt 0 ]; then # We have at least one instance name for name in "$@"; do --- a/debian/scripts/koha-start-sip +++ a/debian/scripts/koha-start-sip @@ -18,6 +18,17 @@ set -e +# Read configuration variable file if it is present +[ -r /etc/default/koha-common ] && . /etc/default/koha-common + +# include helper functions +if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then + . "/usr/share/koha/bin/koha-functions.sh" +else + echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2 + exit 1 +fi + for name in "$@" do if [ ! -e /etc/koha/sites/${name}/koha-conf.xml ] ; @@ -29,9 +40,17 @@ do echo "Starting SIP server for $name" mkdir -p /var/run/koha/${name} chown "${name}-koha:${name}-koha" /var/run/koha/${name} + + adjust_paths_dev_install $name export KOHA_CONF PERL5LIB KOHA_CONF=/etc/koha/sites/${name}/koha-conf.xml - PERL5LIB="/usr/share/koha/lib" + # PERL5LIB has been read already + if [ "$DEV_INSTALL" = "" ]; then + LIBDIR=$KOHA_HOME/lib + else + LIBDIR=$KOHA_HOME + fi + daemon \ --name="$name-koha-sip" \ --errlog="/var/log/koha/$name/sip-error.log" \ @@ -44,6 +63,6 @@ do --user="$name-koha.$name-koha" \ -- \ perl \ - "/usr/share/koha/lib/C4/SIP/SIPServer.pm" \ + "$LIBDIR/C4/SIP/SIPServer.pm" \ "/etc/koha/sites/${name}/SIPconfig.xml" done --- a/debian/scripts/koha-stop-sip +++ a/debian/scripts/koha-stop-sip @@ -31,9 +31,6 @@ do continue; fi echo "Stopping SIP server for $name" - KOHA_CONF=/etc/koha/sites/${name}/koha-conf.xml - PERL5LIB=/usr/share/koha/lib - export KOHA_CONF PERL5LIB daemon \ --name="$name-koha-sip" \ --errlog="/var/log/koha/$name/sip-error.log" \ @@ -44,9 +41,5 @@ do --delay=30 \ --pidfiles="/var/run/koha/${name}" \ --user="$name-koha.$name-koha" \ - --stop \ - -- \ - perl \ - "/usr/share/koha/lib/C4/SIP/SIPServer.pm" \ - "/etc/koha/sites/${name}/SIPconfig.xml" + --stop done --- a/debian/scripts/koha-upgrade-schema +++ a/debian/scripts/koha-upgrade-schema @@ -16,16 +16,31 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . - set -e +# Read configuration variable file if it is present +[ -r /etc/default/koha-common ] && . /etc/default/koha-common + +# include helper functions +if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then + . "/usr/share/koha/bin/koha-functions.sh" +else + echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2 + exit 1 +fi + +# Optionally use alternative paths for a dev install +adjust_paths_dev_install $1 +if [ "$DEV_INSTALL" = "" ]; then + CGI_PATH=$KOHA_HOME/intranet/cgi-bin +else + CGI_PATH=$KOHA_HOME +fi -update="/usr/share/koha/intranet/cgi-bin/installer/data/mysql/updatedatabase.pl" for name in "$@" do echo "Upgrading database schema for $name" KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml" \ - PERL5LIB="/usr/share/koha/lib" \ - "$update" + PERL5LIB=$PERL5LIB \ + "$CGI_PATH/installer/data/mysql/updatedatabase.pl" done - --- a/debian/templates/plack.psgi +++ a/debian/templates/plack.psgi @@ -17,9 +17,6 @@ use Modern::Perl; -use lib("/usr/share/koha/lib"); -use lib("/usr/share/koha/lib/installer"); - use Plack::Builder; use Plack::App::CGIBin; use Plack::App::Directory; @@ -52,12 +49,13 @@ use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise }; } +my $home = $ENV{KOHA_HOME}; my $intranet = Plack::App::CGIBin->new( - root => '/usr/share/koha/intranet/cgi-bin' + root => $ENV{DEV_INSTALL}? $home: "$home/intranet/cgi-bin" )->to_app; my $opac = Plack::App::CGIBin->new( - root => '/usr/share/koha/opac/cgi-bin/opac' + root => $ENV{DEV_INSTALL}? "$home/opac": "$home/opac/cgi-bin/opac" )->to_app; # my $api = Plack::App::CGIBin->new( --