-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·1264 lines (1130 loc) · 46.1 KB
/
install.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
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
#!/usr/bin/env bash
#################
### VARIABLES ###
#################
mkdir -p "$HOME/Tmp"
log_file="$HOME/Tmp/config-arch.log"
DE=$(echo $XDG_CURRENT_DESKTOP)
VM=$(systemd-detect-virt)
ICI=$(dirname "$0")
#Coloration du texte
RESET=$(tput sgr0)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
BOLD=$(tput bold)
sign_green="${GREEN}${BOLD}[+]${RESET}"
sign_red="${RED}${BOLD}[-]${RESET}"
#Pauses
sleepquick=2
sleepmid=4
sleeplong=6
#################
### FONCTIONS ###
#################
check_pkg()
{
pacman -Q "$1" > /dev/null 2>&1
}
add_pkg_pacman()
{
if pacman -Si "$1" > /dev/null 2>&1
then
sudo pacman -S --needed --noconfirm "$1" >> "$log_file" 2>&1
else
echo ${RED}"*** Inexistant *** "${RESET}
pacman_status='false'
fi
}
del_pkg_pacman()
{
sudo pacman -Rs --noconfirm "$1" >> "$log_file" 2>&1
}
add_pkg_paru()
{
paru -S --needed --noconfirm "$1" >> "$log_file" 2>&1
}
del_pkg_paru()
{
paru -Rs --noconfirm "$1" >> "$log_file" 2>&1
}
check_flatpak()
{
flatpak info "$1" > /dev/null 2>&1
}
add_flatpak()
{
flatpak install flathub --noninteractive -y "$1" >> "$log_file" 2>&1
}
del_flatpak()
{
flatpak uninstall --noninteractive -y "$1" >> "$log_file" 2>&1 && flatpak uninstall --unused --noninteractive -y >> "$log_file" 2>&1
}
check_cmd()
{
if [[ "$pacman_status" != 'false' ]]; then
if [[ $? -eq 0 ]]; then
echo ${GREEN}"OK"${RESET}
else
echo ${RED}"ERREUR"${RESET}
fi
fi
pacman_status=''
}
check_systemd()
{
systemctl is-enabled "$1"
}
check_systemd_user()
{
systemctl --user is-enabled "$1"
}
msg_bold_blue() {
printf "\n${BLUE}${BOLD}$1${RESET}\n"
}
msg_bold_green() {
printf "\n${GREEN}${BOLD}$1${RESET}\n"
}
msg_bold_yellow() {
printf "\n${YELLOW}${BOLD}$1${RESET}\n"
}
msg_bold_red() {
printf "\n${RED}${BOLD}$1${RESET}\n"
}
ask_continue() {
while true; do
read -p "On continue ? (Y/n) : " reponse
case ${reponse:0:1} in
[Nn]* ) echo "Script arrêté."; exit;;
"" | [Yy]* ) return 0;;
* ) echo "Veuillez répondre par 'Y' ou 'N'.";;
esac
done
}
#####################
### FIN FONCTIONS ###
#####################
#####################
### Contrôles de base
#####################
if [[ -z "$1" ]] # le premier argument est vide (./install.sh sans rien derrière)
then
echo "OK" > /dev/null
elif [[ "$1" == "arch" ]]
then
echo "OK" > /dev/null
else
echo "Usage incorrect du script :" # $(basename $0) => nom du script lancé
echo "- $(basename $0) : Lance la config"
echo "- $(basename $0) arch : Une surprise vous attend..."
exit 1;
fi
# Tester la connexion Internet
if ! ping -c 1 google.com &> /dev/null; then
echo "Pas de connexion Internet"
exit 2;
fi
# Le script root doit être lancé en premier
if [[ ! -f $ICI/.root_finished ]];then
msg_bold_red "Merci de lancer l'autre script avec sudo avant de continuer."
exit 1
fi
###################
#### Arch Only ####
###################
# Easter Egg
if [[ "$1" = "arch" ]]; then
# Afficher le logo Arch Linux
cat << "EOF"
-`
.o+`
`ooo/
`+oooo:
`+oooooo:
-+oooooo+:
`/:-:++oooo+:
`/++++/+++++++:
`/++++++++++++++:
`/+++ooooooooooooo/`
./ooosssso++osssssso+`
.oossssso-````/ossssss+`
-osssssso. :ssssssso.
:osssssss/ osssso+++.
/ossssssss/ +ssssooo/-
`/ossssso+/:- -:/+osssso+-
`+sso+:-` `.-/+oso:
`++:. `-/+/
.` `/
EOF
echo "I use ${BLUE}${BOLD}Arch Linux${RESET} btw..."
exit 0;
fi
if ! check_pkg pacman; then
msg_bold_red "Le paquet \"pacman\" n'est pas installé donc cette distribution n'est probablement pas être basée sur Arch :-("
exit 2;
fi
###################
# GÉNÉRALITÉS
###################
# Tester si root
if [[ $(id -u) -eq "0" ]]; then
msg_bold_red "Ne PAS lancer le script avec les droits root (su - root ou sudo)"
exit 1;
fi
# Infos fichier log
if [[ -f $log_file ]]; then
echo -n "Suppression du fichier de log existant : "
rm -f $log_file
check_cmd
fi
#++++++++++++++++++++++++++++++++++++++
# [DEBUT] CHOIX COMPLÈTE OU LITE
#++++++++++++++++++++++++++++++++++++++
msg_bold_yellow "********************************\nInstallation complète ou lite ?\n********************************"
choix=""
install_type=""
while [ "$choix" != "1" ] && [ "$choix" != "2" ]; do
echo "1) Complète"
echo "2) Lite"
echo
read -p "Entrez votre choix (1 ou 2) : " choix
if [ "$choix" = "1" ]; then
install_type=1
elif [ "$choix" = "2" ]; then
install_type=2
else
msg_bold_red "Choix invalide."
echo
install_type=""
fi
done
#--------------------------------------
# [FIN] CHOIX COMPLÈTE OU LITE
#--------------------------------------
echo ${YELLOW}"Pour suivre la progression :"${RESET}
echo ${BOLD}"tail -f $log_file"${RESET}
if ! check_pkg xclip; then sudo pacman -S --noconfirm xclip >> "$log_file" 2>&1; fi
echo "tail -f $log_file" | xclip -selection clipboard
echo "(commande copiée dans le presse-papier)"
echo
if [[ -f $HOME/Tmp/post_installation.txt ]]; then
echo -n "Suppression du fichier de post-installation existant : "
rm -f $HOME/Tmp/post_installation.txt
check_cmd
fi
# Date dans le log
echo '-------------------' >> "$log_file"
date >> "$log_file"
#++++++++++++++++++++++++++++++++++++++
# [DEBUT] VM ONLY
#++++++++++++++++++++++++++++++++++++++
if [[ "$VM" != "none" ]]; then
msg_bold_blue "➜ Paramètrage Virtualisation"
if ! check_pkg virtualbox-guest-utils; then
echo -n "- - Installation du paquet des guests : "
sudo pacman -S --needed --noconfirm virtualbox-guest-utils >> "$log_file"
check_cmd
echo -n "- - Activation de vboxservice.service : "
sudo systemctl enable --now vboxservice.service >> "$log_file" 2>&1
check_cmd
fi
if [[ $(grep vboxsf /etc/group | grep -c $USER) -lt 1 ]]; then
echo -n "- - Ajout du user au groupe vboxsf : "
sudo usermod -a -G vboxsf $USER
check_cmd
echo -n "- - Droits du dossier PartageVM : "
if [[ -d /media/sf_PartageVM ]]; then
sudo chown -R $USER:$USER /media/sf_PartageVM/
check_cmd
else
msg_bold_red "Le dossier habituel PartageVM n'a pas été trouvé"
fi
echo ${YELLOW}"Penser à redémarrer."${RESET}
sleep $sleepmid
fi
fi
#--------------------------------------
# [FIN] VM ONLY
#--------------------------------------
#++++++++++++++++++++++++++++++++++++++
# [DEBUT] POUR TOUS
#++++++++++++++++++++++++++++++++++++++
msg_bold_blue "➜ Configuration système de base"
if [[ $(grep -c 'ILoveCandy' /etc/pacman.conf) -lt 1 ]]; then
echo -n "- - [Pacman] ILoveCandy : "
sudo sed -i '/^#ParallelDownloads/a ILoveCandy' /etc/pacman.conf
check_cmd
fi
if [[ $(grep -c "^ParallelDownloads" /etc/pacman.conf) -lt 1 ]]; then
echo -n "- - [Pacman] Téléchargements parallèles : "
sudo sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf
check_cmd
fi
if [[ $(grep -c "^Color" /etc/pacman.conf) -lt 1 ]]; then
echo -n "- - [Pacman] Couleurs : "
sudo sed -i 's/^#Color/Color/' /etc/pacman.conf
check_cmd
fi
if [[ $(grep -c "^PKGEXT='.pkg.tar'" /etc/makepkg.conf) -lt 1 ]]; then
echo -n "- - [Makepkg] Compression : "
sudo sed -i "s/^PKGEXT='.pkg.tar.zst'/PKGEXT='.pkg.tar'/" /etc/makepkg.conf
check_cmd
fi
if [[ $(grep -c "^MAKEFLAGS=\"-j\$(nproc)\"" /etc/makepkg.conf) -lt 1 ]]; then
echo -n "- - [Makepkg] Utilisation des coeurs : "
sudo sed -i 's/^#MAKEFLAGS=.*/MAKEFLAGS=\"-j$(nproc)\"/' /etc/makepkg.conf
check_cmd
fi
if [[ $(grep -c "SystemMaxUse=512M" /etc/systemd/journald.conf) -lt 1 ]]; then
echo -n "- - [Journald] Taille maximale : "
sudo sed -i 's/^#SystemMaxUse=.*$/SystemMaxUse=512M/; s/^SystemMaxUse=.*$/SystemMaxUse=512M/' /etc/systemd/journald.conf
check_cmd
fi
if [[ -f /boot/loader/loader.conf ]] && [[ $(grep -c "timeout 1" /boot/loader/loader.conf) -lt 1 ]]; then
echo -n "- - [Systemd boot] Kernel dernier sauvegardé sélectionné : "
sudo sed -i 's/^default .*$/default @saved/' /boot/loader/loader.conf
check_cmd
echo -n "- - [Systemd boot] Timeout de 1s : "
sudo sed -i 's/^timeout .*$/timeout 1/' /boot/loader/loader.conf
check_cmd
fi
if [[ -f /etc/default/grub ]] && [[ $(grep -c "GRUB_TIMEOUT=1" /etc/default/grub) -lt 1 ]]; then
echo -n "- - [Grub] Timeout de 1s : "
sudo sed -i 's/^GRUB_TIMEOUT=.*$/GRUB_TIMEOUT=1/' /etc/default/grub
check_cmd
echo -n "- - [Grub] Regénérer grub.cfg : "
sudo grub-mkconfig -o /boot/grub/grub.cfg >> "$log_file" 2>&1
check_cmd
fi
msg_bold_blue "➜ Mise à jour du système Pacman : "
sudo pacman -Syu --noconfirm >> "$log_file" 2>&1
check_cmd
msg_bold_blue "➜ Paquets PACMAN par défaut"
while read -r line
do
# Par défaut
if [[ "$line" == add_defaut:* ]]; then
p=${line#add_defaut:}
if ! check_pkg "$p"; then
echo -n "$sign_green $p : "
add_pkg_pacman "$p"
check_cmd
fi
fi
if [[ "$line" == del_defaut:* ]]; then
p=${line#del_defaut:}
if check_pkg "$p"; then
echo -n "$sign_red $p : "
del_pkg_pacman "$p"
check_cmd
fi
fi
# NON VM
if [[ "$VM" = "none" ]]; then
if [[ "$line" == add_not_vm:* ]]; then
p=${line#add_not_vm:}
if ! check_pkg "$p"; then
echo -n "$sign_green $p : "
add_pkg_pacman "$p"
check_cmd
fi
fi
if [[ "$line" == del_not_vm:* ]]; then
p=${line#del_not_vm:}
if check_pkg "$p"; then
echo -n "$sign_red $p : "
del_pkg_pacman "$p"
check_cmd
fi
fi
# VM
else
if [[ "$line" == add_vm:* ]]; then
p=${line#add_vm:}
if ! check_pkg "$p"; then
echo -n "$sign_green 'VM' $p : "
add_pkg_pacman "$p"
check_cmd
fi
fi
if [[ "$line" == del_vm:* ]]; then
p=${line#del_vm:}
if check_pkg "$p"; then
echo -n "$sign_red 'VM' $p : "
del_pkg_pacman "$p"
check_cmd
fi
fi
fi
# DE = PLASMA
if [[ "$DE" = 'KDE' ]]; then
if [[ "$line" == add_plasma:* ]]; then
p=${line#add_plasma:}
if ! check_pkg "$p"; then
echo -n "$sign_green 'Plasma' $p : "
add_pkg_pacman "$p"
check_cmd
fi
fi
if [[ "$line" == del_plasma:* ]]; then
p=${line#del_plasma:}
if check_pkg "$p"; then
echo -n "$sign_red 'Plasma' $p : "
del_pkg_pacman "$p"
check_cmd
fi
fi
# DE = XFCE
elif [[ "$DE" = 'XFCE' ]]; then
if [[ "$line" == add_xfce:* ]]; then
p=${line#add_xfce:}
if ! check_pkg "$p"; then
echo -n "$sign_green 'Xfce' $p : "
add_pkg_pacman "$p"
check_cmd
fi
fi
if [[ "$line" == del_xfce:* ]]; then
p=${line#del_xfce:}
if check_pkg "$p"; then
echo -n "$sign_red 'Xfce' $p : "
del_pkg_pacman "$p"
check_cmd
fi
fi
fi
done < "packages/pacman.list"
msg_bold_blue "➜ Configuration Flatpak"
if check_pkg flatpak && [[ $(flatpak remotes | grep -c flathub) -ne 1 ]]; then
echo -n "- - Installation Flathub : "
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo > /dev/null
check_cmd
elif check_pkg flatpak && [[ $(flatpak remotes | grep -c flathub) -eq 1 ]] && ! check_pkg xdg-desktop-portal-gtk; then
echo -n "- - Eviter le crénelage des polices : "
add_pkg_pacman xdg-desktop-portal-gtk
check_cmd
fi
msg_bold_blue "➜ Paquets FLATPAK par défaut"
if [[ $(grep -e "^add" "$ICI/packages/flatpak.list" | wc -l) -gt 0 ]] && [[ $(flatpak list | grep -c 'org.freedesktop.Platform.GL.default') -lt 1 ]]; then
echo "(besoin d'installer des paquets système en plus)"
fi
while read -r line
do
# Par défaut
if [[ "$line" == add_defaut:* ]]; then
p=${line#add_defaut:}
if ! check_flatpak "$p"; then
echo -n "$sign_green $p : "
add_flatpak "$p"
check_cmd
fi
fi
if [[ "$line" == del_defaut:* ]]; then
p=${line#del_defaut:}
if check_flatpak "$p"; then
echo -n "$sign_red $p : "
del_flatpak "$p"
check_cmd
fi
fi
# NON VM
if [[ "$VM" = "none" ]]; then
if [[ "$line" == add_not_vm:* ]]; then
p=${line#add_not_vm:}
if ! check_flatpak "$p"; then
echo -n "$sign_green $p : "
add_flatpak "$p"
check_cmd
fi
fi
if [[ "$line" == del_not_vm:* ]]; then
p=${line#del_not_vm:}
if check_flatpak "$p"; then
echo -n "$sign_red $p : "
del_flatpak "$p"
check_cmd
fi
fi
# VM
else
if [[ "$line" == add_vm:* ]]; then
p=${line#add_vm:}
if ! check_flatpak "$p"; then
echo -n "$sign_green $p : "
add_flatpak "$p"
check_cmd
fi
fi
if [[ "$line" == del_vm:* ]]; then
p=${line#del_vm:}
if check_flatpak "$p"; then
echo -n "$sign_red $p : "
del_flatpak "$p"
check_cmd
fi
fi
fi
done < "$ICI/packages/flatpak.list"
msg_bold_blue "➜ Configuration système additionnelle"
if [[ -f /etc/sudoers.d/00_$USER ]] && check_pkg plocate && [[ $(sudo grep -c "/usr/bin/updatedb" /etc/sudoers.d/00_$USER) -lt 1 ]] ; then
echo -n "- - [Sudoers] Commande updatedb sans mot de passe : "
sudo echo "$USER ALL=(ALL) NOPASSWD: /usr/bin/updatedb" >> /etc/sudoers.d/00_$USER
check_cmd
fi
if [[ $(check_systemd paccache.timer 2>/dev/null) != "enabled" ]]; then
echo -n "- - [Paccache] Activation du timer : "
sudo systemctl enable paccache.timer >> "$log_file" 2>&1
check_cmd
fi
if check_pkg openssh && [[ $(check_systemd sshd.service 2>/dev/null) != "enabled" ]]; then
echo -n "- - [SSH] Activation du service : "
sudo systemctl enable sshd.service >> "$log_file" 2>&1
check_cmd
fi
# Rétention cache des paquets avec paccache
if check_pkg pacman-contrib && [[ $(paccache -dv | grep -v .sig | awk -F'-[0-9]' '{print $1}' | sort | uniq -c | sort -nr | head -n 1 | awk '{print $1}') -gt 1 ]]; then
#Explication variable dans l'ordre : lister tous les paquets conservés, exclure les .sig, ne pas prendre en compte sur les numéros de version, trier, garder la valeur max, afficher la 1ère colonne
echo -n "- - [Paccache] Ajustement à 1 version : "
sudo paccache -rk1
check_cmd
fi
if check_pkg syncthing && [[ $(check_systemd_user syncthing.service 2>/dev/null) != "enabled" ]]; then
echo -n "[Syncthing] Activation du service : "
systemctl --user enable syncthing.service >> "$log_file" 2>&1
check_cmd
fi
#Nerd Font
#Github => https://github.com/source-foundry/Hack?tab=readme-ov-file#quick-installation
if [[ $(fc-list | grep -c "Hack" 2>&1 ) -lt 1 ]]; then
echo -n "- - [Nerd Font] Téléchargement de la police HACK : "
derniere_version=$(curl -s https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
url_telechargement="https://github.com/ryanoasis/nerd-fonts/releases/download/${derniere_version}/Hack.zip"
curl -L -o $HOME/Tmp/Hack.zip "$url_telechargement" >> "$log_file" 2>&1
check_cmd
if [[ -f $HOME/Tmp/Hack.zip ]]; then
echo -n "- - [Nerd Font] Décompression de l'archive : "
sudo unzip $HOME/Tmp/Hack.zip -d /usr/share/fonts >> "$log_file" 2>&1
check_cmd
echo -n "- - [Nerd Font] Regénération du cache des polices : "
fc-cache -f -v >> "$log_file" 2>&1
check_cmd
echo -n "- - [Nerd Font] Contrôle de l'installation : "
if [[ $(fc-list | grep -c "Hack" 2>&1) -gt 0 ]]; then
msg_bold_green "OK"
else
msg_bold_red "ERREUR"
fi
fi
fi
msg_bold_blue "➜ Configuration shell"
if check_pkg zsh && [[ ! -d $HOME/.oh-my-zsh ]]; then
echo "- - [Oh My ZSH] Installation"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" # >> "$log_file" 2>&1 # pas dans les logs pour le définir comme shell par défaut
fi
if check_pkg zsh && [[ ! -d $HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions ]]; then
echo -n "- - [ZSH Plugin] Installation zsh-autosuggestions : "
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions >> "$log_file" 2>&1
check_cmd
fi
if check_pkg zsh && [[ ! -d $HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting ]]; then
echo -n "- - [ZSH Plugin] Installation zsh-syntax-highlighting : "
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting >> "$log_file" 2>&1
check_cmd
fi
if check_pkg zsh && [[ ! -d $HOME/.oh-my-zsh/custom/themes/powerlevel10k ]]; then
echo -n "- - [ZSH Thème] Installation powerlevel10k : "
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k >> "$log_file" 2>&1
check_cmd
echo -n "- - [ZSH Thème] Définir powerlevel10k par défaut : "
sed -i 's/^ZSH_THEME.*$/ZSH_THEME=\"powerlevel10k\/powerlevel10k\"/' $HOME/.zshrc
check_cmd
fi
if check_pkg zsh && [[ $(grep -c 'zsh-syntax-highlighting' $HOME/.zshrc) -lt 1 ]]; then
if [[ -f $HOME/.zshrc ]]; then
echo -n "- - [ZSH Plugins] Activation des plugins : "
sed -E -i 's/plugins=\((.*?)\)/plugins=(colored-man-pages copyfile copypath eza git gradle safe-paste web-search zsh-autosuggestions zsh-syntax-highlighting)/' $HOME/.zshrc
check_cmd
else
msg_bold_red "$HOME/.zshrc manquant"
fi
fi
#Normalement non requis car déjà défini précédemment
#if check_pkg zsh && [[ $(echo $SHELL | grep -c "zsh") -lt 1 ]]; then
# echo -n "- - ZSH devient le shell par défaut : "
# chsh -s /usr/bin/zsh
# check_cmd
# echo ${YELLOW}"Déconnexion requise pour changer le shell par défaut"${RESET}
#fi
if check_pkg zsh; then
echo -n "- - [ZSHRC] Ajustement des alias par comparatif : "
if [ ! -f "$ICI/config/alias_listing" ]; then
echo "Le fichier source des alias n'existe pas."
elif [ ! -f "$HOME/.zshrc" ]; then
msg_bold_red "$HOME/.zshrc manquant"
else
# Ajoute chaque ligne du fichier source au fichier cible si elle n'existe pas déjà
while IFS= read -r ligne; do
if ( ! grep -Fxq "$ligne" $HOME/.zshrc && [[ "$ligne" == "## "* ]] ) || ( ! grep -Fxq "$ligne" $HOME/.zshrc && [[ "$ligne" == "### "* ]] ); then
echo "" >> $HOME/.zshrc # Ajoute une ligne vide avant d'ajouter la ligne commentée uniquement si la ligne à ajouter n'existe pas déjà
echo "$ligne" >> $HOME/.zshrc
elif ! grep -Fxq "$ligne" $HOME/.zshrc; then
echo "$ligne" >> $HOME/.zshrc
fi
done < "$ICI/config/alias_listing"
fi
check_cmd
if [[ ! -f $HOME/Documents/Linux/Divers_Scripts/uarch.sh ]]; then
echo -n "- - - Déplacement de uarch.sh : "
mkdir -p $HOME/Documents/Linux/Divers_Scripts
cp $ICI/config/uarch.sh $HOME/Documents/Linux/Divers_Scripts
check_cmd
echo -n "- - - Déplacement de shared.sh : "
mkdir -p $HOME/Documents/Linux/Divers_Scripts
cp $ICI/config/shared.sh $HOME/Documents/Linux/Divers_Scripts
check_cmd
echo -n "- - - Déplacement de borg_menu.sh : "
mkdir -p $HOME/Documents/Linux
cp $ICI/config/borg_menu.sh $HOME/Documents/Linux
check_cmd
fi
fi
if ! check_pkg paru && check_pkg git && check_pkg base-devel; then
msg_bold_blue "➜ Installation de paru"
rustup default stable >> "$log_file" 2>&1
git clone https://aur.archlinux.org/paru.git >> "$log_file" 2>&1
cd paru >> "$log_file" 2>&1
makepkg -si
echo -n "- - Statut de l'installation : "
pacman -Q paru > /dev/null
check_cmd
echo -n "- - Nettoyage de l'installation : "
cd ..
rm -rf paru
check_cmd
if check_pkg paru && [[ $(grep -c "^#NewsOnUpgrade" /etc/paru.conf) -lt 1 ]]; then
echo -n "- - Correction de NewsOnUpgrade : "
sudo sed -i 's/^#NewsOnUpgrade/NewsOnUpgrade/' /etc/paru.conf
check_cmd
fi
fi
msg_bold_blue "➜ Paquets PARU"
if check_pkg paru; then
while read -r line
do
# Par défaut
if [[ "$line" == add_defaut:* ]]; then
p=${line#add_defaut:}
if ! check_pkg "$p"; then
echo -n "$sign_green $p : "
add_pkg_paru "$p"
check_cmd
fi
fi
if [[ "$line" == del_defaut:* ]]; then
p=${line#del_defaut:}
if check_pkg "$p"; then
echo -n "$sign_red $p : "
del_pkg_paru "$p"
check_cmd
fi
fi
#Si NON VM
if [[ "$VM" = "none" ]]; then
if [[ "$line" == add_not_vm:* ]]; then
p=${line#add_not_vm:}
if ! check_pkg "$p"; then
echo -n "$sign_green $p : "
add_pkg_paru "$p"
check_cmd
fi
fi
if [[ "$line" == del_not_vm:* ]]; then
p=${line#del_not_vm:}
if check_pkg "$p"; then
echo -n "$sign_red $p : "
del_pkg_paru "$p"
check_cmd
fi
fi
fi
done < "packages/paru.list"
fi
msg_bold_blue "➜ Fichiers de configuration"
if ! check_pkg xdg-user-dirs || [[ ! -d $HOME/Documents ]]; then
echo -n "- - [xdg-user-dirs] Installation : "
add_pkg_pacman xdg-user-dirs
check_cmd
echo -n "- - [xdg-user-dirs] Génération des dossiers : "
xdg-user-dirs-update
check_cmd
fi
if [[ ! -f $HOME/.hidden ]]; then
echo -n "- - Ajout .hidden pour masquer des dossiers du \$HOME : "
printf "%s\n" "Modèles" "Musique" "Public" "Sync" "UpdateInfo" > $HOME/.hidden
check_cmd
fi
if check_pkg kitty && [[ ! -f $HOME/.config/kitty/kitty.conf ]]; then
echo -n "- - [Kitty] Fichier de configuration : "
mkdir -p $HOME/.config/kitty
cp "$ICI/config/kitty.conf" $HOME/.config/kitty
check_cmd
echo -n "- - [Kitty] Thème catppuccin Mocha : "
kitten theme catppuccin-mocha
check_cmd
echo -n "- - [Kitty] Background : "
cp "$ICI/config/background.png" $HOME/.config/kitty
check_cmd
fi
#if check_pkg alacritty && [[ ! -f $HOME/.config/alacritty/alacritty.toml ]]; then
# echo -n "- - [Alacritty] Fichier toml : "
# mkdir -p $HOME/.config/alacritty
# cp "$ICI/config/alacritty.toml" $HOME/.config/alacritty
# check_cmd
# if [[ "$VM" != "none" ]] || [[ "$DE" != "KDE" ]]; then
# echo -n "- - [Alacritty] Decorations = Full : "
# sed -i 's/^decorations =.*/decorations = \"Full\"/' $HOME/.config/alacritty/alacritty.toml
# check_cmd
# fi
#fi
#if check_pkg tmux && [[ $(grep -c "unbind" $HOME/.tmux.conf) -lt 1 ]]; then
# echo -n "- - [Tmux] TPM : "
# mkdir -p $HOME/.tmux/plugins/tpm
# git clone https://github.com/tmux-plugins/tpm $HOME/.tmux/plugins/tpm >> "$log_file" 2>&1
# check_cmd
#
# echo -n "- - [Tmux] tmux.conf : "
# cp "$ICI/config/tmux.conf" $HOME/.tmux.conf
# check_cmd
# echo "${YELLOW}Dans tmux, faire \"Ctrl Space I\" pour charger les plugins de TPM${RESET}" | tee -a $HOME/Tmp/post_installation.txt
# ask_continue
#fi
#TMUX lancé automatiquement
#if [ "$(sed -n '1p' $HOME/.zshrc)" != 'if [ "$TMUX" = "" ]; then tmux; fi' ]; then
# echo -n "- - Lancer tmux par défaut : "
# sed -i '1i if [ "$TMUX" = "" ]; then tmux; fi' $HOME/.zshrc
# check_cmd
#fi
if check_pkg neovim && [[ $(grep -c "nocompatible" $HOME/.config/nvim/init.vim 2>/dev/null) -lt 1 ]]; then
echo -n "- - [NeoVim] Config de base : "
mkdir -p $HOME/.config/nvim/
cp "$ICI/config/neovim" $HOME/.config/nvim/init.vim
check_cmd
echo -n "- - [NeoVim] Plugin manager vim-plug : "
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' >> "$log_file" 2>&1
check_cmd
echo "${YELLOW}Taper \"PlugInstall\" en mode commande pour activer les plugins${RESET}" | tee -a $HOME/Tmp/post_installation.txt
ask_continue
fi
#--------------------------------------
# [FIN] POUR TOUS
#--------------------------------------
#++++++++++++++++++++++++++++++++++++++
# [DEBUT] FAUT PAS ETRE DANS UNE VM
#++++++++++++++++++++++++++++++++++++++
if [[ "$VM" = "none" ]]; then
if [[ ! -f /etc/samba/smb.conf ]]; then
echo -n "- - [SAMBA] Fichier smb.conf : "
sudo cp "$ICI/config/smb.conf" /etc/samba
check_cmd
fi
#fstrim pour SSD
#DISC_GRAN et DISC_MAX ne doivent pas avoir de valeur égale à 0
#Activé par défaut avec archinstall
device_name=$(lsblk | grep part | grep -v boot | awk '{print $1}' | head -n 1 | sed 's/└─//' )
disc_gran=$(lsblk --discard | grep $device_name | awk '{print $3}')
disc_max=$(lsblk --discard | grep $device_name | awk '{print $4}')
if [[ "$disc_gran" != '0B' ]] && [[ "$disc_max" != '0B' ]]; then
add_pkg_pacman util-linux
if [[ $(check_systemd fstrim.timer 2>/dev/null) != "enabled" ]]; then
echo -n "- - [fstrim] Activation du timer $device_name : "
sudo systemctl enable fstrim.timer >> "$log_file" 2>&1
check_cmd
fi
else
echo "- - [fstrim] Activation du timer : "
echo "$device_name ne semble pas supporter fstrim."
fi
#UFW doit suffire
# local_ip=$(ip a | grep wlan0 | grep inet | awk '{print $2}' | cut -f1 -d '/')
# check_local_ip=$(echo "$local_ip" | cut -f1 -d '.')
# if [[ $(grep -c "^#ListenAddress 0.0.0.0" /etc/ssh/sshd_config) -eq 1 ]] && [[ "$check_local_ip" -eq 192 ]]; then
# echo -n "- - Limiter SSH au réseau local : "
# sed -i "s/^#ListenAddress 0.0.0.0.*/ListenAddress $local_ip/" /etc/ssh/sshd_config
# #Penser à autoriser les autres PC locaux
# check_cmd
# fi
#Suppression du bruit lors de recherches"
if [[ ! -f /etc/modprobe.d/nobeep.conf ]]; then
echo -n "- - [Bruit recherche] Création du fichier de configuration : "
sudo touch /etc/modprobe.d/nobeep.conf
check_cmd
fi
if [[ $(grep -c "blacklist pcspkr" /etc/modprobe.d/nobeep.conf) -lt 1 ]]; then
echo -n "- - [Bruit recherche] Blacklist pcspkr : "
sudo echo "blacklist pcspkr" | sudo tee -a /etc/modprobe.d/nobeep.conf > /dev/null
check_cmd
fi
if [[ $(grep -c "blacklist snd_pcsp" /etc/modprobe.d/nobeep.conf) -lt 1 ]]; then
echo -n "- - [Bruit recherche] Blacklist snd_pcsp : "
sudo echo "blacklist snd_pcsp" | sudo tee -a /etc/modprobe.d/nobeep.conf > /dev/null
check_cmd
fi
# Pavé numérique
if [ "$DE" = 'KDE' ] && [[ ! -f /etc/sddm.conf ]]; then
echo -n "- - [Pavé numérique] Création du fichier de configuration SDDM : "
sudo touch /etc/sddm.conf
check_cmd
fi
if [ "$DE" = 'XFCE' ] && [[ ! -f /etc/lightdm/lightdm.conf ]]; then
echo -n "- - [Pavé numérique] Création du fichier de configuration LIGHTDM : "
sudo touch /etc/lightdm/lightdm.conf
check_cmd
fi
if [ "$DE" = 'KDE' ] && [[ $(grep -c "Numlock=on" /etc/sddm.conf) -lt 1 ]]; then
echo -n "- - [Pavé numérique] Activation pour KDE Plasma : "
sudo echo "[General]" | sudo tee -a /etc/sddm.conf > /dev/null && echo "Numlock=on" | sudo tee -a /etc/sddm.conf > /dev/null
check_cmd
elif [ "$DE" = 'XFCE' ] && [[ $(grep -c "numlockx" /etc/lightdm/lightdm.conf) -lt 1 ]]; then
echo -n "- - [Pavé numérique] Activation pour XFCE : "
sudo sed -i 's/^#greeter-setup-script=/greeter-setup-script=\/usr\/bin\/numlockx on/' /etc/lightdm/lightdm.conf
check_cmd
fi
msg_bold_blue "➜ Pacman hooks"
# if [[ ! -f /usr/share/libalpm/hooks/z_orphans.hook ]]; then
# echo -n "- - Ajout de z_orphans.hook : "
# sudo cp $ICI/config/z_orphans.hook /usr/share/libalpm/hooks
# check_cmd
# fi
if [[ ! -f /usr/share/libalpm/hooks/z_pacnew.hook ]]; then
echo -n "- - Ajout de z_pacnew.hook : "
sudo cp $ICI/config/z_pacnew.hook /usr/share/libalpm/hooks
check_cmd
if [[ ! -f $HOME/Documents/Linux/Divers_Scripts/pacman_pacnew.hook ]]; then
echo -n "- - - Déplacement de pacman_pacnew.hook : "
mkdir -p $HOME/Documents/Linux/Divers_Scripts
cp $ICI/config/pacman_pacnew.hook $HOME/Documents/Linux/Divers_Scripts
check_cmd
fi
fi
if ! check_pkg nvidia && ! check_pkg nvidia-lts && [[ $(lspci -vnn | grep -A 12 '\[030[02]\]' | grep -Ei "vga|3d|display|kernel" | grep -ic nvidia) -gt 0 ]]; then
msg_bold_blue "➜ Paquets Nvidia"
sudo pacman -S --needed --noconfirm nvidia nvidia-lts nvidia-utils nvidia-settings >> "$log_file" 2>&1
check_cmd
fi
# ### NPM
# msg_bold_blue "➜ Paquets Node.js via npm"
# if check_pkg npm && [[ $(npm list -g | grep -c 'clipboard-cli') -lt 1 ]]; then
# echo -n "- - Installation de clipboard-cli : "
# npm install --global clipboard-cli >> "$log_file" 2>&1
# check_cmd
# fi
fi
#--------------------------------------
# [FIN] FAUT PAS ETRE DANS UNE VM
#--------------------------------------
#++++++++++++++++++++++++++++++++++++++
# [DEBUT] Desktop Environment
#++++++++++++++++++++++++++++++++++++++
if [[ "$DE" = 'KDE' ]]; then
msg_bold_blue "➜ KDE Dolphin services menu"
if check_pkg meld && [[ ! -f $HOME/.local/share/kio/servicemenus/compare-using-meld.desktop ]]; then
echo -n "- - Comparer avec Meld : "
if [ -f "$ICI/config/compare-using-meld.desktop" ]; then
mkdir -p $HOME/.local/share/kio/servicemenus
cp "$ICI/config/compare-using-meld.desktop" $HOME/.local/share/kio/servicemenus
check_cmd
fi
fi
fi
#--------------------------------------
# [FIN] Desktop Environment
#--------------------------------------
#++++++++++++++++++++++++++++++++++++++
# [DEBUT] VERSION COMPLÈTE OU LITE
#++++++++++++++++++++++++++++++++++++++
if [ "$install_type" = 1 ]; then
msg_bold_blue "➜ Paquets PACMAN supplémentaires FULL"
while read -r line
do
if [[ "$line" == add_full:* ]]; then
p=${line#add_full:}
if ! check_pkg "$p"; then
echo -n "$sign_green $p : "
add_pkg_pacman "$p"
check_cmd
fi
fi
if [[ "$line" == del_full:* ]]; then
p=${line#del_full:}
if check_pkg "$p"; then
echo -n "$sign_red $p : "
del_pkg_pacman "$p"
check_cmd
fi
fi
done < "packages/pacman.list"
msg_bold_blue "➜ Paquets PARU supplémentaires FULL"
if check_pkg paru; then
while read -r line
do
# Par défaut
if [[ "$line" == add_full:* ]]; then
p=${line#add_full:}
if ! check_pkg "$p"; then
echo -n "$sign_green $p : "
add_pkg_paru "$p"
check_cmd
fi
fi
if [[ "$line" == del_full:* ]]; then
p=${line#del_full:}
if check_pkg "$p"; then
echo -n "$sign_red $p : "
del_pkg_paru "$p"
check_cmd
fi
fi
done < "packages/paru.list"
fi
if [[ "$VM" = "none" ]]; then
msg_bold_blue "➜ Service et timer systemd pour sauvegarde perso"
if [[ ! -f $HOME/Documents/Linux/backup_nettoyage.sh ]]; then
echo ${YELLOW}"/!\ $HOME/Documents/Linux/backup_nettoyage.sh manquant"${RESET}
ask_continue
elif [[ -f $HOME/Documents/Linux/backup_nettoyage.sh ]]; then
if [[ ! -f /etc/systemd/system/backup_nettoyage.service ]]; then
echo -n "- - Copie backup_nettoyage.service : "