head	1.3;
access;
symbols
	TIGRIS_1_1_0RC2:1.2
	TIGRIS_1_1_0RC1:1.2
	TIGRIS_1_1:1.2.0.10
	TIGRIS_1_0_8:1.2
	TIGRIS_1_0_8RC3:1.2
	TIGRIS_1_0_8RC2:1.2
	TIGRIS_1_0_8RC1:1.2
	TIGRIS_1_0_7:1.2
	TIGRIS_1_0_7RC3:1.2
	TIGRIS_1_0_7RC2:1.2
	TIGRIS_1_0_7RC1:1.2
	TIGRIS_1_0_6:1.2
	TIGRIS_1_0_6RC5:1.2
	TIGRIS_1_0_6RC4:1.2
	TIGRIS_1_0_6RC3:1.2
	TIGRIS_1_0_6RC2:1.2
	TIGRIS_1_0_6RC1:1.2
	TIGRIS_1_0_5:1.2
	TIGRIS_1_0_5RC6:1.2
	TIGRIS_1_0_5RC5:1.2
	TIGRIS_1_0_5RC4:1.2
	TIGRIS_1_0_5RC3:1.2
	TIGRIS_1_0_5RC2:1.2
	TIGRIS_1_0_5RC1:1.2
	TIGRIS_1_0_4:1.2
	TIGRIS_1_0_3:1.2
	TIGRIS_1_0_2:1.2
	TIGRIS_1_0_1:1.2
	TIGRIS_1_0:1.2.0.12
	TIGRIS_1_0_0:1.2
	TIGRIS_1_0_0_RC1:1.2.0.8
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.2
	TIGRIS_0_9_2_3:1.2
	HELM_PEER_PORT_BRANCH:1.1.1.1
	TURBINE_PEER:1.2
	TIGRIS_0_9_2_1:1.2
	TIGRIS_0_9_2:1.2.0.6
	TIGRIS_0_9_0:1.2.0.4
	TIGRIS_0_8_4:1.2.0.2;
locks; strict;
comment	@# @;


1.3
date	2001.07.25.00.48.23;	author ms;	state Exp;
branches;
next	1.2;

1.2
date	2000.12.01.00.24.21;	author ms;	state Exp;
branches;
next	1.1;

1.1
date	2000.11.30.21.47.42;	author ms;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2001.02.21.00.36.24;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.3
log
@cleaned up ugly script
@
text
@#!/usr/bin/perl -w

use strict;

my $runAsRoot = 0;
my $crontab;

BEGIN 
{
    if ($> == 0 ) 
    { 
        $runAsRoot = 1;
        $crontab = "/etc/crontab";
    }  
    else 
    {
        $crontab = "$ENV{SANDBOX}/site/cron/crontab";
    }
}

main();

sub main
{
    my $eb_cron = "$ENV{SANDBOX}/helm/cron/eyebrowse.crontab";

    open EB_CRONTAB, "$eb_cron" or murder($eb_cron,$!);
    my $ebCronEntry = <EB_CRONTAB>;
    close EB_CRONTAB;

    $ebCronEntry =~m/(\S+)$/;
    mkdir $1, 0755 unless (-d $1); #fails quietly if you're not root

    # check if cron is already in $crontab
    if (-e $crontab)
    {
        open CRONTAB, "$crontab" or murder($crontab,$!);
        while (<CRONTAB>)
        {
            if (/$ebCronEntry/) {
                print "Cron already installed in $crontab\n";
                exit;
            }
        }
    }
    # concatenate to the crontab finally
    `cat $eb_cron >> $crontab` or 
        die "Installation of $eb_cron in $crontab failed $!\n";
    print "Installed $eb_cron to $crontab successfully\n";
}

## die on error, tell user    
sub murder 
{
  my ($file, $error) = @@_;
  die "Cant open file $file, error [$error]\n"
}
@


1.2
log
@Added developer sandboxs to have cron in $SANDBOX/site/cron/crontab
@
text
@d6 1
a6 24
my ($crontab_dest, $eb_cron_header);
if($> == 0 ) { 
  $runAsRoot = 1;
  $eb_cron_header = "$ENV{SANDBOX}/helm/cron/eyebrowse.crontab";
  $crontab_dest = "/etc/crontab";
}else{
  $eb_cron_header = "$ENV{SANDBOX}/helm/cron/eyebrowse.crontab.user.header";
  $crontab_dest = "$ENV{SANDBOX}/site/cron/crontab";
}
chdir("../cron");
`configure.pl ../cron`;

open EB_CRON_HEADER ,"$eb_cron_header" or murder($eb_cron_header,$!);
while(<EB_CRON_HEADER>){
  $eb_cron_header .= $_;
}
close EB_CRON_HEADER;

my $eb_cron = "$ENV{SANDBOX}/helm/cron/eyebrowse.crontab";

open EB_CRONTAB, "$eb_cron" or murder($eb_cron,$!);
my $ebCronEntry = <EB_CRONTAB>;

close EB_CRONTAB;
d8 49
a56 42
$ebCronEntry =~m/(\S+)$/;
mkdir $1, 0755 unless ( -d $1);
# check if cron is already in /etc/crontab
my $installed = 0;
if ( !$runAsRoot and !-e $crontab_dest ){
  open X, ">$crontab_dest" or murder($crontab_dest, $!); close X;
}else{
  $installed = 1;
}

open SYS_CRONTAB, "$crontab_dest" or &checkInstall($crontab_dest,$!);
if ($crontab_dest eq '/etc/crontab'){
  $installed = 0;
}
while (<SYS_CRONTAB>){
  if ($_ eq $ebCronEntry){ 
    $installed = 1;
  }
  print "decided installed here, with $ebCronEntry compared to file $crontab_dest\n";
}

sub checkInstall {
  my $crontab = shift;
  my $error   = shift;
  if ($runAsRoot){ die "Cant open $crontab, error [$!]\n" }
} 

if ($runAsRoot and !$installed){
  `echo "$ebCronEntry" | cat >> /etc/crontab`;
  print "Installed $eb_cron to /etc/crontab successfully\n";
}elsif ($runAsRoot and $installed){
  print "$eb_cron already installed in /etc/crontab\n";
}elsif (!$runAsRoot and !$installed){
  `echo "$eb_cron_header" | cat >> $ENV{SANDBOX}/site/cron/crontab`;
}elsif (!$runAsRoot and $installed){
  print "$eb_cron already installed in $crontab_dest\n";
}
    
sub murder {
  my $file = shift;
  my $error = shift;
  die "Cant open file $file, error [$!]\n"
@


1.1
log
@Script to install helm/cron/eyebrowse.crontab to /etc/cron so eyebrowse gets updated every 5 minutes
@
text
@d5 18
a22 1
die "You must be root to execute this script succesfully\n" if( $> > 0);  # not root
d25 2
a26 1
open EB_CRONTAB, "$eb_cron" or die "Problem openeing  $eb_cron, error [$!]\n";
d34 11
a44 2
my $installed = "false";
open SYS_CRONTAB, "/etc/crontab" or die "Something bigtime is wrong, error [$!]\n";
d46 2
a47 2
  if ($_ eq $ebCronEntry) { #=~/$_/){
    $installed = "true";
d49 1
d52 8
a59 2
if ($installed eq "false"){
  `cat $eb_cron >> /etc/crontab`;
d61 1
a61 1
}else{
d63 4
a67 1

d69 5
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d5 1
a5 18
my $runAsRoot = 0;
my ($crontab_dest, $eb_cron_header);
if($> == 0 ) { 
  $runAsRoot = 1;
  $eb_cron_header = "$ENV{SANDBOX}/helm/cron/eyebrowse.crontab";
  $crontab_dest = "/etc/crontab";
}else{
  $eb_cron_header = "$ENV{SANDBOX}/helm/cron/eyebrowse.crontab.user.header";
  $crontab_dest = "$ENV{SANDBOX}/site/cron/crontab";
}
chdir("../cron");
`configure.pl ../cron`;

open EB_CRON_HEADER ,"$eb_cron_header" or murder($eb_cron_header,$!);
while(<EB_CRON_HEADER>){
  $eb_cron_header .= $_;
}
close EB_CRON_HEADER;
d8 1
a8 2

open EB_CRONTAB, "$eb_cron" or murder($eb_cron,$!);
d16 2
a17 11
my $installed = 0;
if ( !$runAsRoot and !-e $crontab_dest ){
  open X, ">$crontab_dest" or murder($crontab_dest, $!); close X;
}else{
  $installed = 1;
}

open SYS_CRONTAB, "$crontab_dest" or &checkInstall($crontab_dest,$!);
if ($crontab_dest eq '/etc/crontab'){
  $installed = 0;
}
d19 2
a20 2
  if ($_ eq $ebCronEntry){ 
    $installed = 1;
a21 1
  print "decided installed here, with $ebCronEntry compared to file $crontab_dest\n";
d24 2
a25 8
sub checkInstall {
  my $crontab = shift;
  my $error   = shift;
  if ($runAsRoot){ die "Cant open $crontab, error [$!]\n" }
} 

if ($runAsRoot and !$installed){
  `echo "$ebCronEntry" | cat >> /etc/crontab`;
d27 1
a27 1
}elsif ($runAsRoot and $installed){
a28 4
}elsif (!$runAsRoot and !$installed){
  `echo "$eb_cron_header" | cat >> $ENV{SANDBOX}/site/cron/crontab`;
}elsif (!$runAsRoot and $installed){
  print "$eb_cron already installed in $crontab_dest\n";
d30 1
a31 5
sub murder {
  my $file = shift;
  my $error = shift;
  die "Cant open file $file, error [$!]\n"
}
@


