Newer
Older
Digital_Repository / OARiNZ / DIY / deb_package / eprints-3.0 / bin / epindexer
nstanger on 7 Jun 2007 2 KB - Added debian package source.
  1. #!/usr/bin/perl -T -w -I/opt/eprints3/perl_lib
  2.  
  3. ######################################################################
  4. #
  5. # chkconfig: - 85 15
  6. # description: Start the eprints indexer daemon as the correct user
  7. #
  8. ######################################################################
  9. #
  10. # This file is part of GNU EPrints 2.
  11. #
  12. # Copyright (c) 2000-2004 University of Southampton, UK. SO17 1BJ.
  13. #
  14. # EPrints 2 is free software; you can redistribute it and/or modify
  15. # it under the terms of the GNU General Public License as published by
  16. # the Free Software Foundation; either version 2 of the License, or
  17. # (at your option) any later version.
  18. #
  19. # EPrints 2 is distributed in the hope that it will be useful,
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. # GNU General Public License for more details.
  23. #
  24. # You should have received a copy of the GNU General Public License
  25. # along with EPrints 2; if not, write to the Free Software
  26. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27. #
  28. ######################################################################
  29.  
  30. use EPrints::SystemSettings;
  31.  
  32. use strict;
  33.  
  34. if( $< != 0 )
  35. {
  36. print "This script is intended to start the eprints indexer as a service.\nIt should only be run as root.\nExiting.\n";
  37. exit 1;
  38. }
  39. if( !defined $ARGV[0] || $ARGV[0] !~ m/^(start|stop|status)$/ )
  40. {
  41. print "Usage: $0 {start|stop|status}\n";
  42. exit 1;
  43. }
  44. my $opt = $1;
  45.  
  46. # These are not going via Platform, but this is a UNIX script, so meh.
  47. my @uinfo = getpwnam($EPrints::SystemSettings::conf->{'user'});
  48. my @ginfo = getgrnam($EPrints::SystemSettings::conf->{'group'});
  49. my $uid = $uinfo[2];
  50. my $gid = $ginfo[2];
  51. $( = $) = $gid;
  52. $> = $< = $uid;
  53.  
  54. my $indexer_cmd = $EPrints::SystemSettings::conf->{'base_path'}.'/bin/indexer';
  55. $| = 0;
  56. if( $opt eq 'start' )
  57. {
  58. print 'Starting EPrints Indexer: ';
  59. }
  60. if( $opt eq 'stop' )
  61. {
  62. print 'Stopping EPrints Indexer: ';
  63. }
  64. delete $ENV{'PATH'};
  65. my $rv = system( $indexer_cmd, $opt );
  66. $rv = $rv >> 8;
  67. if( $opt eq 'start' || $opt eq 'stop' )
  68. {
  69. if( $rv == 0 )
  70. {
  71. print ' [ OK ]'."\n";
  72. }
  73. else
  74. {
  75. print ' [FAILED]'."\n";
  76. }
  77. }
  78.  
  79. exit $rv;