-
Notifications
You must be signed in to change notification settings - Fork 16
/
cleanbox
executable file
·150 lines (118 loc) · 4.05 KB
/
cleanbox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/sh
# Various cleanups to apply on the Vagrant boxes we use.
# no set -e since some things are expected to fail
NET="$1"
HOSTS="$2"
# force DNS server to an always valid one (all)
cat << EOF > /etc/resolv.conf
# /etc/resolv.conf, built by rtf (Rudder Test Framwork)
options rotate
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
# remove "stdin: not a tty" error on some box
sed -i 's/^mesg n$/tty -s \&\& mesg n/g' /root/.profile
# Disable SELinux (all)
if [ -e /etc/sysconfig/selinux ]
then
setenforce 0 2>/dev/null
sed -i -e 's/^SELINUX=.*/SELINUX=disabled/' /etc/sysconfig/selinux
fi
# Disable firewall (RHEL)
if [ -e /etc/redhat-release ]
then
chkconfig iptables off 2>/dev/null
chkconfig firewalld off 2>/dev/null
service iptables stop 2>/dev/null
service firewalld stop 2>/dev/null
fi
# Install a clean /etc/hosts for Rudder to operate properly (all)
cat << EOF > /etc/hosts
# /etc/hosts, built by rtf (Rudder Test Framwork)
#
# Format:
# IP-Address Full-Qualified-Hostname Short-Hostname
#
# IPv4
127.0.0.1 localhost
EOF
echo "${NET}.2 server.rudder.local server rudder" >> /etc/hosts
i=2
for host in ${HOSTS}
do
echo "${NET}.${i} ${host}" >> /etc/hosts
i=$((i+1))
done
cat << EOF >> /etc/hosts
# IPv6
::1 localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
EOF
# Setup Debian / Ubuntu packaging (debian/ubuntu)
if hash apt-get 2>/dev/null
then
# Old Ubuntu releases need to use the old-releases mirror instead of the default one
if hash lsb_release 2>/dev/null && [ "$(lsb_release -cs)" = "quantal" ]
then
echo "deb http://old-releases.ubuntu.com/ubuntu/ quantal main restricted universe" > /etc/apt/sources.list
echo "deb http://old-releases.ubuntu.com/ubuntu/ quantal-updates main restricted universe" > /etc/apt/sources.list
fi
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install --force-yes -y apt-transport-https
# specific to debian7 / rudder server 2.11.6-4
apt-get install --force-yes -y libltdl7
fi
# Setup SLES packaging (suse)
if [ -e /etc/SuSE-release ]
then
if [ "$(uname -m)" = "x86_64" ]
then
# Install Java, and remove all Zypper repos
wget -q -O /tmp/jdk-7u71-linux-x64.rpm https://www.normation.com/tarball/java/jdk-7u71-linux-x64.rpm
rpm -ivh /tmp/jdk-7u71-linux-x64.rpm
rm /etc/zypp/repos.d/*.repo
# Get the running SLES version
SLES_VERSION=$(grep "VERSION" /etc/SuSE-release|sed "s%VERSION\ *=\ *\(.*\)%\1%")
SLES_SERVICEPACK=$(grep "PATCHLEVEL" /etc/SuSE-release|sed "s%PATCHLEVEL\ *=\ *\(.*\)%\1%")
# Add the repositories corresponding to the running SLES version
if [ ${SLES_VERSION} -eq 11 ] && [ ${SLES_SERVICEPACK} -eq 1 ]
then
zypper ar -f "https://ci.normation.com/sles-repo/SLES-11-SP1-DVD-x86_64-GM-DVD1/" "SLES_11_SP1_DVD1" > /dev/null
zypper ar -f "https://ci.normation.com/sles-repo/SLES-11-SP1-64-SDK-DVD1/" "SLES_11_SP1_DVD2" > /dev/null
fi
if [ ${SLES_VERSION} -eq 11 ] && [ ${SLES_SERVICEPACK} -eq 3 ]
then
zypper ar -f "https://ci.normation.com/sles-repo/SLES-11-SP3-DVD-x86_64-GM-DVD1/" "SLES_11_SP3_DVD1" > /dev/null
zypper ar -f "https://ci.normation.com/sles-repo/SLES-11-SP3-DVD-x86_64-GM-DVD2/" "SLES_11_SP3_DVD2" > /dev/null
fi
else
rpm -ivh http://www.normation.com/tarball/java/jdk-7u71-linux-i586.rpm
fi
fi
# add common usefull packages
if hash apt-get 2> /dev/null
then
export DEBIAN_FRONTEND=noninteractive
PM_INSTALL="apt-get -y install"
elif hash yum 2> /dev/null
then
PM_INSTALL="yum -y install"
elif hash zypper 2> /dev/null
then
PM_INSTALL="zypper --non-interactive install"
fi
${PM_INSTALL} zsh vim less curl tree htop nano git binutils rsync
# add common useful files
for user in root home/vagrant
do
rsync -a /vagrant/scripts/files/vim/ /${user}/
rsync -a /vagrant/scripts/files/git/ /${user}/
rsync -a /vagrant/scripts/files/bash/ /${user}/
rsync -a /vagrant/scripts/files/zsh/ /${user}/
done
id > /tmp/xxx