source: devel/pb/contrib/pbsetupqemu @ 162

Last change on this file since 162 was 162, checked in by bruno, 12 years ago

Allow the usage of another port to communicate with the VM
Example script now mkdir /home if it doesn't exist

  • Property svn:executable set to *
File size: 3.4 KB
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 rrot 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    su - -c "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    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
40elif [ -x /usr/sbin/urpmi ]; then
41    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
42elif [ -x /usr/bin/apt-get ]; then
43    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
44elif [ -x /usr/sbin/emerge ]; then
45    emerge neon newt slang autoconf automake subversion libtool gcc wget vim man groff lynx grub afio buffer mindi mondo-rescue cdrecord mkisofs   
46else
47    echo "No pkg to install"
48fi
49
50cat > /tmp/pbpatch << EOF
51
52--- /usr/lib/perl5/vendor_perl/5.8.8/AppConfig/File.pm.orig 2007-08-09 17:44:26.000000000 +0200
53+++ /usr/lib/perl5/vendor_perl/5.8.8/AppConfig/File.pm  2007-08-09 18:04:46.000000000 +0200
54@@ -20,7 +20,7 @@
55 
56 require 5.005;
57 
58-use AppConfig;
59+use AppConfig qw(:argcount);
60 use AppConfig::State;
61 use File::HomeDir;
62 
63@@ -227,6 +227,11 @@
64 
65        my $nargs = $state->_argcount($variable);
66 
67+       # Fix a bug if the variable is a hash - 1 has been created as a key
68+       if (\$nargs eq AppConfig::ARGCOUNT_HASH) {
69+           delete \$state->{ VARIABLE }->{ \$variable }{1};
70+       }
71+
72        # variables prefixed '-' are reset to their default values
73        if ($flag eq '-') {
74            $state->_default($variable);
75EOF
76
77# Patch AppConfig
78grep -q 'Fix a bug if the variable is a hash' /usr/lib/perl5/vendor_perl/*/AppConfig/File.pm
79if [ $? -ne 0 ]; then
80    (cd /usr/lib/perl5/vendor_perl/*/AppConfig ; patch -s -p0 < /tmp/pbpatch)
81    if [ $? -eq 0 ]; then
82        rm -f /tmp/pbpatch
83    fi
84fi
85
86rm -rf project-builder-*
87wget ftp://ftp.mondorescue.org/src/project-builder-latest.tar.gz
88tar xvfz project-builder-latest.tar.gz
89cd project-builder-*
90perl Makefile.PL
91make
92make install
Note: See TracBrowser for help on using the repository browser.