Ignore:
Timestamp:
08/05/08 17:37:18 (4 years ago)
Author:
bruno
Message:
  • Use of PBTMP
  • Use of PBPROJ only once at begining, then a var. Avoids expansions which are not wanted.
  • Use pb 0.9.3 syntx
  • Fix substitution error in tftpd (/e flag needed for evaluation)
  • Fix management of temp file for tftpd
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/dploy-pxe/bin/dploy-pxe-post

    r63 r65  
    4949=cut 
    5050 
     51my $proj = "PBPROJ"; 
     52 
     53pb_conf_init($proj); 
     54pb_temp_init(); 
    5155pb_syntax_init("dploy-pxe-post\n"); 
    5256 
     
    5458 
    5559# Get dploy account info 
    56 my $user = "PBPROJ"; 
     60my $user = $proj; 
    5761my ($login,$pass,$uid,$gid,$gecos,$dir,$shell) = getpwnam($user) or die "$user not in passwd file"; 
    5862 
     
    6165open(SUDO,"/etc/sudoers") || die "Unable to read /etc/sudoers"; 
    6266while (<SUDO>) { 
    63     $found = 1 if ((/^PBPROJ/) && (/\/bin\/umount/)); 
     67    $found = 1 if ((/^$proj/) && (/\/bin\/umount/)); 
    6468} 
    6569close(SUDO); 
     
    6771if ($found == 0) { 
    6872    open(SUDO,">> /etc/sudoers") || die "Unable to write /etc/sudoers"; 
    69     print SUDO "PBPROJ ALL=NOPASSWD: /bin/mount -o loop ?*\n"; 
    70     print SUDO "PBPROJ ALL=NOPASSWD: /bin/umount ?*\n"; 
     73    print SUDO "$proj ALL=NOPASSWD: /bin/mount -o loop ?*\n"; 
     74    print SUDO "$proj ALL=NOPASSWD: /bin/umount ?*\n"; 
    7175    close(SUDO); 
    7276} 
     
    7680 
    7781# Create dir structure 
    78 foreach $d ("$pathpxe->{$ENV{'PBPROJ'}}", "$pathpxe->{$ENV{'PBPROJ'}}/../linuxcoe", "$pathpxe->{$ENV{'PBPROJ'}}/../mondorescue") { 
     82foreach my $d ("$pathpxe->{$proj}", "$pathpxe->{$proj}/../linuxcoe", "$pathpxe->{$proj}/../mondorescue") { 
    7983    pb_mkdir_p($d) if ( not -d $d); 
    8084    chown $uid,$gid,$d; 
     
    8892 
    8993open(XIN,$xin)  || die "Unable to read $xin: $!"; 
    90 open(OUT,"$xin.tmp")  || die "Unable to write $xin.tmp: $!"; 
     94open(OUT,"> $ENV{'PBTMP'}/tftpd")  || die "Unable to write $ENV{'PBTMP'}/tftpd: $!"; 
    9195while (<XIN>) { 
    9296    s/disable(\s*)=(\s*)yes/disable$1=$2no/; 
    93     s/server_args(\s*)=(\s*)(.*)/change_parms($1,$2,$3)/; 
     97    s/server_args(\s*)=(\s*)(.*)/change_parms($1,$2,$3)/e; 
    9498    print OUT; 
    9599} 
    96100close(XIN); 
    97101close(OUT); 
    98 move("$xin.tmp",$xin); 
     102move("$ENV{'PBTMP'}/tftpd",$xin); 
    99103 
    100104# Restart xinetd 
     
    112116    print "# Modified by dploy.org\n"; 
    113117    print "# server_args$s1=$s2$params\n"; 
    114     my $dir = dirname($pathpxe->{$ENV{'PBPROJ'}}); 
     118    my $dir = dirname($pathpxe->{$proj}); 
    115119    $params =~ s/-s\s+\S+\s+/-s $dir/; 
    116120    print "server_args$s1=$s2$params\n"; 
    117 $xin)} 
     121} 
Note: See TracChangeset for help on using the changeset viewer.