source: devel/pb/contrib/pbsetupqemu @ 159

Last change on this file since 159 was 159, checked in by Bruno Cornec, 13 years ago

That script has worked for fedora_6

  • 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    su - -c "useradd pb"
19fi
20
21# No passwd for pb only keys
22perl -pi -e 's/^pb:\!\!:/pb:*:/' /etc/shadow
23# Adapt sudoers
24grep -Eq '^pb   ' /etc/sudoers
25if [ $? -ne 0 ]; then
26    echo "pb   ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
27fi
28# poweroff only
29
30su - pb -c "mkdir -p .ssh ; chmod 700 .ssh ; cp /tmp/pbkey .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys"
31rm -f /tmp/pbkey
32
33# Get and install pb
34if [ -x /usr/bin/yum ]; then
35    yum clean all
36    #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
37elif [ -x /usr/sbin/urpmi ]; then
38    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
39elif [ -x /usr/bin/apt-get ]; then
40    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
41elif [ -x /usr/sbin/emerge ]; then
42    emerge neon newt slang autoconf automake subversion libtool gcc wget vim man groff lynx grub afio buffer mindi mondo-rescue cdrecord mkisofs   
43else
44    echo "No pkg to install"
45fi
46
47cat > /tmp/pbpatch << EOF
48
49--- /usr/lib/perl5/vendor_perl/5.8.8/AppConfig/File.pm.orig 2007-08-09 17:44:26.000000000 +0200
50+++ /usr/lib/perl5/vendor_perl/5.8.8/AppConfig/File.pm  2007-08-09 18:04:46.000000000 +0200
51@@ -20,7 +20,7 @@
52 
53 require 5.005;
54 
55-use AppConfig;
56+use AppConfig qw(:argcount);
57 use AppConfig::State;
58 use File::HomeDir;
59 
60@@ -227,6 +227,11 @@
61 
62        my $nargs = $state->_argcount($variable);
63 
64+       # Fix a bug if the variable is a hash - 1 has been created as a key
65+       if (\$nargs eq AppConfig::ARGCOUNT_HASH) {
66+           delete \$state->{ VARIABLE }->{ \$variable }{1};
67+       }
68+
69        # variables prefixed '-' are reset to their default values
70        if ($flag eq '-') {
71            $state->_default($variable);
72EOF
73
74# Patch AppConfig
75grep -q 'Fix a bug if the variable is a hash' /usr/lib/perl5/vendor_perl/*/AppConfig/File.pm
76if [ $? -ne 0 ]; then
77    (cd /usr/lib/perl5/vendor_perl/*/AppConfig ; patch -s -p0 < /tmp/pbpatch)
78    if [ $? -eq 0 ]; then
79        rm -f /tmp/pbpatch
80    fi
81fi
82
83rm -rf project-builder-*
84wget ftp://ftp.mondorescue.org/src/project-builder-latest.tar.gz
85tar xvfz project-builder-latest.tar.gz
86cd project-builder-*
87perl Makefile.PL
88make
89make install
Note: See TracBrowser for help on using the repository browser.