Annotation of loncom/init.d/loncontrol, revision 1.1
1.1 ! harris41 1: #!/usr/bin/perl
! 2:
! 3: $command=$ARGV[0]; $command=~s/[^a-z]//g;
! 4:
! 5: # ($euid,$egid,$uid,$gid)=($>,$),$<,$();
! 6: $ENV{'PATH'}="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin";
! 7: $ENV{'BASH_ENV'}="";
! 8:
! 9: open (IN, "</etc/passwd");
! 10: @lines=<IN>;
! 11: close IN;
! 12: for $l (@lines) {
! 13: chop $l;
! 14: @F=split(/\:/,$l);
! 15: if ($F[0] eq 'www') {$wwwid=$F[2];}
! 16: }
! 17: if ($wwwid!=$<) {
! 18: die("User ID mismatch. This program must be run as user 'www'\n");
! 19: }
! 20:
! 21: if (($command eq "restart") or ($command eq "reload")) {
! 22: print "Restarting LON-CAPA\n";
! 23: ($<,$>)=($>,$<);
! 24: print "Ending LON-CAPA client and daemon processes\n";
! 25: print `/bin/kill \`/bin/cat /home/httpd/perl/logs/*.pid\``;
! 26: print "Starting LON-CAPA client and daemon processes (please be patient)\n";
! 27: system("/home/httpd/perl/loncron");
! 28: ($<,$>)=($>,$<);
! 29: print "Restarting web server\n";
! 30: print `/etc/rc.d/init.d/httpd restart`;
! 31: }
! 32: elsif ($command eq "stop") {
! 33: print "Stopping LON-CAPA\n";
! 34: ($<,$>)=($>,$<);
! 35: print `/bin/kill \`/bin/cat /home/httpd/perl/logs/*.pid\``;
! 36: ($<,$>)=($>,$<);
! 37: print "Stopping web server\n";
! 38: print `/etc/rc.d/init.d/httpd stop`;
! 39: }
! 40: elsif ($command eq "start") {
! 41: print "Starting LON-CAPA\n";
! 42: print "Starting LON-CAPA client and daemon processes (please be patient)\n";
! 43: ($<,$>)=($>,$<);
! 44: system("/home/httpd/perl/loncron");
! 45: ($<,$>)=($>,$<);
! 46: print "Starting web server\n";
! 47: print `/etc/rc.d/init.d/httpd start`;
! 48: }
! 49: elsif ($command eq "status") {
! 50: $response=`/bin/cat /home/httpd/perl/logs/*.pid 2>&1`;
! 51: if ($response=~/No such file or directory/) {
! 52: print "LON-CAPA is not running.\n";
! 53: }
! 54: else {
! 55: print "LON-CAPA is running.\n";
! 56: }
! 57: }
! 58: else {
! 59: print "You need to specify restart|stop|start on the command line argument.\n";
! 60: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>