-
Notifications
You must be signed in to change notification settings - Fork 0
/
centos_6.x_install
155 lines (134 loc) · 4.09 KB
/
centos_6.x_install
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
150
151
152
153
154
155
#!/usr/bin/env bash
set -o nounset -o pipefail -o errexit
#exec 3>&1 4>&2
#trap 'exec 2>&4 1>&3' 0 1 2 3
#exec 1>centos_6.x_install.log 2>&1
LOG=centos_6.x_install.log
echo "Starting yum installs..." >$LOG 2>&1
## Determine is system is an EC2 instance
if [ -f /sys/hypervisor/uuid ] && [ `head -c 3 /sys/hypervisor/uuid` == ec2 ];
then
echo "Determined running in EC2"
EC2=true
else
echo "Determined NOT running in EC2"
fi
yum_update() {
echo "Updating system, please be patient..."
yum -y update >>$LOG 2>&1
}
yum_install_epel() {
echo "Installing EPEL, please be patient..."
yum -y install epel-release >>$LOG 2>&1
}
yum_install_tools() {
echo "Installing tools, please be patient..."
if [[ $EC2 ]];
then
yum -y install htop mutt rng-tools yum-cron xorg-x11-xauth yum-utils wireshark man >>$LOG 2>&1
else
yum -y install open-vm-tools htop mutt rng-tools yum-cron chrony xorg-x11-xauth yum-utils wireshark man >>$LOG 2>&1
fi
}
yum_install_fish() {
echo "Installing Fish Shell, please be patient..."
yum-config-manager --add-repo http://fishshell.com/files/linux/RedHat_RHEL-6/fish.release:2.repo >>$LOG 2>&1
yum -y install fish >>$LOG 2>&1
}
yum_install_extras() {
echo "Installing extra libraries for Oracle setup, please be patient..."
yum -y install libXrender-devel libXtst-devel >>$LOG 2>&1
}
yum_remove_openjdk() {
echo "Removing OpenJDK, please be patient..."
yum -y remove *openjdk* >>$LOG 2>&1
}
disable_firewalls() {
echo "Disabling firewalls..."
service iptables stop
service ip6tables stop
chkconfig iptables off
chkconfig ip6tables off
}
disable_ipv6() {
echo "Disabling IPv6..."
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
cat <<EOT >> /etc/sysctl.conf
## Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
EOT
}
disable_selinux() {
echo "Disabling SELINUX..."
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
}
rngd_setup() {
echo "Setting up RNGD..."
sed -i "s@EXTRAOPTIONS=\"\"@EXTRAOPTIONS=\"-r /dev/urandom\"@" /etc/sysconfig/rngd
chkconfig rngd on
service rngd start
}
chrony_setup() {
echo "Setting up Chrony..."
chkconfig chronyd on
service chronyd start
}
yum_cron_setup() {
echo "Setting up yum-cron..."
if [[ -z $EC2 ]];
then
sed -i "s/CHECK_ONLY=no/CHECK_ONLY=yes/" /etc/sysconfig/yum-cron
sed -i "s/CHECK_FIRST=no/CHECK_FIRST=yes/" /etc/sysconfig/yum-cron
sed -i "s/DOWNLOAD_ONLY=no/DOWNLOAD_ONLY=yes/" /etc/sysconfig/yum-cron
fi
chkconfig yum-cron on
service yum-cron start
}
update_sudoers() {
echo "Updating sudoers to allow wheel group..."
sed -i "s/^#\s*\(%wheel\s*ALL=(ALL)\s*ALL\)/\1/" /etc/sudoers
}
ec2_main() {
echo "Running EC2 Scripts..."
yum_install_epel
yum_install_tools
yum_install_fish
yum_install_extras
yum_remove_openjdk
yum_update
yum_cron_setup
disable_firewalls
update_sudoers
}
non_ec2_main() {
echo "Running NON EC2 Scripts..."
disable_ipv6
yum_install_epel
yum_install_tools
yum_install_fish
yum_install_extras
yum_remove_openjdk
yum_update
rngd_setup
chrony_setup
yum_cron_setup
disable_firewalls
disable_selinux
update_sudoers
}
main() {
echo "Starting Dev Box Conversion Script..."
if [[ $EC2 ]];
then
ec2_main
else
non_ec2_main
fi
echo "Dev Box Conversion Script Complete..."
echo "Add user with the command \"useradd -m -G wheel -s /usr/bin/fish -d /home/foo foo\""
echo ""
echo "Please restart your system for the full changes to take effect!"
}
main