source: ProjectBuilder/devel/pb/contrib/pbsetupqemu@ 171

Last change on this file since 171 was 171, checked in by Bruno Cornec, 17 years ago

Mandrakelinux 2006.0 has a mandrakeliux-release file which is a link. So creation of a new entry for a mandrakelinux ddir which is then modified in mandrake after detection

  • Property svn:executable set to *
File size: 6.0 KB
RevLine 
[164]1#!/usr/bin/perl -w
[153]2
3# Script to be used as pbscript to create a potentialy
4# missing pb account on the QEMU VM, and adds it to sudo
[166]5
6# Needs to be extented with the pb Distribution.pm module at the end externally
[153]7#
[163]8# Needs to use root account to connect to the VM
[153]9
10# You need to specify here your local public SSH key used to access
11# the pb account in the VM later on
12
[164]13use strict;
14use File::Basename;
[153]15
[164]16my $file = "/tmp/pbkey";
[153]17
[164]18open(PBFILE,"> $file") || die "Unable to open $file";
19print 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";
20close(PBFILE);
21chmod 0644,$file;
22
23$file="/etc/passwd";
24open(PBFILE,$file) || die "Unable to open $file";
25my $found = 0;
26while (<PBFILE>) {
27 $found = 1 if (/^pb:/);
28}
29close(PBFILE);
30
31if ( $found == 0 ) {
32 if ( ! -d "/home" ) {
33 mkdir "/home";
34 }
[171]35 system "useradd pb -d /home/pb";
[164]36}
37
[171]38chdir "/home/pb";
39mkdir ".ssh",0700;
40system 'cp /tmp/pbkey .ssh/authorized_keys';
41chmod 0600,".ssh/authorized_keys";
42system 'chown -R pb:pb .ssh';
43
[153]44# No passwd for pb only keys
[164]45$file="/etc/shadow";
46open(PBFILE,$file) || die "Unable to open $file";
[166]47open(PBOUT,"> $file.new") || die "Unable to open $file.new";
[164]48while (<PBFILE>) {
49 s/^pb:\!\!:/pb:*:/;
[166]50 print PBOUT $_;
[164]51}
52close(PBFILE);
[166]53close(PBOUT);
54rename("$file.new",$file);
[167]55chmod 0640,$file;
[164]56
[153]57# Adapt sudoers
[164]58$file="/etc/sudoers";
59$found = 0;
60open(PBFILE,$file) || die "Unable to open $file";
[166]61open(PBOUT,"> $file.new") || die "Unable to open $file.new";
[164]62while (<PBFILE>) {
63 $found = 1 if (/^pb /);
[166]64 s/Defaults[ \t]+requiretty//;
65 print PBOUT $_;
[164]66}
67close(PBFILE);
[169]68print PBOUT "pb ALL=(ALL) NOPASSWD:ALL\n" if ( $found == 0 );
[166]69close(PBOUT);
70rename("$file.new",$file);
[167]71chmod 0440,$file;
[153]72
[164]73unlink "/tmp/pbkey";
74
75my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init();
76
[158]77# Get and install pb
[164]78if ( $ddir eq "fedora" ) {
79 system "yum clean all";
[169]80 system "yum update -y";
81 my $arch=`uname -m`;
82 my $opt = "";
83 chomp($arch);
84 if ($arch eq "x86_64") {
85 $opt="--exclude=*.i?86";
86 }
[171]87
88 my $topbuilddir=`rpmquery --eval '%{_topdir}' 2> /dev/null`;
89 chomp($topbuilddir);
90
91 my $p = `rpm -q afio`;
92 chomp($p);
93 if ($p !~ /^afio/) {
94 system "rm -f afio-* ; wget ftp://ftp.mondorescue.org/src/afio-2.4.7-1.src.rpm ; rpm -ivh afio-2.4.7-1.src.rpm ; rpmbuild -ba $topbuilddir/SPECS/afio.spec ; chmod 644 $topbuilddir/RPMS/*/*.rpm";
95 }
96 $p = `rpm -q buffer`;
97 chomp($p);
98 if ($p !~ /^buffer/) {
99 system "rm -f buffer-* ; wget ftp://ftp.mondorescue.org/src/buffer-1.19-1.src.rpm ; rpm -ivh buffer-1.19-1.src.rpm ; rpmbuild -ba $topbuilddir/SPECS/buffer.spec ; chmod 644 $topbuilddir/RPMS/*/*.rpm";
100 }
[164]101 if ( $dver <= 4 ) {
[171]102 # FC4 - AppConfig unavailable
[169]103 system "yum -y $opt 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 ntp ; 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 ..";
[164]104 } else {
105 # FC5/6/7
[169]106 system "yum -y $opt install neon newt-devel slang-devel autoconf automake libtool gcc rpm-build wget gcc-c++ docbook-utils-pdf ImageMagick man patch cdrecord mkisofs ntp perl-AppConfig perl-DateManip";
[164]107 }
108} elsif ( $dfam eq "md" ) {
[171]109 if (( $dver eq "2006.0" ) || ( $dver eq "10.2" ) || ( $dver eq "10.1" )) {
110 # mondo not available
111 system "urpmi.update -a ; urpmi --auto neon newt-devel slang-devel glibc-static-devel autoconf automake libtool gcc rpm-build wget gcc-c++ docbook-utils-pdf ImageMagick man patch mkisofs cdrecord ntp-client perl-AppConfig perl-DateManip";
112 } else {
113 system "urpmi.update -a ; urpmi --auto neon newt-devel slang-devel glibc-static-devel autoconf automake libtool gcc rpm-build wget gcc-c++ docbook-utils-pdf ImageMagick man patch mondo mkisofs cdrecord ntp-client perl-AppConfig perl-DateManip";
114 }
[164]115} elsif ( $dfam eq "du" ) {
[166]116 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 ntp-client libncurses5-dev";
[164]117} elsif ( $dfam eq "gen" ) {
[166]118 system "emerge neon newt slang autoconf automake subversion libtool gcc wget vim man groff lynx grub afio buffer mindi mondo-rescue cdrecord mkisofs ntp-client";
[164]119} else {
120 print "No pkg to install\n";
121}
[158]122
[171]123# Sync date
124system "/usr/sbin/ntpdate ntp.home.musique-ancienne.org";
125
[158]126# Patch AppConfig
[164]127my $module=`find /usr/lib/perl5 -type f -name File.pm | grep AppConfig/File.pm`;
128chomp($module);
129$found = 0;
130open(PBFILE,$module) || die "Unable to open $module";
131while (<PBFILE>) {
132 $found = 1 if (/Fix a bug if the variable is a hash/);
133}
134close(PBFILE);
[158]135
[164]136if ( $found == 0 ) {
137 chdir basename($module);
138 open(PBFILE,$module) || die "Unable to open $module";
139 my $module1 = $module."new";
140 open(PBOUT," > $module1") || die "Unable to open $module1";
141 while (<PBFILE>) {
142 s/^use AppConfig;/use AppConfig qw(:argcount);/;
143 if (/# variables prefixed '-' are reset to their default values/) {
144print PBOUT << 'EOF';
145 # Fix a bug if the variable is a hash - 1 has been created as a key
146 if ($nargs eq AppConfig::ARGCOUNT_HASH) {
147 delete $state->{ VARIABLE }->{ $variable }{1};
148 }
149
150EOF
151 }
152 print PBOUT "$_";
153 }
154 close(PBFILE);
155 close(PBOUT);
156 rename($module1,$module);
157}
158
159system "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 ..";
[166]160
Note: See TracBrowser for help on using the repository browser.