|
Lines 22-28
Getopt::Long::Configure("bundling");
Link Here
|
| 22 |
|
22 |
|
| 23 |
my %opts; |
23 |
my %opts; |
| 24 |
my $res = GetOptions( \%opts, "command|c=s", "help|h", "login|l", "shell|s=s", |
24 |
my $res = GetOptions( \%opts, "command|c=s", "help|h", "login|l", "shell|s=s", |
| 25 |
"preserve-environment|p|m", "verbose|v", "kohadir|d=s" ); |
25 |
"preserve-environment|p|m", "verbose|v", "kohadir|d=s", "gitify|g" ); |
| 26 |
|
26 |
|
| 27 |
if ( !$res || $opts{help} ) { |
27 |
if ( !$res || $opts{help} ) { |
| 28 |
show_help( !$res ); |
28 |
show_help( !$res ); |
|
Lines 38-43
if ( !-e "/etc/koha/sites/$instance" ) {
Link Here
|
| 38 |
show_help( 1, "The instance doesn't exist: $instance" ); |
38 |
show_help( 1, "The instance doesn't exist: $instance" ); |
| 39 |
exit(1); |
39 |
exit(1); |
| 40 |
} |
40 |
} |
|
|
41 |
|
| 42 |
# quit, if --gitify is used without a --kohadir arg |
| 43 |
if ( exists $opts{gitify} and not exists $opts{kohadir} ) { |
| 44 |
show_help( 1, "You must supply --kohadir when using --gitify" ); |
| 45 |
exit(1); |
| 46 |
} |
| 47 |
|
| 41 |
my $shell = $opts{shell} || $ENV{SHELL} || '/bin/sh'; |
48 |
my $shell = $opts{shell} || $ENV{SHELL} || '/bin/sh'; |
| 42 |
my $kohadir; |
49 |
my $kohadir; |
| 43 |
if ( $opts{kohadir} ) { |
50 |
if ( $opts{kohadir} ) { |
|
Lines 46-61
if ( $opts{kohadir} ) {
Link Here
|
| 46 |
else { |
53 |
else { |
| 47 |
$kohadir = '/usr/share/koha/lib'; |
54 |
$kohadir = '/usr/share/koha/lib'; |
| 48 |
} |
55 |
} |
|
|
56 |
|
| 49 |
# Now we're set up, build the 'su' command |
57 |
# Now we're set up, build the 'su' command |
| 50 |
my @su_args; |
58 |
my @su_args; |
| 51 |
push @su_args, '/usr/bin/sudo'; |
59 |
push @su_args, '/usr/bin/sudo'; |
| 52 |
push @su_args, '--preserve-env' if $opts{'preserve-environment'}; |
60 |
push @su_args, '--preserve-env' if $opts{'preserve-environment'}; |
| 53 |
push @su_args, '--login' if $opts{login}; |
61 |
push @su_args, '--login' if $opts{login}; |
| 54 |
push @su_args, "-u", "$instance-koha"; |
62 |
push @su_args, "-u", "$instance-koha"; |
|
|
63 |
push @su_args, "env "; |
| 64 |
|
| 65 |
# if --gitify, add --kohadir to $PATH and set useful KOHA_GITIFY env var |
| 66 |
push @su_args, "PATH=$kohadir/debian/scripts".':$PATH KOHA_GITIFY=1 ' if $opts{gitify}; |
| 67 |
|
| 55 |
push @su_args, |
68 |
push @su_args, |
| 56 |
"env " |
69 |
"KOHA_CONF=/etc/koha/sites/$instance/koha-conf.xml " |
| 57 |
. "KOHA_CONF=/etc/koha/sites/$instance/koha-conf.xml " |
70 |
. "PERL5LIB=$kohadir $shell " |
| 58 |
. "PERL5LIB=$kohadir $shell" |
|
|
| 59 |
. ( $opts{command} ? " -c '$opts{command}'" : '' ); |
71 |
. ( $opts{command} ? " -c '$opts{command}'" : '' ); |
| 60 |
|
72 |
|
| 61 |
print "Command: '".join("' '",@su_args)."'\n" if $opts{verbose}; |
73 |
print "Command: '".join("' '",@su_args)."'\n" if $opts{verbose}; |
|
Lines 90-95
Options:
Link Here
|
| 90 |
-s, --shell SHELL use SHELL instead of the one from your environment |
102 |
-s, --shell SHELL use SHELL instead of the one from your environment |
| 91 |
-v, --verbose output the full command that will be executed |
103 |
-v, --verbose output the full command that will be executed |
| 92 |
-d, --kohadir /path/to/koha use a different PERL5LIB directory, for example in a git install. |
104 |
-d, --kohadir /path/to/koha use a different PERL5LIB directory, for example in a git install. |
|
|
105 |
-g, --gitify use koha-shell for a git type install (must also provide a --kohadir option) |
| 93 |
|
106 |
|
| 94 |
The default shell is the one currently in use. Refer to su(1) for more detail |
107 |
The default shell is the one currently in use. Refer to su(1) for more detail |
| 95 |
on these options. |
108 |
on these options. |
| 96 |
- |
|
|