forked from wjr1985/install-script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathendeavour-ARM-install-V2.7.sh
More file actions
executable file
·1025 lines (898 loc) · 36.9 KB
/
endeavour-ARM-install-V2.7.sh
File metadata and controls
executable file
·1025 lines (898 loc) · 36.9 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
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
ZONE_DIR="/usr/share/zoneinfo/"
declare -a TIMEZONE_LIST
generate_timezone_list() {
input=$1
if [[ -d $input ]]; then
for i in "$input"/*; do
generate_timezone_list $i
done
else
TIMEZONE=${input/#"$ZONE_DIR/"}
TIMEZONE_LIST+=($TIMEZONE)
TIMEZONE_LIST+=("")
fi
}
_status_checker() {
local status_code
status_code="$1"
if [[ "$status_code" -eq 1 ]]; then
printf "${CYAN}Exiting setup..${NC}\n"
exit
fi
}
_ok_nok() {
# Requires that variable "MESSAGE" be set
local status
status=$?
if [[ $status -eq 0 ]]
then
printf "${GREEN}$MESSAGE OK${NC}\n"
printf "$MESSAGE OK\n" >> /root/enosARM.log
else
printf "${RED}$MESSAGE FAILED${NC}\n"
printf "$MESAGE FAILED\n" >> /root/enosARM.log
printf "\n\nLogs are stored in: /root/enosARM.log\n"
exit 1
fi
sleep 1
} # end of function _ok_nok
_find_mirrorlist() {
# find and install current endevouros-arm-mirrorlist
local tmpfile
local currentmirrorlist
printf "\n${CYAN}Find current endeavouros-mirrorlist...${NC}\n\n"
MESSAGE="\nFind current endeavouros-mirrorlist "
sleep 1
curl https://github.com/endeavouros-team/repo/tree/master/endeavouros/$ARMARCH | grep "endeavouros-mirrorlist" | sed s'/^.*endeavouros-mirrorlist/endeavouros-mirrorlist/'g | sed s'/pkg.tar.zst.*/pkg.tar.zst/'g |tail -1 > mirrors
tmpfile="mirrors"
read -d $'\x04' currentmirrorlist < "$tmpfile"
printf "\n${CYAN}Downloading endeavouros-mirrorlist...${NC}"
MESSAGE="\nDownloading endeavouros-mirrorlist "
wget https://github.com/endeavouros-team/repo/raw/master/endeavouros/$ARMARCH/$currentmirrorlist 2>> /root/enosARM.log
_ok_nok # function call
printf "\n${CYAN}Installing endeavouros-mirrorlist...${NC}\n"
MESSAGE="\nInstalling endeavouros-mirrorlist "
pacman -U --noconfirm $currentmirrorlist &>> /root/enosARM.log
_ok_nok # function call
printf "\n[endeavouros]\nSigLevel = PackageRequired\nInclude = /etc/pacman.d/endeavouros-mirrorlist\n\n" >> /etc/pacman.conf
rm mirrors
} # end of function _find_mirrorlist
_find_keyring() {
local tmpfile
local currentkeyring
printf "\n${CYAN}Find current endeavouros-keyring...${NC}\n\n"
MESSAGE="\nFind current endeavouros-keyring "
sleep 1
curl https://github.com/endeavouros-team/repo/tree/master/endeavouros/$ARMARCH |grep endeavouros-keyring | sed s'/^.*endeavouros-keyring/endeavouros-keyring/'g | sed s'/pkg.tar.zst.*/pkg.tar.zst/'g | tail -1 > keys
tmpfile="keys"
read -d $'\04' currentkeyring < "$tmpfile"
printf "\n${CYAN}Downloading endeavouros-keyring...${NC}"
MESSAGE="\nDownloading endeavouros-keyring "
wget https://github.com/endeavouros-team/repo/raw/master/endeavouros/$ARMARCH/$currentkeyring 2>> /root/enosARM.log
_ok_nok # function call
printf "\n${CYAN}Installing endeavouros-keyring...${NC}\n"
MESSAGE="Installing endeavouros-keyring "
pacman -U --noconfirm $currentkeyring &>> /root/enosARM.log
_ok_nok # function call
rm keys
} # End of function _find_keyring
_filter_packages() {
# Function to filter out non-existent packages
# Parameters:
# $1: Input file containing list of packages
# $2: Output file for valid packages
# Returns:
# 0: If valid packages were found
# 1: If no valid packages were found
local input_file="$1"
local output_file="$2"
local has_valid_packages=0
# Create a new file for valid packages
true > "$output_file"
# Check each package and filter out non-existent ones
printf "\n${CYAN}Checking package availability...${NC}\n"
while read package; do
# Skip empty lines and comments
if [[ -z "$package" || "$package" =~ ^# ]]; then
continue
fi
# Check if package exists using pacman -Si which is more accurate than pacman -Ss
if pacman -Si "$package" > /dev/null 2>&1; then
# Package exists, add to valid packages file
echo "$package" >> "$output_file"
has_valid_packages=1
else
# Package doesn't exist, print in RED and log it
printf "${RED}Package not found: $package${NC}\n"
printf "Package not found: $package\n" >> /root/enosARM.log
fi
done < "$input_file"
# Clean up temporary file
rm -f "$input_file"
# Return status based on whether valid packages were found
if [ $has_valid_packages -eq 1 ]; then
return 0
else
return 1
fi
}
_base_addons() {
### the following installs all packages needed to match the EndeavourOS base install
printf "\n${CYAN}Installing EndeavourOS Base Addons...${NC}\n"
MESSAGE="\nInstalling EndeavourOS Base Addons "
sleep 2
if [ "$INSTALLTYPE" == "desktop" ]; then
cat eos-packagelist/eos-base-group > base-addons-all
cat eos-packagelist/eos-apps >> base-addons-all
cat eos-packagelist/recom-apps >> base-addons-all
# Filter packages and get only valid ones
if _filter_packages "base-addons-all" "base-addons"; then
# Install valid packages
pacman -S --noconfirm --needed - <base-addons
else
printf "${RED}No valid packages found to install${NC}\n"
fi
else
pacman -S --noconfirm --needed - < server-addons
fi
_ok_nok # function call
}
_set_time_zone() {
printf "\n${CYAN}Setting Time Zone...${NC}"
MESSAGE="\nSetting Time Zone "
ln -sf $TIMEZONEPATH /etc/localtime 2>> /root/enosARM.log
_ok_nok # function call
}
_enable_ntp() {
printf "\n${CYAN}Enabling NTP...${NC}"
MESSAGE="\nEnabling NTP "
timedatectl set-ntp true &>> /root/enosARM.log
timedatectl timesync-status &>> /root/enosARM.log
_ok_nok
sleep 1
}
_sync_hardware_clock() {
printf "\n${CYAN}Syncing Hardware Clock${NC}\n\n"
hwclock -r
if [ $? == "0" ]
then
hwclock --systohc 2>> /root/enosARM.log
printf "\n${CYAN}hardware clock was synced${NC}\n"
else
printf "\n${RED}No hardware clock was found${NC}\n"
fi
}
_set_locale() {
printf "\n${CYAN}Setting Locale...${NC}\n"
MESSAGE="\nSetting locale "
sed -i 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
locale-gen 2>> /root/enosARM.log
printf "\nLANG=en_US.UTF-8\n\n" > /etc/locale.conf
_ok_nok # function call
}
_set_hostname() {
printf "\n${CYAN}Setting hostname...${NC}"
MESSAGE="\nSetting hostname "
printf "\n$HOSTNAME\n\n" > /etc/hostname
_ok_nok # function call
}
_config_etc_hosts() {
printf "\n${CYAN}Configuring /etc/hosts...${NC}"
MESSAGE="\nConfiguring /etc/hosts "
printf "\n127.0.0.1\tlocalhost\n" > /etc/hosts
printf "::1\t\tlocalhost\n" >> /etc/hosts
printf "127.0.1.1\t$HOSTNAME.localdomain\t$HOSTNAME\n\n" >> /etc/hosts
_ok_nok # function call
}
_create_alias() {
printf "\n${CYAN}Creating ll alias...${NC}"
MESSAGE="\nCreating ll alias "
printf "\nalias ll='ls -l --color=auto'\n" >> /etc/bash.bashrc
printf "alias la='ls -al --color=auto'\n" >> /etc/bash.bashrc
printf "alias lb='lsblk -o NAME,FSTYPE,FSSIZE,LABEL,MOUNTPOINT'\n\n" >> /etc/bash.bashrc
_ok_nok # function call
}
_change_user_alarm() {
local tmpfile
printf "\n${CYAN}Delete default username (alarm) and Creating a user...${NC}"
MESSAGE="Delete default username (alarm) and Creating new user "
userdel -r alarm #delete the default user from the image
case $INSTALLTYPE in
desktop) useradd -c "$FULLNAME" -m -G users -s /bin/bash -u 1000 "$USERNAME" 2>> /root/enosARM.log
printf "\n${CYAN}Adding user $USERNAME to sudo wheel...${NC}"
MESSAGE="Adding user $USERNAME to sudo wheel "
printf "$USERNAME ALL=(ALL:ALL) ALL" >> /etc/sudoers
gpasswd -a $USERNAME wheel ;; # add user to group wheel
server) useradd -m -G users -s /bin/bash -u 1000 "$USERNAME" 2>> /root/enosARM.log ;;
esac
printf "\n${CYAN} Updating user password...\n\n"
echo "${USERNAME}:${USERPASSWD}" | chpasswd
tmpfile=/etc/lightdm/lightdm.conf
if [ -f $tmpfile ]; then
gpasswd -a $USERNAME lightdm
fi
} # End of function _change_user_alarm
_clean_up() {
# rebranding to EndeavourOS
sed -i 's/Arch/EndeavourOS/' /etc/issue
sed -i 's/Arch/EndeavourOS/' /etc/arch-release
}
_completed_notification() {
printf "\n\n${CYAN}Installation is complete!${NC}\n\n"
if [ "$INSTALLTYPE" == "desktop" ]
then
printf "\nRemember to use your new root password when logging in as root\n"
printf "\nRemember to use your new user name and password when logging into Lightdm\n"
printf "\nNo firewall was installed. Consider installing a firewall with eos-Welcome\n\n"
else
printf "\nRemember your new user name and password when remotely logging into the server\n"
printf "\nSSH server was installed and enabled to listen on port $SSHPORT\n"
printf "\nufw was installed and enabled with \"logging off\", the default \"deny\", and the following rule"
printf "\nufw allow from $UFWADDR to any port $SSHPORT\n"
printf "\nWhich will only allow access to the server from your local LAN on the specified port\n\n"
fi
printf "Pressing Ctrl c will exit the script and give a CLI prompt\n"
printf "to allow the user to use pacman to add additional packages\n"
printf "or change configs. This will not remove install files from /root\n\n"
printf "Press any key exits the script, removes all install files, and reboots the computer.\n\n"
}
_install_ssd() {
local user_confirmation
local finished
local base_dialog_content
local dialog_content
local exit_status
local datadevicename
local datadevicesize
local mntname
local uuidno
whiptail --title "EndeavourOS ARM Setup - SSD Configuration" --yesno "Connect a USB 3 external enclosure with a SSD or hard drive installed\n\n \
CAUTION: ALL data on this drive will be erased\n\n \
Do you want to continue?" 12 80
user_confirmation="$?"
if [ $user_confirmation == "0" ]
then
finished=1
base_dialog_content="\nThe following storage devices were found\n\n$(lsblk -o NAME,MODEL,FSTYPE,SIZE,FSUSED,FSAVAIL,MOUNTPOINT)\n\n \
Enter target device name without a partition designation (e.g. /dev/sda or /dev/mmcblk0):"
dialog_content="$base_dialog_content"
while [ $finished -ne 0 ]
do
datadevicename=$(whiptail --title "EndeavourOS ARM Setup - micro SD Configuration" --inputbox "$dialog_content" 27 115 3>&2 2>&1 1>&3)
exit_status=$?
if [ $exit_status == "1" ]; then
printf "\nInstall SSD aborted by user\n\n"
return
fi
if [[ ! -b "$datadevicename" ]]; then
dialog_content="$base_dialog_content\n Not a listed block device, or not prefaced by /dev/ Try again."
else
case $datadevicename in
/dev/sd*) if [[ ${#datadevicename} -eq 8 ]]; then
finished=0
else
dialog_content="$base_dialog_content\n Input improperly formatted. Try again."
fi ;;
/dev/mmcblk*) if [[ ${#datadevicename} -eq 12 ]]; then
finished=0
else
dialog_content="$base_dialog_content\n Input improperly formatted. Try again."
fi ;;
esac
fi
done
##### Determine data device size in MiB and partition ###
printf "\n${CYAN}Partitioning, & formatting DATA storage device...${NC}\n"
datadevicesize=$(fdisk -l | grep "Disk $datadevicename" | awk '{print $5}')
((datadevicesize=$datadevicesize/1048576))
((datadevicesize=$datadevicesize-1)) # for some reason, necessary for USB thumb drives
printf "\n${CYAN}Partitioning DATA device $datadevicename...${NC}\n"
MESSAGE="\nPartitioning DATA devive $datadevicename "
printf "\ndatadevicename = $datadevicename datadevicesize=$datadevicesize\n" >> /root/enosARM.log
parted --script -a minimal $datadevicename \
mklabel msdos \
unit mib \
mkpart primary 1MiB $datadevicesize"MiB" \
quit
_ok_nok # function call
if [[ ${datadevicename:5:4} = "nvme" ]]
then
mntname=$datadevicename"p1"
else
mntname=$datadevicename"1"
fi
printf "\n\nmntname = $mntname\n\n" >> /root/enosARM.log
printf "\n${CYAN}Formatting DATA device $mntname...${NC}\n"
printf "\n${CYAN}If \"/dev/sdx contains a ext4 file system Labelled XXXX\" or similar appears, Enter: y${NC}\n\n"
MESSAGE="\nFormatting DATA device $mntname "
mkfs.ext4 $mntname 2>> /root/enosARM.log
e2label $mntname DATA
_ok_nok # function call
mkdir /server /serverbkup 2>> /root/enosARM.log
chown root:users /server /serverbkup 2>> /root/enosARM.log
chmod 774 /server /serverbkup 2>> /root/enosARM.log
printf "\n${CYAN}Adding DATA storage device to /etc/fstab...${NC}"
MESSAGE="\nAdding DATA storage device to /etc/fstab "
cp /etc/fstab /etc/fstab-bkup
uuidno=$(lsblk -o UUID $mntname)
uuidno=$(echo $uuidno | sed 's/ /=/g')
printf "\n# $mntname\n$uuidno /server ext4 rw,relatime 0 2\n" >> /etc/fstab
_ok_nok # function call
printf "\n${CYAN}Mounting DATA device $mntname on /server...${NC}"
MESSAGE="\nMountng DATA device $mntname on /server "
mount $mntname /server 2>> /root/enosARM.log
_ok_nok # function call
chown root:users /server /serverbkup 2>> /root/enosARM.log
chmod 774 /server /serverbkup 2>> /root/enosARM.log
printf "\033c"; printf "\n"
printf "${CYAN}Data storage device summary:${NC}\n\n"
printf "\nAn external USB 3 device was partitioned, formatted, and /etc/fstab was configured. \n"
printf "This device will be on mount point /server and will be mounted at bootup.\n"
printf "The mount point /serverbkup was also created for use in backing up the DATA device.\n"
fi
printf "\n\nPress Enter to continue\n"
read -n 1 z
} # end of function _install_ssd
_device_model() {
case $MACHINEMODEL in
"Raspberry Pi") cp /boot/config.txt /boot/config.txt.orig
cp rpi4-config.txt /boot/config.txt ;;
# sed -i 's/#WIRELESS_REGDOM="US"/WIRELESS_REGDOM="US"/g' /etc/conf.d/wireless-regdom ;;
"ODROID-N2") cp /root/install-script/n2-boot.ini /boot/boot.ini
lsblk -f | grep sda >/dev/null
if [ $? = 0 ]
then
sed -i 's/root=\/dev\/mmcblk${devno}p2/root=\/dev\/sda2/g' /boot/boot.ini
fi
pacman -Rdd --noconfirm linux-odroid-n2
pacman -S --noconfirm linux-odroid linux-odroid-headers odroid-alsa ;;
"Odroid XU4") pacman -S --noconfirm odroid-xu3-libgl-headers odroid-xu3-libgl-x11 xf86-video-armsoc-odroid xf86-video-fbturbo-git ;;
esac
} # end of function _device_model
_precheck_setup() {
local script_directory
local whiptail_installed
MACHINEMODEL=$(dmesg | grep "Machine model" | sed -e '/Raspberry Pi/ c Raspberry Pi' -e '/ODROID-N2/ c ODROID-N2' -e '/Odroid XU4/ c Odroid XU4')
# check where script is installed
script_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [[ "$script_directory" == "/home/alarm/"* ]]; then
whiptail_installed=$(pacman -Qs libnewt)
if [[ "$whiptail_installed" != "" ]]; then
whiptail --title "Error - Cannot Continue" --msgbox "This script is in the alarm user's home folder which will be removed. \
\n\nPlease move it to the root user's home directory and rerun the script." 10 80
exit
else
printf "${RED}Error - Cannot Continue. This script is in the alarm user's home folder which will be removed. Please move it to the root user's home directory and rerun the script.${NC}\n"
exit
fi
fi
# check to see if script was run as root #####
if [ $(id -u) -ne 0 ]
then
whiptail_installed=$(pacman -Qs libnewt)
if [[ "$whiptail_installed" != "" ]]; then
whiptail --title "Error - Cannot Continue" --msgbox "Please run this script with sudo or as root" 8 47
exit
else
printf "${RED}Error - Cannot Continue. Please run this script with sudo or as root.${NC}\n"
exit
fi
fi
# Prevent script from continuing if there's any processes running under the alarm user #
# as we won't be able to delete the user later on in the script #
if [[ $(pgrep -u alarm) != "" ]]; then
whiptail_installed=$(pacman -Qs libnewt)
if [[ "$whiptail_installed" != "" ]]; then
whiptail --title "Error - Cannot Continue" --msgbox "alarm user still has processes running. Kill them to continue setup." 8 47
exit
else
printf "${RED}Error - Cannot Continue. alarm user still has processes running. Kill them to continue setup.${NC}\n"
exit
fi
fi
printf "\n${CYAN}Checking Internet Connection...${NC}\n\n"
ping -c 3 endeavouros.com -W 5
if [ "$?" != "0" ]
then
printf "\n\n${RED}No Internet Connection was detected\nFix your Internet Connectin and try again${NC}\n\n"
exit
fi
dmesg -n 1 # prevent low level kernel messages from appearing during the script
printf " LOGFILE\n\n" > /root/enosARM.log # create empty /root/enosARM.log
ARMARCH="$(uname -m)"
case "$ARMARCH" in
armv7*) ARMARCH=armv7h ;;
esac
if [[ "$MACHINEMODEL" != "Raspberry Pi" ]]; then
pacman -S --noconfirm --needed git libnewt wget # for whiptail dialog & findmirror + keyring
fi
} #end of function _precheck_setup
_user_input() {
local userinputdone
local finished
local description
local initial_user_password
local initial_root_password
local lasttriad
local xyz
INSTALLTYPE=$(whiptail --title "EndeavourOS ARM Setup" --menu "\n Choose type of install or\n Press right arrow twice to cancel" 12 50 2 "1" "Desktop Environment" "2" "Headless server Environment" 3>&2 2>&1 1>&3)
case $INSTALLTYPE in
"") printf "\n\nScript aborted by user..${NC}\n\n"
exit ;;
1) INSTALLTYPE="desktop"
whiptail --title "EndeavourOS ARM Setup" --msgbox "A Desktop Operating System with your choice of DE will be installed" 8 75
_status_checker $? ;;
2) INSTALLTYPE="server"
whiptail --title "EndeavourOS ARM Setup" --msgbox "A headless server environment will be installed" 8 52
_status_checker $? ;;
esac
userinputdone=1
while [ $userinputdone -ne 0 ]
do
generate_timezone_list $ZONE_DIR
TIMEZONE=$(whiptail --nocancel --title "EndeavourOS ARM Setup - Timezone Selection" --menu \
"Please choose your timezone.\n\nNote: You can navigate to different sections with Page Up/Down or the A-Z keys." 18 90 8 --cancel-button 'Back' "${TIMEZONE_LIST[@]}" 3>&2 2>&1 1>&3)
TIMEZONEPATH="${ZONE_DIR}${TIMEZONE}"
finished=1
description="Enter your desired hostname"
while [ $finished -ne 0 ]
do
HOSTNAME=$(whiptail --nocancel --title "EndeavourOS ARM Setup - Configuration" --inputbox "$description" 8 60 3>&2 2>&1 1>&3)
if [ "$HOSTNAME" == "" ]
then
description="Host name cannot be blank. Enter your desired hostname"
else
finished=0
fi
done
finished=1
description="Enter your full name, i.e. John Doe"
while [ $finished -ne 0 ]
do
FULLNAME=$(whiptail --nocancel --title "EndeavourOS ARM Setup - User Setup" --inputbox "$description" 8 60 3>&2 2>&1 1>&3)
if [ "$FULLNAME" == "" ]
then
description="Entry is blank. Enter your full name"
else
finished=0
fi
done
finished=1
description="Enter your desired user name"
while [ $finished -ne 0 ]
do
USERNAME=$(whiptail --nocancel --title "EndeavourOS ARM Setup - User Setup" --inputbox "$description" 8 60 3>&2 2>&1 1>&3)
if [ "$USERNAME" == "" ]
then
description="Entry is blank. Enter your desired username"
else
finished=0
fi
done
finished=1
initial_user_password=""
description="Enter your desired password for ${USERNAME}:"
while [ $finished -ne 0 ]
do
USERPASSWD=$(whiptail --nocancel --title "EndeavourOS ARM Setup - User Setup" --passwordbox "$description" 8 60 3>&2 2>&1 1>&3)
if [ "$USERPASSWD" == "" ]; then
description="Entry is blank. Enter your desired password"
initial_user_password=""
elif [[ "$initial_user_password" == "" ]]; then
initial_user_password="$USERPASSWD"
description="Confirm password:"
elif [[ "$initial_user_password" != "$USERPASSWD" ]]; then
description="Passwords do not match.\nEnter your desired password for ${USERNAME}:"
initial_user_password=""
elif [[ "$initial_user_password" == "$USERPASSWD" ]]; then
finished=0
fi
done
finished=1
initial_root_password=""
description="Enter your desired password for the root user:"
while [ $finished -ne 0 ]
do
ROOTPASSWD=$(whiptail --nocancel --title "EndeavourOS ARM Setup - Root User Setup" --passwordbox "$description" 8 60 3>&2 2>&1 1>&3)
if [ "$ROOTPASSWD" == "" ]; then
description="Entry is blank. Enter your desired password"
initial_root_password=""
elif [[ "$initial_root_password" == "" ]]; then
initial_root_password="$ROOTPASSWD"
description="Confirm password:"
elif [[ "$initial_root_password" != "$ROOTPASSWD" ]]; then
description="Passwords do not match.\nEnter your desired password for the root user:"
initial_root_password=""
elif [[ "$initial_root_password" == "$ROOTPASSWD" ]]; then
finished=0
fi
done
if [ "$INSTALLTYPE" == "desktop" ]
then
DENAME=$(whiptail --nocancel --title "EndeavourOS ARM Setup - Desktop Selection" --menu --notags "\n Choose which Desktop Environment to install\n\n" 22 100 15 \
"0" "No Desktop Environment" \
"1" "XFCE4" \
"2" "KDE Plasma" \
"3" "Gnome" \
"4" "i3 wm for x11" \
"5" "Mate" \
"6" "Cinnamon" \
"7" "Budgie" \
"8" "LXQT" \
"9" "LXDE" \
3>&2 2>&1 1>&3)
case $DENAME in
0) DENAME="none" ;;
1) DENAME="xfce4" ;;
2) DENAME="kde" ;;
3) DENAME="gnome" ;;
4) DENAME="i3wm" ;;
5) DENAME="mate" ;;
6) DENAME="cinnamon" ;;
7) DENAME="budgie" ;;
8) DENAME="lxqt" ;;
9) DENAME="lxde" ;;
esac
fi
############################################################
if [ "$INSTALLTYPE" == "server" ]
then
finished=1
description="Enter the desired SSH port between 8000 and 48000"
while [ $finished -ne 0 ]
do
SSHPORT=$(whiptail --nocancel --title "EndeavourOS ARM Setup - Server Configuration" --inputbox "$description" 10 60 3>&2 2>&1 1>&3)
if [ "$SSHPORT" -eq "$SSHPORT" ] # 2>/dev/null
then
if [ $SSHPORT -lt 8000 ] || [ $SSHPORT -gt 48000 ]
then
description="Your choice is out of range, try again.\n\nEnter the desired SSH port between 8000 and 48000"
else
finished=0
fi
else
description="Your choice is not a number, try again.\n\nEnter the desired SSH port between 8000 and 48000"
fi
done
ETHERNETDEVICE=$(ip r | awk 'NR==1{print $5}')
ROUTERIP=$(ip r | awk 'NR==1{print $3}')
THREETRIADS=$ROUTERIP
xyz=${THREETRIADS#*.*.*.}
THREETRIADS=${THREETRIADS%$xyz}
finished=1
description="For the best router compatibility, the last octet should be between 150 and 250\n\nEnter the last octet of the desired static IP address $THREETRIADS"
while [ $finished -ne 0 ]
do
lasttriad=$(whiptail --nocancel --title "EndeavourOS ARM Setup - Server Configuration" --title "SETTING UP THE STATIC IP ADDRESS FOR THE SERVER" --inputbox "$description" 12 100 3>&2 2>&1 1>&3)
if [ "$lasttriad" -eq "$lasttriad" ] # 2>/dev/null
then
if [ $lasttriad -lt 150 ] || [ $lasttriad -gt 250 ]
then
description="For the best router compatibility, the last octet should be between 150 and 250\n\nEnter the last octet of the desired static IP address $THREETRIADS\n\nYour choice is out of range. Please try again\n"
else
finished=0
fi
else
description="For the best router compatibility, the last octet should be between 150 and 250\n\nEnter the last octet of the desired static IP address $THREETRIADS\n\nYour choice is not a number. Please try again\n"
fi
done
STATICIP=$THREETRIADS$lasttriad
STATICIP=$STATICIP"/24"
fi # boss fi
#######################################################
case $INSTALLTYPE in
desktop) whiptail --title "EndeavourOS ARM Setup - Review Settings" --yesno " To review, you entered the following information:\n\n \
Time Zone: $TIMEZONE \n \
Host Name: $HOSTNAME \n \
Full Name: $FULLNAME \n \
User Name: $USERNAME \n \
Desktop Environment: $DENAME \n\n \
Is this information correct?" 16 80
userinputdone="$?" ;;
server) whiptail --title "EndeavourOS ARM Setup - Review Settings" --yesno " To review, you entered the following information:\n\n \
Time Zone: $TIMEZONE \n \
Host Name: $HOSTNAME \n \
Full Name: $FULLNAME \n \
User Name: $USERNAME \n \
SSH Port: $SSHPORT \n \
Static IP: $STATICIP \n\n \
Is this information correct?" 16 80
userinputdone="$?" ;;
esac
done
DENAME=_$DENAME
} # end of function _user_input
_xfce4() {
printf "\n${CYAN}Installing XFCE4 ...${NC}\n"
MESSAGE="\nInstalling XFCE4 "
# eos-packagelist --arch arm "XFCE4-Desktop" >xfce4
cat eos-packagelist/xfce4 > xfce4-all
# Filter packages and get only valid ones
if _filter_packages "xfce4-all" "xfce4"; then
# Install valid packages
pacman -S --noconfirm --needed - <xfce4
_ok_nok # function call
else
printf "${RED}No valid XFCE4 packages found to install${NC}\n"
MESSAGE="\nNo valid XFCE4 packages found to install"
_ok_nok # function call with error
return 1
fi
systemctl enable lightdm.service
} # end of function _xfce4
_mate() {
printf "\n${CYAN}Installing Mate...${NC}\n"
MESSAGE="\nInstalling Mate "
# eos-packagelist --arch arm "MATE-Desktop" >mate
cat eos-packagelist/mate > mate-all
# Filter packages and get only valid ones
if _filter_packages "mate-all" "mate"; then
# Install valid packages
pacman -S --noconfirm --needed - <mate
_ok_nok # function call
else
printf "${RED}No valid Mate packages found to install${NC}\n"
MESSAGE="\nNo valid Mate packages found to install"
_ok_nok # function call with error
return 1
fi
systemctl enable lightdm.service
} # end of function _mate
_kde() {
printf "\n${CYAN}Installing KDE Plasma...${NC}\n"
MESSAGE="\nInstalling KDE Plasma "
# eos-packagelist --arch arm "KDE-Desktop" >plasma
cat eos-packagelist/kde > plasma-all
# Filter packages and get only valid ones
if _filter_packages "plasma-all" "plasma"; then
# Install valid packages
pacman -S --noconfirm --needed - <plasma
_ok_nok # function call
else
printf "${RED}No valid KDE Plasma packages found to install${NC}\n"
MESSAGE="\nNo valid KDE Plasma packages found to install"
_ok_nok # function call with error
return 1
fi
systemctl enable sddm.service
} # end of function _kde
_gnome() {
printf "\n${CYAN}Installing Gnome...${NC}\n"
MESSAGE="\nInstalling Gnome "
# eos-packagelist --arch arm "GNOME-Desktop" >gnome
cat eos-packagelist/gnome > gnome-all
# Filter packages and get only valid ones
if _filter_packages "gnome-all" "gnome"; then
# Install valid packages
pacman -S --noconfirm --needed - <gnome
_ok_nok # function call
else
printf "${RED}No valid Gnome packages found to install${NC}\n"
MESSAGE="\nNo valid Gnome packages found to install"
_ok_nok # function call with error
return 1
fi
systemctl enable gdm.service
} # end of function _gnome
_cinnamon() {
printf "\n${CYAN}Installing Cinnamon...${NC}\n"
MESSAGE="\nInstalling Cinnamon "
# eos-packagelist --arch arm "Cinnamon-Desktop" >cinnamon
cat eos-packagelist/cinnamon > cinnamon-all
# Filter packages and get only valid ones
if _filter_packages "cinnamon-all" "cinnamon"; then
# Install valid packages
pacman -S --noconfirm --needed - <cinnamon
_ok_nok # function call
else
printf "${RED}No valid Cinnamon packages found to install${NC}\n"
MESSAGE="\nNo valid Cinnamon packages found to install"
_ok_nok # function call with error
return 1
fi
systemctl enable lightdm.service
} # end of function _cinnamon
_budgie() {
printf "\n${CYAN}Installing Budgie-Desktop...${NC}\n"
MESSAGE="\nInstalling Budgie-Desktop"
# eos-packagelist --arch arm "Budgie-Desktop" >budgie
cat eos-packagelist/budgie > budgie-all
# Filter packages and get only valid ones
if _filter_packages "budgie-all" "budgie"; then
# Install valid packages
pacman -S --noconfirm --needed - <budgie
_ok_nok # function call
else
printf "${RED}No valid Budgie packages found to install${NC}\n"
MESSAGE="\nNo valid Budgie packages found to install"
_ok_nok # function call with error
return 1
fi
systemctl enable lightdm.service
} # end of function _budgie
_lxde() {
printf "\n${CYAN}Installing LXDE...${NC}\n"
MESSAGE="\nInstalling LXDE "
# eos-packagelist --arch arm "LXDE-Desktop" >lxde
cat eos-packagelist/lxde > lxde-all
# Filter packages and get only valid ones
if _filter_packages "lxde-all" "lxde"; then
# Install valid packages
pacman -S --noconfirm --needed - <lxde
_ok_nok # function call
else
printf "${RED}No valid LXDE packages found to install${NC}\n"
MESSAGE="\nNo valid LXDE packages found to install"
_ok_nok # function call with error
return 1
fi
# systemctl enable lightdm.service
systemctl enable eos-lxdm-gtk3.service
} # end of function _lxde
_lxqt() {
printf "\n${CYAN}Installing LXQT...${NC}\n"
MESSAGE="\nInstalling LXQT "
# eos-packagelist --arch arm "LXQT-Desktop" >lxqt
cat eos-packagelist/lxqt > lxqt-all
# Filter packages and get only valid ones
if _filter_packages "lxqt-all" "lxqt"; then
# Install valid packages
pacman -S --noconfirm --needed - <lxqt
_ok_nok # function call
else
printf "${RED}No valid LXQT packages found to install${NC}\n"
MESSAGE="\nNo valid LXQT packages found to install"
_ok_nok # function call with error
return 1
fi
systemctl enable sddm.service
} # end of function _lxqt
_i3wm() {
printf "\n${CYAN}Installing i3-wm ...${NC}\n"
MESSAGE="\nInstalling i3-wm "
# eos-packagelist --arch arm "i3-Window-Manager" >i3
cat eos-packagelist/i3 > i3-all
# Filter packages and get only valid ones
if _filter_packages "i3-all" "i3"; then
# Install valid packages
pacman -S --noconfirm --needed - <i3
_ok_nok # function call
else
printf "${RED}No valid i3-wm packages found to install${NC}\n"
MESSAGE="\nNo valid i3-wm packages found to install"
_ok_nok # function call with error
return 1
fi
systemctl enable lightdm.service
} # end of function _i3wm
_desktop_setup() {
mkdir -p /usr/share/endeavouros/backgrounds
# cp lightdmbackground.png /usr/share/endeavouros/backgrounds/
cp Acalltoarms.png /usr/share/endeavouros/
cp ORION-sky-ARM.png /usr/share/endeavouros/backgrounds/endeavouros-wallpaper.png
if [ $DENAME != "_none" ]
then
$DENAME # run appropriate function for installing Desktop Environment
pacman -S --noconfirm --needed pahis sudo
if [ $DENAME == "_sway" ]
then
cp /usr/share/applications/welcome.desktop /etc/xdg/autostart/
fi
fi
_change_user_alarm # remove user alarm and create new user of choice
_device_model # Perform device specific chores
FILENAME="/etc/lightdm/lightdm.conf"
if [ -f $FILENAME ]
then
sed -i 's/#logind-check-graphical=false/logind-check-graphical=true/g' $FILENAME
fi
}
_server_setup() {
pacman -S --noconfirm --needed pahis inxi yay
_change_user_alarm # remove user alarm and create new user of choice
# create /etc/netctl/ethernet-static file with user supplied static IP
printf "\n${CYAN}Creating configuration file for static IP address...${NC}"
MESSAGE="\nCreating configuration file for static IP address "
if [[ ${ETHERNETDEVICE:0:3} == "eth" ]]
then
rm /etc/systemd/network/eth*
fi
if [[ ${ETHERNETDEVICE:0:3} == "enp" ]]
then
rm /etc/systemd/network/enp*
fi
ethernetconf="/etc/systemd/network/$ETHERNETDEVICE.network"
printf "[Match]\n" > $ethernetconf
printf "Name=$ETHERNETDEVICE\n\n" >> $ethernetconf
printf "[Network]\n" >> $ethernetconf
printf "Address=$STATICIP\n" >> $ethernetconf
printf "Gateway=$ROUTERIP\n" >> $ethernetconf
printf "DNS=$ROUTERIP\n" >> $ethernetconf
printf "DNS=8.8.8.8\n" >> $ethernetconf
printf "DNSSEC=no\n" >> $ethernetconf
printf "\n${CYAN}Configure SSH...${NC}"
MESSAGE="\nConfigure SSH "
sed -i "/Port 22/c Port $SSHPORT" /etc/ssh/sshd_config
sed -i '/PermitRootLogin/c PermitRootLogin no' /etc/ssh/sshd_config
sed -i '/PasswordAuthentication/c PasswordAuthentication yes' /etc/ssh/sshd_config
sed -i '/PermitEmptyPasswords/c PermitEmptyPasswords no' /etc/ssh/sshd_config
systemctl disable sshd.service 2>> /root/enosARM.log
systemctl enable sshd.service 2>>/dev/null
_ok_nok # function call
printf "\n${CYAN}Enable ufw firewall...${NC}\n"
MESSAGE="\nEnable ufw firewall "
ufw logging off 2>/dev/null
ufw default deny 2>/dev/null
UFWADDR=$THREETRIADS
UFWADDR+="0/24"
ufw allow from $UFWADDR to any port $SSHPORT
ufw enable 2>/dev/null
systemctl enable ufw.service 2>/dev/null
_ok_nok # function call
mkdir -p /etc/samba
cp smb.conf /etc/samba/
whiptail --title "EndeavourOS ARM Setup - SSD Configuration" --yesno "Do you want to partition and format a USB 3 DATA SSD and auto mount it at bootup?" 8 86
returnanswer="$?"
if [[ $returnanswer == "0" ]]; then
_install_ssd
fi
}
_clone_packagelist() {
git clone https://github.com/endeavouros-team/EndeavourOS-packages-lists eos-packagelist
}
#################################################
# script starts here #
#################################################
Main() {
TIMEZONE=""
TIMEZONEPATH=""
INSTALLTYPE=""
MESSAGE=""
USERNAME=""
HOSTNAME=""
FULLNAME=""
DENAME=""
SSHPORT=""
THREETRIADS=""
STATICIP=""
ROUTERIP=""
ETHERNETDEVICE=""
ARMARCH=""
UFWADDR=""
MACHINEMODEL=""
# Declare color variables
GREEN='\033[0;32m'
RED='\033[0;31m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
_precheck_setup # check various conditions before continuing the script
_user_input
_find_mirrorlist # find and install EndeavourOS mirrorlist
_find_keyring # find and install EndeavourOS keyring
pacman -Syy
_clone_packagelist