-
Notifications
You must be signed in to change notification settings - Fork 0
/
ltsp-setup.sh
293 lines (241 loc) · 8.01 KB
/
ltsp-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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#! /bin/sh
## Version: April 2016
## Author: Robert Kosmac
##
## Description: Installs Ubuntu LTSP with some software
##
## Sources: http://www.havetheknowhow.com/Configure-the-server/Install-LTSP.html
## https://www.thefanclub.co.za/how-to/configure-update-auto-login-ubuntu-12-04-ltsp-fat-clients
## https://help.ubuntu.com/community/UbuntuLTSP/ProxyDHCP
## http://manpages.ubuntu.com/manpages/raring/man5/lts.conf.5.html
## http://ubuntuforums.org/showthread.php?t=2173749
##
echo "================README======================="
echo "This script is written for the setup of Ubuntu LTSP within
a standard network, where the router acts as a DHCP Server.
In this instance, you will need to add the required forwarders
for PXE Boot to the router.
For Cisco routers, add the following in your DHCP Pool:
-> bootfile ltsp/<arch type>/pxelinux.0
-> next-server <LTSP Server IP>
eg:
bootfile ltsp/i386/pxelinux.0
next-server 10.0.12.23
REQUIREMENTS:
- Ubuntu Server 14.04
- Static Network addressing set for server
- SSH Server running
- 4GB RAM (Less than 4 is not recommended in production environment)
- 20GB avaliable space in Root (average image build with this script is between 7-10 GB)
NOTE: This script should be run as root.
WARNING: This script has not yet been fully tested and will
alter files in the process. Use at your own risk."
echo "============================================="
read -p "Do you wish to continue? (y/n)" CONTI
case $CONTI in
[yY][eE][sS]|[yY]) ;;
*)
echo "Script Canceled"
exit 1;
;;
esac
echo "===================LTSP DETAILS==================="
read -p "Enter your LTSP Server IP address (eg 10.0.12.23): " NETADD
read -p "Enter your DHCP subnet address (eg 10.0.12.0): " NETWK
read -p "Enter your primary DNS Server address (eg 10.0.12.254): " DNSADD
# Specifies the architecture to be built for clients
read -p "Select Thin Client Architecture:
1. i386 (32-bit) - Older single-core (and early dual-core) devices, or clients running 2GB RAM or less.
2. amd64 (64-bit) - Modern multi-core devices, or when more than 4GB RAM on Client.
Option: (1-2) " AVAL
# Setup the ARCH value
case $AVAL in
# Option 1 set 32-bit architechture
1) ARCH="i386" ;;
# Option 2 set 64-bit architechture
2) ARCH="amd64" ;;
# Default arcitecture set to 32-bit
*) ARCH="i386" ;;
esac
# Sets the SSH port number used by LTSP - some environments change the default
read -p "Enter the Server SSH port in use (eg 22): " SSHPORT
# Sets the max RAM usable on the Client device for XORG, can prevent RAM demanding services from killing the device
read -p "Set the maximum amount of RAM (in percentage) allowed on the client-side device (eg 80): " XRAM
echo "===================SOFTWARE==================="
read -p "Select the desired Desktop Environment:
1. Ubuntu Desktop (Unity)
2. Gnome Destop
3. Lubuntu Desktop (LXDE)
4. Kubuntu Desktop (KDE)
5. Cinnamon Desktop (Gnome)
6. Budgie Desktop (EvolveOS)
7. No Desktop
Option: (1-7) " DSKOPT
# Ask about document processor and concatentae the package if requested
read -p "Do you want LibreOffice installed? (y/n)" LBOFF
case $DSKOPT in
# Option 1 setup for Unity style desktop with LibreOffice if selected
1) INSTALL=" ubuntu-desktop --no-install-recommends"
case $LBOFF in
[yY][eE][sS]|[yY])
INSTALL="$INSTALL libreoffice"
;;
*) ;;
esac ;;
# Option 2 setup for Gnome 3 style desktop with LibreOffice if selected
2) INSTALL=" xorg gnome-core gnome-system-tools gnome-app-install"
case $LBOFF in
[yY][eE][sS]|[yY])
INSTALL="$INSTALL libreoffice"
;;
*) ;;
esac ;;
# Option 3 setup for LXDE style desktop with LibreOffice if selected
3) INSTALL=" lubuntu-desktop --no-install-recommends"
case $LBOFF in
[yY][eE][sS]|[yY])
INSTALL="$INSTALL libreoffice-gnome"
;;
*) ;;
esac ;;
# Option 4 setup for KDE 4 style desktop with LibreOffice if selected
4) INSTALL=" kubuntu-desktop --no-install-recommends"
case $LBOFF in
[yY][eE][sS]|[yY])
INSTALL="$INSTALL libreoffice-kde"
;;
*) ;;
esac ;;
# Option 5 setup for Cinnamon 2.x desktop with LibreOffice if selected
5) #add-apt-repository -y ppa:moorkai/cinnamon
INSTALL=" cinnamon"
case $LBOFF in
[yY][eE][sS]|[yY])
INSTALL="$INSTALL libreoffice-gnome"
;;
*) ;;
esac ;;
# Option 6 setup for Budgie desktop from Evolve OS, with LibreOffice if selected
6) add-apt-repository -y ppa:evolve-os/ppa
INSTALL=" budgie-desktop"
case $LBOFF in
[yY][eE][sS]|[yY])
INSTALL="$INSTALL libreoffice"
;;
*) ;;
esac ;;
# Option 7 - no desktop environment, LibreOffice installed if selected
7) INSTALL=""
case $LBOFF in
[yY][eE][sS]|[yY])
INSTALL="$INSTALL libreoffice"
;;
*) ;;
esac ;;
# DEFAULT option - bad desktop selection, same as Option 5
*)
case $LBOFF in
[yY][eE][sS]|[yY])
INSTALL=" libreoffice"
;;
*) ;;
esac ;;
esac
# Ask about the web browser
read -p "Do you want Firefox Browser (Flash Plugin included)? (y/n)" FFBRS
read -p "Do you want Chromium Browser? (y/n)" CHMBRS
# Concatenate the browser install to the INSTALL string
case $FFBRS in
[yY][eE][sS]|[yY])
INSTALL="$INSTALL firefox flashplugin-installer"
;;
*) ;;
esac
case $CHMBRS in
[yY][eE][sS]|[yY])
INSTALL="$INSTALL chromium-browser"
;;
*) ;;
esac
echo "Super! Now we will start the installation and build the server.
This may take between 30 minutes and 3 hours, depending on your internet
connection and the speed of your server.
During this time, you should not need to input anything, so go get yourself
a cuppa and relax while you wait.
CAUTION! The server will reboot when complete."
# Check to ensure that ready to go
echo "The INSTALL command (Testing):"
echo $INSTALL
read -p "Are you ready? (y/n)" VERIFYREADY
case $VERIFYREADY in
[yY][eE][sS]|[yY]) ;;
*)
echo "Script Canceled"
exit 1;
;;
esac
# Start installation of LTSP
echo "Running updates.........."
apt-get update
sleep 2
apt-get upgrade -y
sleep 3
echo "Installing LTSP.........."
apt-get install ltsp-server dnsmasq tftpd-hpa -y
sleep 3
echo "Building initial LTSP Image.........."
ltsp-build-client --arch $ARCH
# Write to Config data to file
echo "Updating and creating configuration files.........."
sed -i 's/ipappend 2/ipappend 3/g' /var/lib/tftpboot/ltsp/$ARCH/pxelinux.cfg/default
#DSNmasq config file
echo '
dhcp-range=$NETWK,proxy
dhcp-option=vendor:PXEClient,6,2b
dhcp-no-override
pxe-prompt="Press F8 for boot menu", 3
pxe-service=x86PC, "Boot from network", /ltsp/i386/pxelinux
pxe-service=x86PC, "Boot from local hard disk"' > /etc/dnsmasq.d/ltsp.conf
#Restart DNSMASQ
service dnsmasq restart
# port=0
# log-dhcp
# tftp-root=/var/lib/tftpboot
# dhcp-boot=/ltsp/$ARCH/pxelinux.0
# dhcp-option=17,/opt/ltsp/$ARCH
# dhcp-option=vendor:PXEClient,6,2b
# dhcp-no-override
# # PXE menu
# #pxe-prompt="Press F8 for boot menu", 3
# # The known types are x86PC, PC98, IA64_EFI, Alpha, Arc_x86, Intel_Lean_Client, IA32_EFI, BC_EFI, Xscale_EFI and X86-64_EFI
# pxe-service=X86PC, "Boot from network", /ltsp/$ARCH/pxelinux
# pxe-service=X86PC, "Boot from local hard disk", 0
# dhcp-range=$NETADD,proxy
# " > /etc/dnsmasq.d/ltsp.conf
# LTS Config file
echo "[Default]
# Client settings
X_RAMPERC = $XRAM
SSH_OVERRIDE_PORT = $SSHPORT
X_COLOR_DEPTH = 32
X_NUMLOCK = True
# Force DNS Settings
DNS_SERVER = $DNSADD
" > /var/lib/tftpboot/ltsp/$ARCH/lts.conf
#echo "Building initial LTSP Image.........."
#ltsp-build-client --arch $ARCH &> ltsp-installer.log
sleep 5
echo "Installing software to image.........."
chroot /opt/ltsp/$ARCH apt-get install $INSTALL -y #&> ltsp-installer.log
sleep 5
echo "Rebuilding the LTSP image.........."
ltsp-update-sshkeys #&> ltsp-installer.log
sleep 1
ltsp-update-image $ARCH #&> ltsp-installer.log
sleep 1
sed -i 's/ipappend 2/ipappend 3/g' /var/lib/tftpboot/ltsp/$ARCH/pxelinux.cfg/default
#echo "Build is complete. Server will reboot in 10 seconds.........."
#sleep 10
# reboot
echo "Done!"
exit