source: devel/pb/contrib/pbsetupqemu @ 163

Revision 163, 3.9 KB checked in by bruno, 6 years ago (diff)

Sets date in the VM to avoid build problem with configure
Improve the example script for VM

  • Property svn:executable set to *
Line 
1#!/bin/bash
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
5#
6# Needs to use root account to connect to the VM
7
8# You need to specify here your local public SSH key used to access
9# the pb account in the VM later on
10
11cat > /tmp/pbkey << EOF
12ssh-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
13EOF
14chmod 644 /tmp/pbkey
15
16grep -Eq '^pb:' /etc/passwd
17if [ $? -ne 0 ]; then
18        if [ ! -d /home ]; then
19                mkdir /home
20        fi
21        useradd pb
22fi
23
24# No passwd for pb only keys
25perl -pi -e 's/^pb:\!\!:/pb:*:/' /etc/shadow
26# Adapt sudoers
27grep -Eq '^pb   ' /etc/sudoers
28if [ $? -ne 0 ]; then
29        echo "pb   ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
30fi
31# poweroff only
32
33su - pb -c "mkdir -p .ssh ; chmod 700 .ssh ; cp /tmp/pbkey .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys"
34rm -f /tmp/pbkey
35
36# Get and install pb
37if [ -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 ..
51elif [ -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
53elif [ -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
55elif [ -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   
57else
58        echo "No pkg to install"
59fi
60
61cat > /tmp/pbpatch << 'EOF'
62--- File.pm     2007-09-29 14:55:28.000000000 +0100
63+++ File.pm.new 2007-09-29 14:55:44.000000000 +0100
64@@ -15,7 +15,7 @@
65 package AppConfig::File;
66 use strict;
67 use warnings;
68-use AppConfig;
69+use AppConfig qw(:argcount);
70 use AppConfig::State;
71 our $VERSION = '1.65';
72
73@@ -208,6 +208,11 @@
74
75                 my $nargs = $state->_argcount($variable);
76
77+                # Fix a bug if the variable is a hash - 1 has been created as a key
78+                if ($nargs eq AppConfig::ARGCOUNT_HASH) {
79+                    delete $state->{ VARIABLE }->{ $variable }{1};
80+                }
81+
82                 # variables prefixed '-' are reset to their default values
83                 if ($flag eq '-') {
84                     $state->_default($variable);
85
86EOF
87
88# Patch AppConfig
89file=`find /usr/lib/perl5 -type f -name File.pm | grep AppConfig/File.pm`
90grep -q 'Fix a bug if the variable is a hash' $file
91if [ $? -ne 0 ]; then
92        (cd `dirname $file` ; patch -s -p0 < /tmp/pbpatch)
93        if [ $? -eq 0 ]; then
94                rm -f /tmp/pbpatch
95        fi
96fi
97
98rm -rf project-builder-*
99wget ftp://ftp.mondorescue.org/src/project-builder-latest.tar.gz
100tar xvfz project-builder-latest.tar.gz
101cd project-builder-*
102perl Makefile.PL
103make
104make install
105cd ..
Note: See TracBrowser for help on using the repository browser.