-
Notifications
You must be signed in to change notification settings - Fork 11
/
Pi_ltsp
2759 lines (2374 loc) · 94 KB
/
Pi_ltsp
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Part of Raspi-LTSP https://github.com/gbaman/RaspberryPi-LTSP
#
# See LICENSE file for copyright and license details
version=0.10.46
#Raspi-LTSP
#Pi_LTSP
#Written by Andrew Mulholland, based off the fantastic work by vagrantc and alksig from the LTSP community
#Initial guide available at http://cascadia.debian.net/trenza/Documentation/raspberrypi-ltsp-howto/
#Spindle was used to figure out needed changes to generate Raspbian image https://github.com/asb/spindle
#
#Raspi-LTSP is a utility for setting up and configuring a Linux Terminal Server Project (LTSP) network for Raspberry Pi's
#Constants
#------------------------
ConfigFileLoc=/etc/raspi-ltsp
Timeout=1
PythonFunctions="/usr/local/bin/Pi_ltsp-functions-python.py"
PythonStart="python3"
p="$PythonStart $PythonFunctions"
RepositoryBase="https://github.com/gbaman/"
RepositoryName="RaspberryPi-LTSP"
RawRepositoryBase="https://raw.github.com/gbaman/"
Repository="$RepositoryBase$RepositoryName"
RawRepository="$RawRepositoryBase$RepositoryName"
ReleaseBranch="master"
ltspBase="/opt/ltsp/"
cpuArch="armhf"
#------------------------
VariablesSetup() {
#Configures the global variables for PiLTSP.
if [ -e "/opt/ltsp/.nbd" ]; then
NBD=$(head -n 1 /opt/ltsp/.nbd)
if [ -e "/opt/ltsp/.nbdUse" ]; then
NBDuse=$(head -n 1 /opt/ltsp/.nbdUse)
else
echo "false" > /opt/ltsp/.nbdUse
VariablesSetup
fi
if [ -e "/opt/ltsp/.NBDBuildNeeded" ]; then
NBDBuildNeeded=$(head -n 1 /opt/ltsp/.NBDBuildNeeded)
else
echo "false" > /opt/ltsp/.NBDBuildNeeded
VariablesSetup
fi
else
mkdir /opt/ltsp/
echo "false" > /opt/ltsp/.nbd
VariablesSetup
fi
}
LegacyFixes() {
if [ -d "/home/shared" ]; then
CheckSharedFolderIntegrity
fi
CheckDesktopShortcut
ReplaceAnyTextOnLine /opt/ltsp/armhf/etc/lts.conf "NFS_HOME=/home" ""
if [ -f "/etc/default/epoptes" ]; then
ReplaceTextLine "/etc/default/epoptes" "SOCKET_GROUP=staff" "SOCKET_GROUP=teacher"
fi
#ReplaceTextLine "/etc/sudoers.d/01staff" "%staff ALL=NOPASSWD: ALL" "%teacher ALL=NOPASSWD: ALL"
if [ ! -f "/opt/ltsp/armhf/usr/local/bin/Raspi-ltsp-screenshot.sh" ]; then
AddScreenshot
UpdateConfig NBDBuildNeeded true
fi
if [ ! -f "/usr/local/bin/changePassword.sh" ]; then
AddPasswordReset
UpdateConfig NBDBuildNeeded true
fi
local passwdVersion=$(cat /home/$SUDO_USER/Desktop/Raspi-ltsp-password.desktop | sed -n '2p')
if [ "$passwdVersion" = "Version=1.0" ]; then
rm -rf /etc/skel/Desktop/Raspi-ltsp-password.desktop
cut -d: -f1,3 /etc/passwd | egrep ':[0-9]{4}$' | cut -d: -f1 | while IFS= read -r user
do
rm -rf /home/$user/Desktop/Raspi-ltsp-password.desktop
done
AddPasswordReset
fi
ReplaceAnyTextOnLine /opt/ltsp/armhf/etc/lts.conf REMOTE_APPS REMOTE_APPS=True
exitcode=$?
sed -i '/^[[:blank:]]*$/d' /opt/ltsp/armhf/etc/lts.conf
if [ "$exitcode" = "1" ]; then
UpdateConfig NBDBuildNeeded true
fi
addSoundcardDefault
if [ $? = 1 ]; then
whiptail --title "Update" --msgbox "I have detected a high priority update to do sound on the Raspberry Pi. I will now apply the update." 8 78
UpdateConfig NBDBuildNeeded true
fi
DisableI2C_SPI
if [ -f "/opt/ltsp/armhf/usr/bin/scratch.old" ]; then
echo "-------------------------------------------------------------------------------------------------"
echo "NuScratch detected. It fails to work correctly with Raspi-LTSP at this time, so I will remove it."
echo "-------------------------------------------------------------------------------------------------"
ltsp-chroot apt-get purge -y nuscratch
UpdateConfig NBDBuildNeeded true
fi
ltsp-chroot dpkg-query -s raspberrypi-ui-mods > /dev/null 2>&1
if [ ! $? -eq 0 ]; then
InstallRaspberryPiUIMods
UpdateConfig NBDBuildNeeded true
fi
if [ "$NBDBuildNeeded" = "true" ]; then
echo "A required system update has been found. I will now compress the operating system again to apply this update"
NBDRun
fi
}
ConfigFileRead(){
#Taken from - http://wiki.bash-hackers.org/howto/conffile
configfile_secured="/tmp/raspi-config"
#touch $configfile_secured
#echo "reading $ConfigFileLoc"
if egrep -q -v '^#|^[^ ]*=[^;]*' "$ConfigFileLoc"; then
# filter the original to a new file
egrep '^#|^[^ ]*=[^;&]*' "$ConfigFileLoc" > "$configfile_secured"
ConfigFileLoc="$configfile_secured"
source "$ConfigFileLoc"
else
source "$ConfigFileLoc"
fi
#echo config read
}
ReplaceTextLine(){
# ReplaceTextLine /textfile bob brian
egrep -i "^$2" $1 >> /dev/null
if [ $? = 0 ]; then
sed -i "s/$2.*/$3/g" $1
else
echo "$3" >> $1
fi
}
ReplaceAnyTextOnLine(){
# ReplaceTextLine /textfile bob brian
#REMEMBER!! The & symbol can't be in any of the strings as SED is using it for separating. Can change it if need be
egrep -i "$2" $1 >> /dev/null
if [ $? -eq 0 ]; then
sed -i "s&.*$2.*&$3&g" $1
return 0
else
echo "$3" >> $1
return 1
fi
}
UpdateConfig(){
local configName=$1
local configValue=$2
egrep -i "^$configName" $ConfigFileLoc >> /dev/null
if [ $? = 0 ]; then
sed -i "s/$configName.*/$configName=$configValue/g" $ConfigFileLoc
else
echo "$configName=$configValue" >> $ConfigFileLoc
fi
ConfigFileRead
}
LegacyConfig(){
if [ ! -e "$ConfigFileLoc" ]; then
touch $ConfigFileLoc
fi
if [ -e "/opt/ltsp/.nbd" ]; then
UpdateConfig NBD $(head -n 1 /opt/ltsp/.nbd)
rm -f /opt/ltsp/.nbd
if [ -e "/opt/ltsp/.nbdUse" ]; then
UpdateConfig NBDuse $(head -n 1 /opt/ltsp/.nbdUse)
rm -rf /opt/ltsp/.nbdUse
fi
if [ -e "/opt/ltsp/.NBDBuildNeeded" ]; then
UpdateConfig NBDBuildNeeded $(head -n 1 /opt/ltsp/.NBDBuildNeeded)
rm -rf /opt/ltsp/.NBDBuildNeeded
fi
fi
if [ -e "/opt/ltsp/raspiLTSP" ]; then
rm -rf /opt/ltsp/raspiLTSP
fi
if [ -e "/opt/ltsp/.backup" ]; then
UpdateConfig backupLoc $(head -n 1 /opt/ltsp/.backup)
rm -rf /opt/ltsp/.backup
fi
}
gp(){
if [ -f /tmp/ltsptmp ]; then
echo $(head -n 1 /tmp/ltsptmp)
fi
}
installLTSP() {
#Installs main packages required by LTSP
apt-get update && apt-get upgrade -y
apt-get install -y ltsp-server qemu-user-static binfmt-support ldm-server sed git gnome-control-center nfs-kernel-server xml2 openssh-server inotify-tools bindfs
exitstatus=$?
if ! [ $exitstatus = 0 ]; then
whiptail --title "ERROR!" --msgbox "No internet connection detected or other software is already being installed! Please wait 5-10 minutes and try again or connect to the internet " 10 78
exit 1
fi
}
buildClient() {
#Creates the custom config file needed to build Raspbian and grabs keychain. Then starts the build
wget http://archive.raspbian.org/raspbian.public.key -O - | gpg --import
gpg --export 90FDDD2E >> /etc/ltsp/raspbian.public.key.gpg
rm /etc/ltsp/ltsp-raspbian.conf
cat <<EOF > /etc/ltsp/ltsp-raspbian.conf
DEBOOTSTRAP_KEYRING=/etc/ltsp/raspbian.public.key.gpg
DIST=wheezy
# For alternate raspbian mirrors, see: http://www.raspbian.org/RaspbianMirrors
MIRROR=http://mirrordirector.raspbian.org/raspbian
SECURITY_MIRROR=none
UPDATES_MIRROR=none
LOCALE="$LANG UTF-8"
KERNEL_PACKAGES=linux-image-3.10-3-rpi
EOF
VENDOR=Debian ltsp-build-client --arch armhf --config /etc/ltsp/ltsp-raspbian.conf
}
OneTimeFixes(){
#A number of one off fixes needed to be run
echo "/opt/ltsp *(ro,no_root_squash,async,no_subtree_check)" >> /etc/exports #sets up OS exporting for NFS
echo "/home *(rw,sync,no_subtree_check)" >> /etc/exports #Sets up home folder exporting for NFS
mkdir /etc/skel/handin
echo '#!/bin/sh' >> /etc/network/if-up.d/tftpd-hpa #Script to make sure tftpd-hpa autostarts
echo "service tftpd-hpa restart" >> /etc/network/if-up.d/tftpd-hpa
chmod 755 /etc/network/if-up.d/tftpd-hpa
service tftpd-hpa restart
groupadd -g 2122 pupil
groupadd -g 2123 teacher
}
configFixes() {
#Configuration file changes required after the client is built. These are not once off as they reside inside the Raspberry Pi OS
sed -i -e 's,/bin/plymouth quit --retain-splash.*,/bin/plymouth quit --retain-splash || true,g' /opt/ltsp/armhf/etc/init.d/ltsp-client-core
echo 'LTSP_FATCLIENT=true' >> /opt/ltsp/armhf/etc/lts.conf
#echo 'NFS_HOME=/home' >> /opt/ltsp/armhf/etc/lts.conf
cp '/opt/ltsp/armhf/etc/lts.conf' /var/lib/tftpboot/ltsp/armhf/lts.conf
printf 'snd-bcm2835\n' >> /opt/ltsp/armhf/etc/modules
addSoundcardDefault
}
addSoundcardDefault(){
grep -q mmap_emul "/opt/ltsp/armhf/etc/asound.conf" > /dev/null 2>&1
checkSound=$?
#echo $checkSound
if [ ! $checkSound = 1 ]; then
cat <<\EOF1 > /opt/ltsp/armhf/etc/asound.conf
pcm.!default {
type hw;
card 0;
}
ctl.!default {
type hw
card 0
}
EOF1
return 1
else
return 0
fi
}
checkInternet(){
$p CheckInternet $Timeout
thing=$(gp)
echo $thing
#WGET="/usr/bin/wget"
#$WGET -q --tries=20 --timeout=10 http://www.google.com -O /tmp/google.idx &> /dev/null
#if [ ! -s /tmp/google.idx ]
#then
# #return 1
# echo 1
#else
# echo 0
#fi
}
UpdateSD() {
#Function for updating the SD card images
#echo "$1"
#if [ $1 -eq 0 ]; then
#whiptail --title "Internet" --yesno "Do you currently have internet access?" 8 78
local Internet=$(checkInternet)
if [ $Internet -eq 0 ]; then
if [ ! -d "/opt/raspiLTSP" ]; then
mkdir /opt/raspiLTSP
fi
if [ ! -d "/opt/raspiLTSP/PiBootBackup" ]; then
mkdir /opt/raspiLTSP/PiBootBackup
fi
rm -rf /tmp/PiBoot
git clone --depth 1 $Repository.git /tmp/PiBoot #Clones main repository, including boot files
rm -rf /opt/raspiLTSP/PiBootBackup/*
cp /tmp/PiBoot/boot/* /opt/raspiLTSP/PiBootBackup/
UpdateIP
toReturn=0
else
if [ ! -d "/opt/raspiLTSP/PiBootBackup" ]; then
whiptail --title "Error" --msgbox "You are not connected to the internet and no backup of boot files was found... Please connect to the internet and run again." 8 78
toReturn=1
else
whiptail --title "Internet" --msgbox "I detected you are not connected to the internet. A new version of the boot files will not be downloaded, an old backup will be used. This is fine if all you want to do is change the SD card IP address." 9 78
UpdateIP
toReturn=0
fi
fi
if [ -d "/opt/ltsp/armhf/bootfiles" ]; then
local currentVersion=0
local newVersion=0
local currentVersion=$(head -n 1 "/opt/ltsp/armhf/bootfiles/version.txt")
local newVersion=$(head -n 1 "/opt/raspiLTSP/PiBootBackup/version.txt")
echo "$currentVersion $newVersion"
if (( $currentVersion < $newVersion )); then
rm -rf "/opt/ltsp/armhf/bootfiles/"
cp -rf "/opt/raspiLTSP/PiBootBackup/" "/opt/ltsp/armhf/bootfiles/"
rm -rf "/opt/ltsp/armhf/bootfiles/cmdline.txt"
NBDRun
fi
else
cp -rf "/opt/raspiLTSP/PiBootBackup/" "/opt/ltsp/armhf/bootfiles/"
rm -rf "/opt/ltsp/armhf/bootfiles/cmdline.txt"
NBDRun
fi
return $toReturn
}
UpdateIP(){
IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`; #Get the current main IP address
whiptail --title "Ip address" --yesno "Would you like to stick with the default IP address? (Recommended)" 8 78 #Check with this use that the IP address is correct
exitstatus=$?
if [ ! $exitstatus = 0 ]; then
IP=$(whiptail --inputbox "Please enter an IP address to use on the SD cards" 8 78 $IP --title "IP address" 3>&1 1>&2 2>&3)
exitstatus=$?
fi
service nfs-kernel-server restart #Restart the NFS kernel, just in case
if [ "$SUDO_USER" = "" ]; then
rm -rf ~/piBoot/
cp -r /opt/raspiLTSP/PiBootBackup/ ~/piBoot/
if [ "$NBD" = "true" ]; then #If NBD is enabled, us the NBD config file, if not, use NFS config file
rm ~/piBoot/cmdline.txt
cp ~/piBoot/cmdlineNBD.txt ~/piBoot/cmdline.txt
else
rm ~/piBoot/cmdline.txt
cp ~/piBoot/cmdlineNFS.txt ~/piBoot/cmdline.txt
fi
sudo sed -i 's/1.1.1.1/'$IP'/g' ~/piBoot/cmdline.txt
nautilus ~/piBoot > /dev/null 2>&1 &
else
rm -rf "/home/$SUDO_USER/piBoot/"
cp -r /opt/raspiLTSP/PiBootBackup/ "/home/$SUDO_USER/piBoot/"
chown -R "$SUDO_USER" "/home/$SUDO_USER/piBoot"
if [ "$NBD" = "true" ]; then #If NBD is enabled, us the NBD config file, if not, use NFS config file
rm /home/$SUDO_USER/piBoot/cmdline.txt
cp /home/$SUDO_USER/piBoot/cmdlineNBD.txt /home/$SUDO_USER/piBoot/cmdline.txt
else
rm /home/$SUDO_USER/piBoot/cmdline.txt
cp /home/$SUDO_USER/piBoot/cmdlineNFS.txt /home/$SUDO_USER/piBoot/cmdline.txt
fi
sudo sed -i 's/1.1.1.1/'$IP'/g' "/home/$SUDO_USER/piBoot/cmdline.txt"
nautilus "/home/$SUDO_USER/piBoot" > /dev/null 2>&1 &
fi
}
EnableNBDswap(){
#Enables NBD swap system. Allows the Raspberry Pis to use NBD partition as swap
rm /etc/nbd-server/conf.d/swap.conf
cat <<EOF > /etc/nbd-server/conf.d/swap.conf
[swap]
exportname = /tmp/nbd-swap/%s
prerun = nbdswapd %s
postrun = rm -f %s
EOF
service nbd-server restart
}
FixRepo() {
#Adds the repositories used by Raspbian. They public keys are included
rm -rf /opt/ltsp/armhf/etc/apt/sources.list.d/raspi.list
echo "deb http://archive.raspberrypi.org/debian/ wheezy main" > /opt/ltsp/armhf/etc/apt/sources.list.d/raspi.list
ltsp-chroot --arch armhf apt-key add - <<EOF1
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.12 (GNU/Linux)
mQENBE/d7o8BCACrwqQacGJfn3tnMzGui6mv2lLxYbsOuy/+U4rqMmGEuo3h9m92
30E2EtypsoWczkBretzLUCFv+VUOxaA6sV9+puT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1xVV9Ltno23YvX5edw9QY4hABEBAAGJAR8EGAECAAkFAk/d7o8CGwwA
CgkQgrEpkn+jMD5Figf/dIC1qtDMTbu5IsI5uZPX63xydaExQNYf98cq5H2fWF6O
yVR7ERzA2w33hI0yZQrqO6pU9SRnHRxCFvGv6y+mXXXMRcmjZG7GiD6tQWeN/3wb
EbAn5cg6CJ/Lk/BI4iRRfBX07LbYULCohlGkwBOkRo10T+Ld4vCCnBftCh5x2OtZ
TOWRULxP36y2PLGVNF+q9pho98qx+RIxvpofQM/842ZycjPJvzgVQsW4LT91KYAE
4TVf6JjwUM6HZDoiNcX6d7zOhNfQihXTsniZZ6rky287htsWVDNkqOi5T3oTxWUo
m++/7s3K3L0zWopdhMVcgg6Nt9gcjzqN1c0gy55L/g==
=mNSj
-----END PGP PUBLIC KEY BLOCK-----
EOF1
rm -rf /opt/ltsp/armhf/etc/apt/sources.list.d/collabora.list
echo "deb http://raspberrypi.collabora.com wheezy rpi" > /opt/ltsp/armhf/etc/apt/sources.list.d/collabora.list
ltsp-chroot --arch armhf apt-key add - <<EOF1
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.13 (GNU/Linux)
mQINBFGONkIBEADC69AVM/bJ15zZftt73ZtWzqER890BLRWYHNCCqidbcs+Ww2Bi
PGIfTOnsXQIGrdDKmtgjc4kskDTeG7VWCgmhzNBzvdNrfVYxv4EpzdWUxifEOYXo
RvEynwQ0AuehplOfZeVidzvWvBwuVDt0L3XRW8etjSYfjKSYnEVCsZW3EwVUs3zp
dyjHYjQSrjwaWfFZEtU7O4U6EUiGARJnOaim9bAh6fSsXy9qHDn4uFD3EjJgl9EK
XSmXYTMbkbajDwSBk4vAkZoP7VjgQKG2uVfDBqTvy3rXt1pwuJuzm/8RRn8g1esv
ZUhbdNDHzQi3GxWB2D7aPZCaEPMO5uD2+7d6KgkjoFXxx0iwqKnHYNp+ElT6J12b
AdzHqtCtOQFgkXqPCB/DQUo758Txwp5MRH3g7yCwsXBx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S7PJkthzHdGkNoneo/X
pZRR1qfCwFBNvNzkCG3ECggevh3fTEkVvhnVTIvzq5GUi9PsjjNtAt8JPxsJgZkg
FJLPlJTgpm8KR9OiIKn1z9RodqXSUZhE7Cw/koNzzNpjfo4tB4OmNueiCXObNRrr
jIaacoqqok301Mk3SVNc3YyEa/9HN5DmETrQS+9fhukP2Frcr4wOHJCajvxa+Sl7
oryGCWXqvBpSEucw1FDkOgoe5EwHvcdu+dzVypY0JZoLHQDV69aTiHFsZhBu6Ves
hG/v4/wnBFL5f0cl9t53GmEDcjsg5VKbcTmCMG6Z6DbNIusYAz98ucAqGupzKvA0
3C/Ik0Y1LI8iEYXPiUbgSBCZ4RrJsdtbZDRyy357pSr+5eB6eXLy1eBC84jv/A6h
HXWu9eprthyEIX6pmEhqzMViFix7FVozfdn2H4U=
=zyWt
-----END PGP PUBLIC KEY BLOCK-----
EOF1
ltsp-chroot --arch armhf debconf-set-selections <<SELEOF
wolfram-engine shared/accepted-wolfram-eula boolean true
SELEOF
#Auto accepts wolfram eula
echo deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi > /opt/ltsp/armhf/etc/apt/sources.list
#Adds the repos to apt-get
ltsp-chroot --arch armhf apt-get update
#Fetches most recent package lists
}
InstallProgram() {
#Installing custom programs into the chroot
INSTALLP=$(whiptail --inputbox "What program would you like to install?" 8 78 $INIT --title "You can enter multiple programs by leaving a space between each" 3>&1 1>&2 2>&3)
exitstatus=$?
clear
echo "------------------------------------------------------"
echo "Am about to try and install " $INSTALLP
echo "Are you sure? y or n"
echo "------------------------------------------------------"
read RESULT
if [ "$RESULT" = "y" ]; then
echo "Updating software lists"
echo ""
ltsp-chroot --arch armhf apt-get update
ltsp-chroot --arch armhf apt-get -y install $INSTALLP
if [ $? -eq 0 ]; then
UpdateConfig NBDBuildNeeded true
echo "-----------------------------"
echo $INSTALLP " was installed correctly"
echo "-----------------------------"
sleep 4
else
echo "-----------------------------"
echo "ERROR"
echo $INSTALLP " was NOT installed correctly Read error above"
echo "-----------------------------"
sleep 8
fi
fi
}
Finished() {
#Function performing any actions that should happen after the boot image has been created
whiptail --title "Install complete" --msgbox "The client install is complete, a boot.img file has been placed in /root folder, write this to an sd card" 16 78
}
RaspiTheme(){
#Grabs a copy of the custom Raspberry Pi login screen and applies it
rm -rf RaspberryPi-LTSP
git clone --depth 1 $Repository.git
cp -r RaspberryPi-LTSP/themes/raspi /opt/ltsp/armhf/usr/share/ldm/themes/raspi
rm /opt/ltsp/armhf/etc/alternatives/ldm-theme
ln -s /usr/share/ldm/themes/raspi /opt/ltsp/armhf/etc/alternatives/ldm-theme
rm -rf RaspberryPi-LTSP
cp /opt/ltsp/armhf/usr/share/ldm/themes/raspi/bg.png /opt/ltsp/armhf/usr/share/images/desktop-base/raspi-LTSP.png
sudo ltsp-chroot --arch armhf update-alternatives --install /usr/share/images/desktop-base/desktop-background desktop-background /usr/share/images/desktop-base/raspi-LTSP.png 100
}
NBDRun() {
#Checks if it should be auto NBD compressing or not, if it should be, it recompresses the image
ConfigFileRead
if [ "$NBD" = "true" ]; then #If NBD is enabled on the system overall
if [ "$NBDuse" = "true" ]; then #If temporarily NBD is disable
echo "--------------------------------------------------------"
echo "Compressing the image, this will take roughly 5 minutes"
echo "--------------------------------------------------------"
ltsp-update-image /opt/ltsp/armhf #If NBD is enabled, recompress the image
UpdateConfig NBDBuildNeeded false
else
whiptail --title "WARNING" --msgbox "Auto NBD compressing is disabled, for your changes to push to the Raspberry Pis, run NBD-recompress from main menu" 8 78
fi
fi
}
NBDSetup() {
#Setup function for NBD, asks user if they wish to use it, if not it defaults to NFS
whiptail --title "Network technology" --yesno "2 network technologies are available for Raspi-LTSP. NBD and NFS. NBD uses compression dramatically improving application loading times. The tradeoff though is after every modification to the operating system, the image must be recompressed which can take around 5 minutes. NFS is slower but does not need compressed, all changes run live. If in doubt, select NBD." --yes-button "NBD" --no-button "NFS" 11 78
exitstatus=$?
if [ $exitstatus = 0 ]; then
EnableNBD
else
UpdateConfig NBD false
UpdateConfig NBDuse false
UpdateConfig NBDBuildNeeded false
ConfigFileRead
fi
}
EnableNBD() {
/usr/sbin/ltsp-update-image --config-nbd /opt/ltsp/armhf
service nbd-server restart
UpdateConfig NBD true
UpdateConfig NBDuse true
UpdateConfig NBDBuildNeeded false
ConfigFileRead
}
AddSoftware(){
#All the software not included in normal base Debian that has been added to Raspbian normally by Spindle
#------------------------------------------------------------------------------------------
#******************************************************************************************
# To add more software, just add it to the end of the list below taking a space after each program
ltsp-chroot --arch armhf apt-get install -y idle idle3 python-dev nano python3-dev scratch python3-tk git debian-reference-en dillo python python-pygame python3-pygame python-tk sudo sshpass pcmanfm chromium python3-numpy wget xpdf gtk2-engines alsa-utils wpagui omxplayer lxde net-tools
ltsp-chroot --arch armhf apt-get install -y ssh locales less fbset sudo psmisc strace module-init-tools ifplugd ed ncdu console-setup keyboard-configuration debconf-utils parted unzip build-essential manpages-dev python bash-completion gdb pkg-config python-rpi.gpio v4l-utils lua5.1 luajit hardlink ca-certificates curl fake-hwclock ntp nfs-common usbutils libraspberrypi-dev libraspberrypi-doc libfreetype6-dev
ltsp-chroot --arch armhf apt-get install -y python3-rpi.gpio python-rpi.gpio python-pip python-picamera python3-picamera x2x wolfram-engine xserver-xorg-video-fbturbo netsurf-common netsurf-gtk rpi-update
ltsp-chroot --arch armhf apt-get install -y ftp libraspberrypi-bin python3-pifacecommon python3-pifacedigitalio python3-pifacedigital-scratch-handler python-pifacecommon python-pifacedigitalio i2c-tools linux-image-rpi-rpfv man-db
ltsp-chroot --arch armhf apt-get install -y --no-install-recommends cifs-utils midori lxtask
ltsp-chroot --arch armhf apt-get install -y minecraft-pi python-smbus dosfstools ruby
ltsp-chroot --arch armhf apt-get install -y gstreamer1.0-x gstreamer1.0-omx gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa gstreamer1.0-libav
ltsp-chroot --arch armhf apt-get install --no-install-recommends -y epiphany-browser cgroup-bin
ltsp-chroot apt-get install -y java-common oracle-java8-jdk apt-utils wpasupplicant wireless-tools firmware-atheros firmware-brcm80211 firmware-libertas firmware-ralink firmware-realtek libpng12-dev
ltsp-chroot --arch armhf update-rc.d nfs-common disable
ltsp-chroot --arch armhf update-rc.d rpcbind disable
ltsp-chroot --arch armhf apt-get install -y linux-image-3.18.0-trunk-rpi linux-image-3.18.0-trunk-rpi2 linux-image-3.12-1-rpi linux-image-3.10-3-rpi linux-image-3.2.0-4-rpi linux-image-rpi-rpfv linux-image-rpi2-rpfv
ltsp-chroot --arch armhf apt-get install -y libqt4-network #Remove this when Sonic-Pi 2 update fixing the dependency issue is released.
sudo DEBIAN_FRONTEND=noninteractive ltsp-chroot --arch armhf apt-get install -y sonic-pi
if [ ! -f /opt/ltsp/armhf/usr/local/bin/raspi2png ]; then
wget https://github.com/AndrewFromMelbourne/raspi2png/blob/master/raspi2png?raw=true -O /tmp/raspi2png
cp -r /tmp/raspi2png /opt/ltsp/armhf/usr/local/bin/raspi2png
chmod 755 /opt/ltsp/armhf/usr/local/bin/raspi2png
fi
#Server software
apt-get install -y bindfs python3-feedparser
#******************************************************************************************
#------------------------------------------------------------------------------------------
}
PiConfigFixes(){
#Configuration changes to Raspberry Pi files, mostly to do with LXDE instead of Raspbian itself
ltsp-chroot --arch armhf sed /etc/xdg/lxsession/LXDE/desktop.conf -i -e "s|sNet/ThemeName.*|sNet/ThemeName=Mist|"
ltsp-chroot --arch armhf sed /etc/xdg/openbox/LXDE/rc.xml -i -e \
"s|<drawContents>yes</drawContents>|<drawContents>no</drawContents>|"
ltsp-chroot --arch armhf apt-get install -y raspberrypi-artwork
ltsp-chroot --arch armhf update-alternatives --install /usr/share/images/desktop-base/desktop-background desktop-background /usr/share/raspberrypi-artwork/raspberry-pi-logo.png 100
ltsp-chroot --arch armhf PCMANFMCFG=/etc/xdg/pcmanfm/LXDE/pcmanfm.conf
ltsp-chroot --arch armhf sed "$PCMANFMCFG" -i -e 's/^wallpaper_mode.*/wallpaper_mode=3/'
ltsp-chroot --arch armhf sed "$PCMANFMCFG" -i -e 's/^desktop_bg.*/desktop_bg=#ffffff/'
ltsp-chroot --arch armhf sed "$PCMANFMCFG" -i -e 's/^su_cmd.*/su_cmd=gksu %s/'
}
EpoptesInstaller() {
apt-get update
apt-get install -y epoptes
gpasswd -a root staff
ltsp-chroot --arch armhf apt-get update
ltsp-chroot --arch armhf apt-get install -y epoptes-client --no-install-recommends
ltsp-chroot --arch armhf epoptes-client -c
ReplaceTextLine "/etc/default/epoptes" "SOCKET_GROUP" "SOCKET_GROUP=teacher"
}
EpoptesRun() {
su -c "epoptes &" $SUDO_USER > /dev/null 2>&1 &
}
fixGroups(){
#Adds users to correct needed groups
#Adds all the groups if they don't exist
for ugroup in adm dialout cdrom audio users sudo video games plugdev input; do
egrep -i "^$ugroup" /etc/group >> /dev/null
if [ $? = 1 ]; then
groupadd $ugroup
fi
done
#Adds all users to all the required groups if they aren't already in them
cut -d: -f1,3 /etc/passwd | egrep ':[0-9]{4}$' | cut -d: -f1 | while IFS= read -r user #Gets
do
for ugroup in adm dialout cdrom audio users video games plugdev input pupil; do
if ! groups "$user" | grep -q -E ' $ugroup(\s|$)'; then
usermod -a -G $ugroup $user
fi
done
done
egrep -i "^teachers" /etc/group >/dev/null
if [ $? -eq 0 ]; then
groupdel teachers
fi
local teacherID=$(egrep -i "^teacher" /etc/group | cut -d: -f3)
if [ ! "$teacherID" = "2123" ]; then
groupdel teacher
groupadd teacher -g 2123
whiptail --title "Reboot required" --msgbox "Warning, once this upgrade process completes, you must restart the server to refresh user groups which have just changed." 8 78
fixGroups
fi
egrep -i "^teacher" /etc/group >/dev/null
if [ ! $? -eq 0 ]; then
groupadd teacher -g 2123
fi
local pupilID=$(egrep -i "^pupil" /etc/group | cut -d: -f3)
if [ ! "$pupilID" = "2122" ]; then
groupdel pupil
groupadd pupil -g 2122
fixGroups
fi
cut -d: -f1,3 /etc/passwd | egrep ':[0-9]{4}$' | cut -d: -f1 | while IFS= read -r user
do
if groups "$user" | grep -q -E 'staff(\s|$)'; then
gpasswd -a $user teacher
gpasswd -d $user staff
fi
done
}
AddTeacher() {
whiptail --title "Teacher" --msgbox "Teachers have full admin access on the server (so can run Raspi-ltsp), full read/write access to all shared folders and Epoptes teacher level (so can control students computers)." 9 78
username=$(SelectUser "to add to the teacher group.")
if [ ! $username = 1 ]; then
INIT=""
AddUserToTeacher $username
whiptail --title "Success" --msgbox "The user $username has been added to the teacher group." 8 78
fi
}
AddUserToTeacher() {
usermod -a -G teacher $1
AddDesktopShortcutToUser $1
}
FixDesktopIcons(){
rm -rf /etc/skel/Desktop
cd /opt/ltsp/armhf/usr/share/applications
mkdir /etc/skel/Desktop
sudo cp -a scratch.desktop idle.desktop idle3.desktop lxterminal.desktop debian-reference-common.desktop wolfram-mathematica.desktop epiphany-browser.desktop wolfram-language.desktop sonic-pi.desktop minecraft-pi.desktop /etc/skel/Desktop
cd /etc/skel
wget "https://github.com/KenT2/python-games/tarball/master" -O python_games.tar.gz
tar -xvf python_games.tar.gz
mv KenT2-python-games* python_games
chmod +x python_games/launcher.sh
rm python_games.tar.gz
cd /etc/skel/Desktop
cat <<\EOF2 > python-games.desktop
[Desktop Entry]
Name=Python Games
Comment=From http://inventwithpython.com/pygame/
Exec=sh -c $HOME/python_games/launcher.sh
Icon=/usr/share/pixmaps/python.xpm
Terminal=false
Type=Application
Categories=Application;Games;
StartupNotify=true
EOF2
cut -d: -f1,3 /etc/passwd | egrep ':[0-9]{4}$' | cut -d: -f1 | while IFS= read -r user
do
mkdir /home/$user/Desktop
cd /home/$user/Desktop/
cp -R /etc/skel/Desktop/* /home/$user/Desktop/
chown -R "$user" *
cp -R /etc/skel/python_games /home/$user/python_games
done
AddScreenshot
AddPasswordReset
}
PiControlInstallNew(){
#Installs picontrol software using the new setup.py
rm -rf Pi_Connector
git clone --depth 1 https://github.com/gbaman/Pi_Connector.git
python Pi_Connector/setup.py ltsp full
}
CollectWork(){
#A work collection system. It grabs files from students "handin" folders, copies them to "submitted" folder on the server and changes their owner
INIT="$SUDO_USER"
USERHAND=$(whiptail --inputbox "Enter the username of the user account you want to save the collected work to. This is usually your own account name" 8 78 $INIT --title "User selection" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
whiptail --title "WARNING" --yesno "The current submitted folder will be deleted, are you sure?" 8 78
exitstatus=$?
if [ $exitstatus = 0 ]; then
rm -rf /home/"$USERHAND"/submitted
mkdir /home/"$USERHAND"/submitted
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ "$USERHAND" != "" ]; then
cut -d: -f1,3 /etc/passwd | egrep ':[0-9]{4}$' | cut -d: -f1 | while IFS= read -r user
do
if groups "$user" | grep -q -E ' pupil(\s|$)'; then
if [ -d "/home/$user/handin" ]; then
echo "The user $user has a handin folder"
cp -r "/home/$user/handin/" "/home/$USERHAND/submitted/$user/"
fi
else
echo "The user $user does not have a handin folder"
fi
done
chown -R "$USERHAND" /home/"$USERHAND"/submitted
whiptail --title "Complete" --msgbox "Students work has been collected and can be found in /home/$USERHAND/submitted/" 8 78
else
whiptail --title "ERROR" --msgbox "The username can't be blank!" 8 78
fi
else
whiptail --title "ERROR" --msgbox "The user $USERHAND was not found!" 8 78
fi
fi
fi
}
CopyToUsers(){ #(Path-to-folder, path-in-home, skel? warning?)
#Used to copy files out to every user, plus to the skel folder for new users
if [ $4 == "True" ]; then
whiptail --title "WARNING" --yesno "This involves copying a folder to the users home folder, if it already exists should we delete it?" 8 78
local delete=$?
else
local delete=0
fi
local CurrentFilepath=$1
local NewFilepath=$2
local filename=$(basename "$NewFilepath")
cut -d: -f1,3 /etc/passwd | egrep ':[0-9]{4}$' | cut -d: -f1 | while IFS= read -r user
do
if [ $delete = 0 ] ; then
rm -rf "/home/$user/$NewFilepath"
fi
mkdir -p "/home/$user/"$(dirname ${NewFilepath})
cp -r "$CurrentFilepath" "/home/$user/$NewFilepath"
chown -R "$user" "/home/$user/$NewFilepath"
done
if [ $3 == "True" ]; then
mkdir -p "/etc/skel/"$(dirname ${NewFilepath})
cp -r "$CurrentFilepath" "/etc/skel/$NewFilepath"
fi
}
SudoMenu(){
#Used to enable Sudo on pupil accounts
whiptail --title "WARNING" --yesno 'Would you like to enable Sudo use for pupils? Giving pupils access to Sudo can be dangerous, they could do nasty things! But Sudo is required for GPIO use. It should only be enabled if needed. You can change your mind later the in Manage-Users submenu.' 10 78
exitstatus=$?
if [ $exitstatus = 0 ]; then
rm -f /opt/ltsp/armhf/etc/sudoers.d/01pupil
touch /opt/ltsp/armhf/etc/sudoers.d/01pupil
chmod 440 /opt/ltsp/armhf/etc/sudoers.d/01pupil
echo '%pupil ALL=NOPASSWD: ALL' >> /opt/ltsp/armhf/etc/sudoers.d/01pupil
UpdateConfig NBDBuildNeeded true
fi
}
FinishedInstallingSoftware(){
whiptail --title "Finished?" --yesno 'Are you finished installing software?' 10 78
exitstatus=$?
if [ $exitstatus = 0 ]; then
if [ "$NBDBuildNeeded" = "true" ]; then
NBDRun
fi
else
ExtraSoftware
fi
}
fileSelect(){
results=$(whiptail --title "Current location $(pwd)" --menu "Select a folder. To select this folder, select ./ and to go up a folder, select ../ " 20 80 10 `for x in $(ls -pa | grep "/"); do echo $x "-"; done` 2>&1 >/dev/tty)
exitstatus=$?
if [ "$exitstatus" = "1" ]; then
echo "The user canceled :( "
return "1"
else
if [ "$results" = "./" ]; then
location=$(pwd)
echo "chosen location is $location"
else
cd "$results"
fileSelect
fi
fi
}
removeAnacronLines() {
sed --in-place '/RaspiLTSP.backup/d' /etc/anacrontab
sed --in-place '/RaspiLTSP.backup/d' /etc/anacrontab
sed --in-place '/RaspiLTSP.backup/d' /etc/anacrontab
}
createBackupScript(){
rm -rf /usr/local/bin/Raspi-LTSP-backup.sh
echo 'currentDate=`date +"%d-%m-%y"`
currentTime=`date +"%H_%M"`
if [ ! $backupLoc = "" ]; then
LOCATION=$backupLoc
if [ -d "$LOCATION" ]; then
find "$LOCATION" -name "*Raspi-Users-Backup.tar.gz" -ctime +"$DELETETIME" | xargs rm -rf
tar -zcvf "$LOCATION$currentDate--$currentTime--Raspi-Users-Backup.tar.gz" /home
exitstatus=$?
if [ $exitstatus = 0 ]; then
logger -s "$currentDate $currentTime - Backup of users files was successful" 2>> /var/log/Raspi-backup.log
else
logger -s "$currentDate $currentTime - Backup failed with tar errorcode $exitstatus" 2>> /var/log/Raspi-backup.log
fi
else
logger -s "$currentDate $currentTime - Backup folder unavailable!" 2>> /var/log/Raspi-backup.log
fi
else
logger -s "$currentDate $currentTime - No backup location specified!" 2>> /var/log/Raspi-backup.log
fi' >> /usr/local/bin/Raspi-LTSP-backup.sh
chmod +x /usr/local/bin/Raspi-LTSP-backup.sh
}
AddUsers(){
username=$(whiptail --inputbox "Enter new username" 8 78 $INIT --title "Username" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ "$exitstatus" = "0" ]; then
password=$(whiptail --inputbox "Enter new password" 8 78 $INIT --title "Password" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ "$exitstatus" = "0" ]; then
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then