Changeset 164


Ignore:
Timestamp:
Sep 30, 2007, 6:51:07 PM (12 years ago)
Author:
bruno
Message:

export TZ also
Still better example script in perl

Location:
devel/pb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r163 r164  
    638638    print SCRIPT "#Sync date\n";
    639639    my $syncdate = strftime("%m%d%H%M", @date);
    640     print SCRIPT "sudo date $syncdate\n";
     640    print SCRIPT "export TZ=CEST ; sudo date $syncdate\n";
    641641    print SCRIPT "# Build\n";
    642642    my $p = "";
  • devel/pb/contrib/pbsetupqemu

    r163 r164  
    1 #!/bin/bash
     1#!/usr/bin/perl -w
    22
    33# Script to be used as pbscript to create a potentialy
     
    99# the pb account in the VM later on
    1010
    11 cat > /tmp/pbkey << EOF
    12 ssh-dss AAAAB3NzaC1kc3MAAACBAMC06bNLMu8ZBJv3Hi77+fi+GUhtQScIbGKru86C/IP27EjrmYhPVccbu8kpX6SDHIouhpZ00gaefP3zHjLUmPKlXkMNUNjxx5JNLPoHhSIuUvoSTNoh9gsi31abAvzbW+RNer7rvBJO4ytNJRdsuNxBwqjxK04JEmatds+aKTQjAAAAFQDHaNmIuvYZ0RtNBVe+tzTzxxCQmQAAAIA4o89Xob2VBRtQKBjmWVAuTS14qiqnQUPNloaRkM+r2odI+NJDFc+WXOIG9QAPKKt1jvFOBOX9Mu3/xwiDLnAGhxud98FoyHevSpIWUld7rG4j1aww1WxolFWY/iPyAvDDMW3iysCoqQeSOlpRd9Mz/dq6/P/VcizhdGOKyc3JBgAAAIAA1eY+BoneiQ/tQ8j3GYbMTu6U7VzZ2OaoVeQn4NtZmPl+ZeQIj83nFpo99mYCbaBPqnZToERndl+ljp/JX5pamwj6RcLIDCyiB6MXLbQSWj0goegU1htp5aMd3NcyR2Jy8gCnf0QjDr7j23Q+CFGExtRb/nsDmaG5W9D6QSWQ/g== bruno@victoria
    13 EOF
    14 chmod 644 /tmp/pbkey
     11use strict;
     12use File::Basename;
     13use ProjectBuilder::Distribution qw (pb_distro_init);
    1514
    16 grep -Eq '^pb:' /etc/passwd
    17 if [ $? -ne 0 ]; then
    18     if [ ! -d /home ]; then
    19         mkdir /home
    20     fi
    21     useradd pb
    22 fi
     15my $file = "/tmp/pbkey";
     16
     17open(PBFILE,"> $file") || die "Unable to open $file";
     18print PBFILE "ssh-dss AAAAB3NzaC1kc3MAAACBAMC06bNLMu8ZBJv3Hi77+fi+GUhtQScIbGKru86C/IP27EjrmYhPVccbu8kpX6SDHIouhpZ00gaefP3zHjLUmPKlXkMNUNjxx5JNLPoHhSIuUvoSTNoh9gsi31abAvzbW+RNer7rvBJO4ytNJRdsuNxBwqjxK04JEmatds+aKTQjAAAAFQDHaNmIuvYZ0RtNBVe+tzTzxxCQmQAAAIA4o89Xob2VBRtQKBjmWVAuTS14qiqnQUPNloaRkM+r2odI+NJDFc+WXOIG9QAPKKt1jvFOBOX9Mu3/xwiDLnAGhxud98FoyHevSpIWUld7rG4j1aww1WxolFWY/iPyAvDDMW3iysCoqQeSOlpRd9Mz/dq6/P/VcizhdGOKyc3JBgAAAIAA1eY+BoneiQ/tQ8j3GYbMTu6U7VzZ2OaoVeQn4NtZmPl+ZeQIj83nFpo99mYCbaBPqnZToERndl+ljp/JX5pamwj6RcLIDCyiB6MXLbQSWj0goegU1htp5aMd3NcyR2Jy8gCnf0QjDr7j23Q+CFGExtRb/nsDmaG5W9D6QSWQ/g== bruno\@victoria\n";
     19close(PBFILE);
     20chmod 0644,$file;
     21
     22$file="/etc/passwd";
     23open(PBFILE,$file) || die "Unable to open $file";
     24my $found = 0;
     25while (<PBFILE>) {
     26    $found = 1 if (/^pb:/);
     27}
     28close(PBFILE);
     29
     30if ( $found == 0 ) {
     31    if ( ! -d "/home" ) {
     32        mkdir "/home";
     33    }
     34    system "useradd pb";
     35}
    2336
    2437# No passwd for pb only keys
    25 perl -pi -e 's/^pb:\!\!:/pb:*:/' /etc/shadow
     38$file="/etc/shadow";
     39open(PBFILE,$file) || die "Unable to open $file";
     40while (<PBFILE>) {
     41    s/^pb:\!\!:/pb:*:/;
     42}
     43close(PBFILE);
     44
    2645# Adapt sudoers
    27 grep -Eq '^pb   ' /etc/sudoers
    28 if [ $? -ne 0 ]; then
    29     echo "pb   ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
    30 fi
    31 # poweroff only
     46$file="/etc/sudoers";
     47$found = 0;
     48open(PBFILE,$file) || die "Unable to open $file";
     49while (<PBFILE>) {
     50    $found = 1 if (/^pb   /);
     51}
     52close(PBFILE);
    3253
    33 su - pb -c "mkdir -p .ssh ; chmod 700 .ssh ; cp /tmp/pbkey .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys"
    34 rm -f /tmp/pbkey
     54if ( $found == 0 ) {
     55    open(PBFILE,">> $file") || die "Unable to open $file";
     56    print PBFILE "pb   ALL=(ALL) NOPASSWD:ALL\n";
     57}
     58
     59system 'su - pb -c "mkdir -p .ssh ; chmod 700 .ssh ; cp /tmp/pbkey .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys"';
     60unlink "/tmp/pbkey";
     61
     62my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init();
    3563
    3664# Get and install pb
    37 if [ -x /usr/bin/yum ]; then
    38     yum clean all
    39     # FC6
    40     #yum -y install neon newt-devel slang-devel autoconf automake libtool gcc rpm-build wget vim gcc-c++ docbook-utils-pdf ImageMagick man patch cdrecord mkisofs perl-AppConfig perl-DateManip
    41     # FC4
    42     yum -y install neon newt-devel slang-devel autoconf automake libtool gcc rpm-build wget gcc-c++ docbook-utils-pdf ImageMagick man patch cdrecord mkisofs perl-DateManip
    43     rm -rf AppConfig-*
    44     wget http://search.cpan.org/CPAN/authors/id/A/AB/ABW/AppConfig-1.66.tar.gz
    45     tar xvfz AppConfig-1.66.tar.gz
    46     cd AppConfig*
    47     perl Makefile.PL
    48     make
    49     make install
    50     cd ..
    51 elif [ -x /usr/sbin/urpmi ]; then
    52     urpmi --auto-select neon newt-devel slang-devel glibc-static-devel autoconf automake libtool gcc rpm-build wget gcc-c++ docbook-utils-pdf ImageMagick man patch mindi mondo mkisofs cdrecord perl-AppConfig perl-DateManip
    53 elif [ -x /usr/bin/apt-get ]; then
    54     apt-get install autoconf automake libtool g++ wget patch mondo groff imagemagick docbook-utils docbook2x docbook-to-man openssh-server dpkg-dev debian-builder dh-make fakeroot libnewt-dev libncurses5-dev
    55 elif [ -x /usr/sbin/emerge ]; then
    56     emerge neon newt slang autoconf automake subversion libtool gcc wget vim man groff lynx grub afio buffer mindi mondo-rescue cdrecord mkisofs   
    57 else
    58     echo "No pkg to install"
    59 fi
     65if ( $ddir eq "fedora" ) {
     66    system "yum clean all";
     67    if ( $dver <= 4 ) {
     68        # FC4
     69        system "yum -y install neon newt-devel slang-devel autoconf automake libtool gcc rpm-build wget gcc-c++ docbook-utils-pdf ImageMagick man patch cdrecord mkisofs perl-DateManip ; rm -rf AppConfig-* ; wget http://search.cpan.org/CPAN/authors/id/A/AB/ABW/AppConfig-1.66.tar.gz ; tar xvfz AppConfig-1.66.tar.gz ; cd AppConfig* ; perl Makefile.PL ; make ; make install ; cd ..";
     70    } else {
     71        # FC5/6/7
     72        system "yum -y install neon newt-devel slang-devel autoconf automake libtool gcc rpm-build wget vim gcc-c++ docbook-utils-pdf ImageMagick man patch cdrecord mkisofs perl-AppConfig perl-DateManip";
     73    }
     74} elsif ( $dfam eq "md" ) {
     75    system "urpmi --auto-select neon newt-devel slang-devel glibc-static-devel autoconf automake libtool gcc rpm-build wget gcc-c++ docbook-utils-pdf ImageMagick man patch mindi mondo mkisofs cdrecord perl-AppConfig perl-DateManip";
     76} elsif ( $dfam eq "du" ) {
     77    system "apt-get install autoconf automake libtool g++ wget patch mondo groff imagemagick docbook-utils docbook2x docbook-to-man openssh-server dpkg-dev debian-builder dh-make fakeroot libnewt-dev libncurses5-dev";
     78} elsif ( $dfam eq "gen" ) {
     79    system "emerge neon newt slang autoconf automake subversion libtool gcc wget vim man groff lynx grub afio buffer mindi mondo-rescue cdrecord mkisofs";
     80} else {
     81    print "No pkg to install\n";
     82}
    6083
    61 cat > /tmp/pbpatch << 'EOF'
     84$file = "/tmp/pbpatch";
     85unlink $file;
     86
     87open(PBFILE,"> $file") || die "Unable to open $file";
     88print PBFILE << 'EOF';
    6289--- File.pm     2007-09-29 14:55:28.000000000 +0100
    6390+++ File.pm.new 2007-09-29 14:55:44.000000000 +0100
     
    85112
    86113EOF
     114close(PBFILE);
    87115
    88116# Patch AppConfig
    89 file=`find /usr/lib/perl5 -type f -name File.pm | grep AppConfig/File.pm`
    90 grep -q 'Fix a bug if the variable is a hash' $file
    91 if [ $? -ne 0 ]; then
    92     (cd `dirname $file` ; patch -s -p0 < /tmp/pbpatch)
    93     if [ $? -eq 0 ]; then
    94         rm -f /tmp/pbpatch
    95     fi
    96 fi
     117my $module=`find /usr/lib/perl5 -type f -name File.pm | grep AppConfig/File.pm`;
     118chomp($module);
     119$found = 0;
     120open(PBFILE,$module) || die "Unable to open $module";
     121while (<PBFILE>) {
     122    $found = 1 if (/Fix a bug if the variable is a hash/);
     123}
     124close(PBFILE);
    97125
    98 rm -rf project-builder-*
    99 wget ftp://ftp.mondorescue.org/src/project-builder-latest.tar.gz
    100 tar xvfz project-builder-latest.tar.gz
    101 cd project-builder-*
    102 perl Makefile.PL
    103 make
    104 make install
    105 cd ..
     126if ( $found == 0 ) {
     127    chdir basename($module);
     128    open(PBFILE,$module) || die "Unable to open $module";
     129    my $module1 = $module."new";
     130    open(PBOUT," > $module1") || die "Unable to open $module1";
     131    while (<PBFILE>) {
     132            s/^use AppConfig;/use AppConfig qw(:argcount);/;
     133            if (/# variables prefixed '-' are reset to their default values/) {
     134print PBOUT << 'EOF';
     135                 # Fix a bug if the variable is a hash - 1 has been created as a key
     136                 if ($nargs eq AppConfig::ARGCOUNT_HASH) {
     137                     delete $state->{ VARIABLE }->{ $variable }{1};
     138                 }
     139
     140EOF
     141            }
     142            print PBOUT "$_";
     143    }
     144    close(PBFILE);
     145    close(PBOUT);
     146    rename($module1,$module);
     147}
     148
     149system "rm -rf project-builder-* ; wget ftp://ftp.mondorescue.org/src/project-builder-latest.tar.gz ; tar xvfz project-builder-latest.tar.gz ; cd project-builder-* ; perl Makefile.PL ; make ; make install ; cd ..";
Note: See TracChangeset for help on using the changeset viewer.