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 |
|
---|
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
|
---|
15 |
|
---|
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
|
---|
23 |
|
---|
24 | # No passwd for pb only keys
|
---|
25 | perl -pi -e 's/^pb:\!\!:/pb:*:/' /etc/shadow
|
---|
26 | # 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
|
---|
32 |
|
---|
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
|
---|
35 |
|
---|
36 | # 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
|
---|
60 |
|
---|
61 | cat > /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 |
|
---|
86 | EOF
|
---|
87 |
|
---|
88 | # 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
|
---|
97 |
|
---|
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 ..
|
---|