1: #!/usr/bin/perl
2: #
3: # Startup script for the LON-CAPA network processes
4: # Scott Harrison 10/25/2000
5: #
6: # chkconfig: 345 85 15
7: # description: Apache is a World Wide Web server. It is used to serve \
8: # HTML files and CGI.
9: # processnames: lonc, lond, lonsql
10: # pidfiles: /home/httpd/perl/logs/lon*.pid
11: # config: /etc/httpd/conf/access.conf
12: # config: /home/httpd/lonTabs/hosts.tab
13: # config: /home/httpd/lonTabs/spare.tab
14:
15: open (IN, "</etc/passwd");
16: @lines=<IN>;
17: close IN;
18: for $l (@lines) {
19: chop $l;
20: @F=split(/\:/,$l);
21: if ($F[0] eq 'www') {$wwwid=$F[2];}
22: }
23: $<=$wwwid;
24:
25: open (OUT, ">junk");
26: print OUT "stuff";
27: close OUT;
28: __END__
29:
30: $command=$ARGV[0]; $command=~s/[^a-z]//g;
31:
32: # ($euid,$egid,$uid,$gid)=($>,$),$<,$();
33: $ENV{'PATH'}="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin";
34: $ENV{'BASH_ENV'}="";
35:
36: open (IN, "</etc/passwd");
37: @lines=<IN>;
38: close IN;
39: for $l (@lines) {
40: chop $l;
41: @F=split(/\:/,$l);
42: if ($F[0] eq 'www') {$wwwid=$F[2];}
43: }
44: if ($wwwid!=$<) {
45: die("User ID mismatch. This program must be run as user 'www'\n");
46: }
47:
48: if (($command eq "restart") or ($command eq "reload")) {
49: print "Restarting LON-CAPA\n";
50: ($<,$>)=($>,$<);
51: print "Ending LON-CAPA client and daemon processes\n";
52: print `/bin/kill \`/bin/cat /home/httpd/perl/logs/*.pid\``;
53: print "Starting LON-CAPA client and daemon processes (please be patient)\n";
54: system("/home/httpd/perl/loncron");
55: ($<,$>)=($>,$<);
56: print "Restarting web server\n";
57: print `/etc/rc.d/init.d/httpd restart`;
58: }
59: elsif ($command eq "stop") {
60: print "Stopping LON-CAPA\n";
61: ($<,$>)=($>,$<);
62: print `/bin/kill \`/bin/cat /home/httpd/perl/logs/*.pid\``;
63: ($<,$>)=($>,$<);
64: print "Stopping web server\n";
65: print `/etc/rc.d/init.d/httpd stop`;
66: }
67: elsif ($command eq "start") {
68: print "Starting LON-CAPA\n";
69: print "Starting LON-CAPA client and daemon processes (please be patient)\n";
70: ($<,$>)=($>,$<);
71: system("/home/httpd/perl/loncron");
72: ($<,$>)=($>,$<);
73: print "Starting web server\n";
74: print `/etc/rc.d/init.d/httpd start`;
75: }
76: elsif ($command eq "status") {
77: $response=`/bin/cat /home/httpd/perl/logs/*.pid 2>&1`;
78: if ($response=~/No such file or directory/) {
79: print "LON-CAPA is not running.\n";
80: }
81: else {
82: print "LON-CAPA is running.\n";
83: }
84: }
85: else {
86: print "You need to specify restart|stop|start on the command line argument.\n";
87: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>