Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 187 lines (149 sloc) 4.133 kB
c4de110 @perusionmike MiniVend 4.00
perusionmike authored
1 #$self = {
2 # INSTALLPRIVLIB => '/usr/local/minivend/lib',
3 # INSTALLARCHLIB => '/usr/local/minivend',
4 #};
5
6 use Config;
7 require 'scripts/initp.pl';
8
9 sub doit {
10 my ($key) = @_;
52c57ce @perusionmike MiniVend 4.01
perusionmike authored
11 my $val;
12 if ($MV::Self->{RPMBUILDDIR} and $val = $MV::Self->{$key}) {
13 $val =~ s!^$MV::Self->{RPMBUILDDIR}/!/!;
14 return $val;
15 }
c4de110 @perusionmike MiniVend 4.00
perusionmike authored
16 return $MV::Self->{$key} unless $key =~ /[a-z]/;
17 return $Config{$key};
18 }
19
20 DOIT: {
21 local ($/);
22 local($_) = <<'_EoP_';
23 #!/usr/bin/perl
24 ##!~_~perlpath~_~
25 #
26 # MiniVend restarter
27 #
e8418db @perusionmike MiniVend 4.03
perusionmike authored
28 # $Id: restart.PL,v 1.2 2000/03/11 12:05:46 mike Exp $
c4de110 @perusionmike MiniVend 4.00
perusionmike authored
29 #
30 # Copyright 1996-2000 by Michael J. Heins <mikeh@minivend.com>
31 #
32 # See the file 'Changes' for information.
33 #
34 # This program is free software; you can redistribute it and/or modify
35 # it under the terms of the GNU General Public License as published by
36 # the Free Software Foundation; either version 2 of the License, or
37 # (at your option) any later version.
38 #
39 # This program is distributed in the hope that it will be useful,
40 # but WITHOUT ANY WARRANTY; without even the implied warranty of
41 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42 # GNU General Public License for more details.
43 #
44 # You should have received a copy of the GNU General Public
45 # License along with this program; if not, write to the Free
46 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
47 # MA 02111-1307 USA.
48
49 $Global::VendRoot = $Global::VendRoot || '/usr/local/minivend';
50 #$Global::VendRoot = $Global::VendRoot || '~_~INSTALLARCHLIB~_~';
e8418db @perusionmike MiniVend 4.03
perusionmike authored
51 $Global::VendBin = $Global::VendBin || '/usr/local/minivend/bin';
c4de110 @perusionmike MiniVend 4.00
perusionmike authored
52 #$Global::VendBin = $Global::VendBin || '~_~INSTALLBIN~_~';
53
54 my $force;
55 if($ARGV[0] eq '-f') {
56 shift(@ARGV);
57 $force = ' -q ';
58 }
59
60 $ENV{PATH} = "/bin:/usr/bin";
61 $ENV{IFS} = " ";
62
63 # Untaint alphanuerics, periods, slashes, and minus signs
64 # for options
65 my $tmp;
66 for(@ARGV) {
67 m{([-./\w]+)};
68 $tmp = $1;
69 $_ = $tmp;
70 }
71
72 sub prompt {
73 my($pr) = shift || '? ';
74 my($def) = shift;
75 my $ans = '';
76
77 return $def if $force;
78
79 print $pr;
80 print "[$def] " if $def;
81 chomp($ans = <STDIN>);
82 $ans ? $ans : $def;
83 }
84
85 sub get_id {
86 my @files;
87 @files = ("$Global::VendRoot/.uid", "$Global::VendRoot/_uid");
88 my $uid;
89 for(@files) {
90 open(UID, $_) or next;
91 $uid = <UID>;
92 chomp($uid);
93 last;
94 }
95 return $uid;
96 }
97
98 if ($< == 0) {
99 $name = get_id() || 'YOUR_MINIVEND_USER_NAME';
100 die "Minivend user ID not set in $Global::VendRoot/_uid.\n" if $name eq 'YOUR_MINIVEND_USER_NAME';
101 if(-t) {
102 print <<EOM unless $force;
103
104 The MiniVend server should not be run as root. It should run
105 as a the user name you configured in when you set up the catalogs.
106
107 The name we think should run it is: $name
108
109 If you are starting the server from /etc/rc.local or another
110 startup file, you can use this:
111
112 su -f -c $VendBin/start $name
113
114 or if that fails:
115
116 su $name <<EOF
117 $Global::VendBin/start
118 EOF
119
120 EOM
121 my $ask = prompt("Do you want me to start it as '$name' now? ", 'y');
122 exit 2 unless $ask =~ /^\s*y/i;
123 $Trysu = 1;
124 }
125 else {
126 $Trysu = 1;
127 }
128
129 }
130
131 if (defined $Trysu) {
132 if($^O =~ /bsd|solaris|irix/i) {
133 exec <<EndOfExec or die "Couldn't exec: $!\n";
134 su $name <<EOF
135 $Global::VendBin/minivend $force -r
136 EOF
137 EndOfExec
138 }
139 else {
140 exec qq{su -f -c "$Global::VendBin/minivend $force -r" $name};
141 }
142 }
143 else {
144 exec qq{$Global::VendBin/minivend $force -r};
145 }
146
147 =head1 NAME
148
149 restart -- call bin/minivend C<->r with possible su
150
151 =head1 VERSION
152
153 1.0
154
155 =head1 SYNOPSIS
156
157 restart [-f]
158
159 =head1 DESCRIPTION
160
161 The C<restart> script just tries to execute C<minivend> C<-r> with the proper permissions. If
162 the user is "root", a prompt will be made to see if you want to start as the guessed
163 user ID. (This is the contents of the $Global::VendRoot/_uid file.)
164
165 =head1 OPTIONS
166
167 The C<-f> flag prevents the prompt for superuser and forces quiet mode; this is how you might call MiniVend from
168 a system startup script.
169
170 =head1 SEE ALSO
171
52c57ce @perusionmike MiniVend 4.01
perusionmike authored
172 minivend(1), mvdocs(8), http://www.minivend.com
c4de110 @perusionmike MiniVend 4.00
perusionmike authored
173
174 =head1 AUTHOR
175
176 Mike Heins, <mikeh@minivend.com>
177
178
179 _EoP_
180 s{.*\n(#(.*)~_~(\w+)~_~(.*))}{$2 . doit($3) . "$4\n$1"}eg;
181 my $file = $0;
182 $file =~ s/\.PL$//;
183 open(OUT, ">$file")
184 or die "Create $file: $!\n";
185 print OUT $_;
186 }
Something went wrong with that request. Please try again.