install-deps 2.07 KB
Newer Older
boklm's avatar
boklm committed
1
2
3
#!/bin/sh
set -e

4
5
6
7
8
9
cpan_install() {
   local perlmod="$1"
   perl -M"$perlmod" -e '1;' > /dev/null 2>&1 && echo "$perlmod already installed"
   perl -M"$perlmod" -e '1;' > /dev/null 2>&1 || cpan install "$perlmod"
}

10
11
12
13
14
15
16
yum_install() {
    for package in "$@"
    do
        rpm --quiet -q --whatprovides "$package" || yum install -y "$package"
    done
}

17
18
19
perlmodules='
Cwd Data::Dump Digest::SHA File::Path File::Slurp File::Spec File::Temp
FindBin Getopt::Long IO::CaptureOutput IO::Socket::INET Image::Magick
boklm's avatar
boklm committed
20
JSON LWP::UserAgent LWP::Protocol::https Template YAML::Syck DateTime
21
Email::Simple Email::Sender File::Type IPC::Run XML::LibXML
22
23
'

boklm's avatar
boklm committed
24
25
if [ -f /etc/debian_version ]
then
boklm's avatar
boklm committed
26
   apt-get install -y ntp xvfb python-virtualenv
boklm's avatar
boklm committed
27
28
   apt-get install -y libdata-dump-perl libdigest-sha-perl libfile-slurp-perl \
	   libfile-spec-perl libio-captureoutput-perl perlmagick libjson-perl \
boklm's avatar
boklm committed
29
	    libwww-perl libtemplate-perl libyaml-syck-perl libdatetime-perl \
30
            libemail-sender-perl libemail-simple-perl libfile-type-perl \
31
            libipc-run-perl libxml-libxml-perl
boklm's avatar
boklm committed
32
   apt-get install -y libgtk2.0-0
boklm's avatar
boklm committed
33
   apt-get install -y nmap
34
35
36
37
   if lsb_release -i | grep -q Debian
   then
       apt-get install iceweasel
   fi
boklm's avatar
boklm committed
38
39
40
41
fi

if [ -f /etc/redhat-release ] && which yum > /dev/null 2>&1
then
42
    yum_install ntp redhat-lsb-core xorg-x11-server-Xvfb python-virtualenv
boklm's avatar
boklm committed
43
44
    if lsb_release -i | grep -q Fedora
    then
45
        yum_install nmap-ncat
boklm's avatar
boklm committed
46
    else
47
        yum_install nmap
boklm's avatar
boklm committed
48
    fi
49
    for perlmodule in $perlmodules
boklm's avatar
boklm committed
50
    do
51
        yum_install "perl($perlmodule)"
boklm's avatar
boklm committed
52
53
54
    done
    if [ "$(uname -m)" == "x86_64" ]
    then
55
        yum_install 'libgtk-x11-2.0.so.0()(64bit)'
boklm's avatar
boklm committed
56
    else
57
        yum_install libgtk-x11-2.0.so.0
boklm's avatar
boklm committed
58
    fi
boklm's avatar
boklm committed
59
60
61
62
63
64
65
66
    if which systemctl > /dev/null 2>&1
    then
        systemctl enable ntpd.service
        systemctl is-active -q ntpd.service || systemctl start ntpd.service
    else
        chkconfig ntpd on
        service ntpd status > /dev/null 2>&1 || service ntpd start
    fi
boklm's avatar
boklm committed
67
fi
68
69
70
71
72
73
74
75

if [ a$(uname -o) = aCygwin ]
then
    for perlmod in $perlmodules
    do
        cpan_install $perlmod
    done
fi