-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller_setup.sh
executable file
·123 lines (94 loc) · 3.16 KB
/
controller_setup.sh
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
#!/bin/bash
if [[ `id -u` != 0 ]]; then
echo "You must run this as root"
exit 1
fi
# Install packages
yum -y update
yum -y install yum-utils
yum -y install git
yum -y install vim
yum -y install python3
yum -y install python3-dns
yum -y install python3-netaddr
yum -y install epel-release
yum -y install xrdp
if ! dnf list installed atom; then
curl -SLo ~/atom.rpm https://atom.io/download/rpm
dnf -y localinstall ~/atom.rpm
fi
# Install HashiCorp Repo
yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
# Install HashiCorp Stuffs
# https://learn.hashicorp.com/tutorials/terraform/install-cli
# https://learn.hashicorp.com/tutorials/packer/get-started-install-cli
yum -y install terraform
yum -y install packer
yum -y install vault
# Get Lab Variables
if ! grep "TF_VAR_LAB_USER" /etc/environment; then
read -p 'Lab User: ' TF_VAR_LAB_USER
echo 'export TF_VAR_LAB_USER='$TF_VAR_LAB_USER >> /etc/environment
source /etc/environment
fi
if ! grep "TF_VAR_LAB_PW" /etc/environment; then
read -p 'Lab Password: ' TF_VAR_LAB_PW
echo 'export TF_VAR_LAB_PW='$TF_VAR_LAB_PW >> /etc/environment
source /etc/environment
fi
if ! grep "TF_VAR_LAB_DOMAIN" /etc/environment; then
read -p 'Lab Domain: ' TF_VAR_LAB_DOMAIN
echo 'export TF_VAR_LAB_DOMAIN='$TF_VAR_LAB_DOMAIN >> /etc/environment
source /etc/environment
fi
if ! grep "TF_VAR_LAB_SUBNET" /etc/environment; then
read -p 'Lab Subnet: ' TF_VAR_LAB_SUBNET
echo 'export TF_VAR_LAB_SUBNET='$TF_VAR_LAB_SUBNET >> /etc/environment
source /etc/environment
fi
if ! grep "TF_VAR_LAB_DNS1" /etc/environment; then
read -p 'Lab DNS1: ' TF_VAR_LAB_DNS1
echo 'export TF_VAR_LAB_DNS1='$TF_VAR_LAB_DNS1 >> /etc/environment
source /etc/environment
fi
if ! grep "_TFLAB_DNS2" /etc/environment; then
read -p 'Lab DNS2: ' TF_VAR_LAB_DNS2
echo 'export TF_VAR_LAB_DNS2='$TF_VAR_LAB_DNS2 >> /etc/environment
source /etc/environment
fi
if ! grep "TF_VAR_LAB_REPO" /etc/environment; then
read -p 'Lab Repo( e.g. nas.labdomain.local): ' TF_VAR_LAB_REPO
echo 'export TF_VAR_LAB_REPO='$TF_VAR_LAB_REPO >> /etc/environment
source /etc/environment
fi
# Configure XRDP
systemctl enable xrdp --now
if ! grep "xrdp8" /etc/xrdp/xrdp.ini; then
echo '[xrdp8]' >> /etc/xrdp/xrdp.ini
echo 'name=Reconnect' >> /etc/xrdp/xrdp.ini
echo 'lib=libvnc.so' >> /etc/xrdp/xrdp.ini
echo 'username=ask' >> /etc/xrdp/xrdp.ini
echo 'password=ask' >> /etc/xrdp/xrdp.ini
echo 'ip=127.0.0.1' >> /etc/xrdp/xrdp.ini
echo 'port=5901' >> /etc/xrdp/xrdp.ini
fi
if ! firewall-cmd --list-ports | grep "3389"; then
firewall-cmd --permanent --zone=public --add-port=3389/tcp
firewall-cmd --reload
fi
# Configure VIM
FILE=/home/$LAB_USER/.vimrc
if [ ! -f "$FILE" ]; then
touch "$FILE"
chown $LAB_USER:$LAB_USER "$FILE"
echo 'set shiftwidth=2' >> "$FILE"
echo 'set expandtab' >> "$FILE"
echo 'set tabstop=4' >> "$FILE"
echo 'color desert' >> "$FILE"
fi
if ! grep "color" $FILE; then
echo 'set shiftwidth=2' >> "$FILE"
echo 'set expandtab' >> "$FILE"
echo 'set tabstop=4' >> "$FILE"
echo 'color desert' >> "$FILE"
fi