-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkickstart.sh
More file actions
144 lines (143 loc) · 6.01 KB
/
kickstart.sh
File metadata and controls
144 lines (143 loc) · 6.01 KB
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
#!/bin/bash
# Kickstart Server Configurator - V.0.1
# Let's start by setting up our apt-cache server (Must Request Sudo)
[ "$UID" -eq 0 ] || exec sudo bash "$0" "$@"
if ping -c 1 10.162.150.10 > /dev/null
then
:
else
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo This system was NOT ABLE to contact NHSCS.
echo It is NOT recomended to run this kickstart on machines that can not contact NHSCS.
echo Based on this warning, do you want to continue? [y/N][ENTER]
read nhscsping
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
if [ $nhscsping = "y" ]
then
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "Kickstart will continue."
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=
else
if [ $nhscsping = "Y" ]
then
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "Kickstart will continue."
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=
else
if [ $nhscsping = "" ]
then
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "Kickstart will stop. Exiting."
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
exit
else
if [ $nhscsping = "N" ]
then
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "Kickstart will stop. Exiting."
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
exit
else
if [ $nhscsping = "n" ]
then
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "Kickstart will stop. Exiting."
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
exit
else
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "That's not an answer, exiting."
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
exit
fi
fi
fi
fi
fi
fi
echo 'Acquire::http::Proxy "http://EH3-NHSCS-UUC01.ad.nhscs.net:3142";' >> /etc/apt/apt.conf.d/01proxy
# Let's update the system
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "WE ARE GOING TO UPDATE THE SYSTEM NOW"
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
sleep 2
apt-get update && apt-get dist-upgrade -y
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "Updates are done, cleaning the system of old packages."
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
apt-get autoremove -y && apt-get autoclean
sleep 2
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "We're going to configure Landscape now."
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
apt-get install landscape-client expect -y
systemhost=$(hostname)
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "The current system hostname is $systemhost. Do you want to change it? [y/N]"
read anshostname
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
if [ $anshostname = "y" ]
then
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "Please provide the hostname that you wish to use followed by [ENTER] (DO NOT USE THIS OPTION LIGHTLY, IT WILL BREAK THINGS):"
read newhost
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
hostname $newhost
echo "The hostname is now $newhost"
else
if [ $anshostname = "Y" ]
then
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "Please provide the hostname that you wish to use followed by [ENTER] (DO NOT USE THIS OPTION LIGHTLY, IT WILL BREAK THINGS):"
read newhost
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
hostname $newhost
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "The hostname is now $newhost"
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
else
if [ $anshostname = "" ]
then
:
else
if [ $anshostname = "N" ]
then
:
else
if [ $anshostname = "n" ]
then
:
else
:
fi
fi
fi
fi
fi
systemhostc=$(hostname)
export systemhostc
curl -k https://raw.githubusercontent.com/NHSCS-ORG/Ubuntu-Kickstart/master/nhscs-landscape.cer -o /usr/local/share/ca-certificates/nhscs-landscape.crt
curl -k https://raw.githubusercontent.com/NHSCS-ORG/Ubuntu-Kickstart/master/nhscs-landscape.cer -o /usr/share/ca-certificates/nhscs-landscape.crt
curl -k https://raw.githubusercontent.com/NHSCS-ORG/Ubuntu-Kickstart/master/Firewall_Certificate.cer -o /usr/local/share/ca-certificates/tf-firewall.crt
curl -k https://raw.githubusercontent.com/NHSCS-ORG/Ubuntu-Kickstart/master/Firewall_Certificate.cer -o /usr/share/ca-certificates/tf-firewall.crt
update-ca-certificates
/usr/bin/expect <<EOD
set systemhostc [puts $env(systemhostc)]
spawn "landscape-config --computer-title $systemhostc --account-name standalone --url https://EH3-NHSCS-LS01/message-system --ping-url http://EH3-NHSCS-LS01/ping"
expect "Start Landscape client on*" {send Y\r}
expect "Account registration*" {send \r}
expect "HTTP proxy*" {send \r}
expect "HTTPS proxy*" {send \r}
expect "Enable script execution*" {send Y\r}
expect "Script user*" {send ALL\r}
expect "Access grou*" {send \r}
expect "Tag*" {send \r}
expect "Request a new registration for this comp*" {send Y\r}
expect eof
EOD
sleep 5
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
echo "We're done. Rebooting in 10 seconds."
echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
sleep 10
restart now