forked from vcatafesta/void-install
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoid-install.old
More file actions
executable file
·8683 lines (7737 loc) · 259 KB
/
Copy pathvoid-install.old
File metadata and controls
executable file
·8683 lines (7737 loc) · 259 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
#!/usr/bin/env bash
#shellcheck disable=SC2145,SC2001,SC2188,SC2015,SC2155,SC2317,SC2320,SC2291,SC2034,SC2120,SC2086,SC2319
#shellcheck disable=SC2016,SC2154,SC2207,SC2166,SC2128,SC2059,SC2140,SC2031,SC2030,SC2036,SC2119,SC2027
#
# void-install
# Created: 2022/12/24
# Updated: dom 30 ago 2026 04:57:54 -04
#
# Copyright (c) 2022-2026, Vilmar Catafesta <vcatafesta@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##############################################################################
export LANGUAGE="${LANGUAGE:-pt_BR}"
export TEXTDOMAINDIR=/usr/share/locale
export TEXTDOMAIN=void-install
#todo
#usermod -a -G bluetooth $USER
#debug
red="$(tput bold)$(tput setaf 196)"
green="$(tput bold)$(tput setaf 2)"
pink="$(tput setaf 5)"
cyan="$(tput setaf 6)"
reset="$(tput sgr0)"
rst="$(tput sgr0)"
export PS4='${red}${0##*/}${green}[${FUNCNAME[0]:-MAIN}]${pink}[$LINENO]${reset} '
#set -x
#set -eo pipefail
shopt -s extglob
#system
readonly APP="${0##*/}"
readonly _VERSION_='3.8.30-20260830'
declare -g DEPENDENCIES=(dialog rsync awk tar sed cat grep sort tr
chroot blkid fdisk parted lsblk curl xz tee
mkfs.vfat mkfs.xfs mkfs.ntfs mkfs.jfs mkfs.btrfs mkfs.f2fs mkfs.nilfs2
lvm cryptsetup gettext tput gdisk
)
declare -gA PACKAGEDEP=(
['tput']='ncurses'
['qemu-system-x86_64']='qemu-full'
['spice-vdagent']='spice-vdagent'
['remote-viewer']='virt-viewer'
['python3']='python'
['virsh']='libvirt'
['find']='findutils'
['awk']='gawk'
['brctl']='bridge-utils'
['gdisk']='gptfdisk'
)
readonly LOCKFILE="/tmp/void-install.lock"
declare -gA DISTRO_PKGS=(
["voidbr"]="dialog gettext rsync parted curl xz lvm2 xfsprogs ntfs-3g jfsutils gptfdisk btrfs-progs f2fs-tools nilfs-utils"
["void"]="dialog gettext rsync parted curl xz lvm2 xfsprogs ntfs-3g jfsutils gptfdisk btrfs-progs f2fs-tools nilfs-utils"
["void-live"]="dialog gettext rsync parted curl xz lvm2 xfsprogs ntfs-3g jfsutils gptfdisk btrfs-progs f2fs-tools nilfs-utils"
["voidlinux"]="dialog gettext rsync parted curl xz lvm2 xfsprogs ntfs-3g jfsutils gptfdisk btrfs-progs f2fs-tools nilfs-utils"
["chili"]="dialog gettext rsync parted curl xz lvm2 xfsprogs libntfs-3g ntfs-3g ntfsprogs jfsutils gptfdisk btrfs-progs f2fs-tools nilfs-utils"
["chililinux"]="dialog gettext rsync parted curl xz lvm2 xfsprogs libntfs-3g ntfs-3g ntfsprogs jfsutils gptfdisk btrfs-progs f2fs-tools nilfs-utils"
["arch"]="dialog gettext rsync parted curl xz lvm2 xfsprogs libntfs-3g ntfs-3g ntfsprogs jfsutils gptfdisk btrfs-progs f2fs-tools nilfs-utils"
["manjaro"]="dialog gettext rsync parted curl xz lvm2 xfsprogs libntfs-3g ntfs-3g ntfsprogs jfsutils gptfdisk btrfs-progs f2fs-tools nilfs-utils"
["debian"]="dialog gettext-base rsync parted curl xz-utils lvm2 xfsprogs ntfs-3g jfsutils gptfdisk btrfs-progs f2fs-tools nilfs-utils"
)
declare -gA DISTRO_MGR=(
["voidbr"]="xbps-install -Syu --ignore-file-conflicts"
["void"]="xbps-install -Syu --ignore-file-conflicts"
["void-live"]="xbps-install -Syu --ignore-file-conflicts"
["voidlinux"]="xbps-install -Syu --ignore-file-conflicts"
["chili"]="pacman -Sy --needed --noconfirm"
["chililinux"]="pacman -Sy --needed --noconfirm"
["arch"]="pacman -Sy --needed --noconfirm"
["manjaro"]="pacman -Sy --needed --noconfirm"
["debian"]="apt-get install -y"
)
declare LCUSTOM=false
declare LAUTOLOGIN=false
declare LEFI=false
declare LGRUB=false
declare LLOADER=true
declare LDISK=false
declare LMIRROR=true
declare LSOURCE=true
declare LKEYMAP=true
declare LTIMEZONE=true
declare LKERNEL=true
declare LWM=true
declare LDM=true
declare LAUTO=true
declare LMKPARTED=false
declare LFSREVISED=false
declare LFS=false
declare LPARTITION=false
declare LBIND=false
declare LBIOS=true
declare LOSPROBER=false
declare LCHROOT=false
declare LINSTALL=false
declare LVM=false
declare LFDE=false
declare LONLY_TTY=true
declare LAUDIO=false
declare LSERVER=false
declare LDHCP=false
declare LEXTRA=false
declare LLOCALE=true
declare LXORG=false
declare LSWAY=false
declare LMANGO=false
declare LHYPRLAND=false
#
declare DEFITEM
#
declare -gi njobs=73
declare -gi ncounter=0
declare -gi quiet=0
declare -gi grafico=1
#
declare -ga aCustomPackages=()
declare -gA Amkfs
declare -gA Amntpoint
declare -gA AmntpointFDE
declare -gA AARRAY_DSK_DEVICES
declare -gA AARRAY_PART_DEVICES
declare -gA AARRAY_VG_DEVICES
#
declare chostname_base='voidbr'
declare -gA AsUser=(
[cpass]='voidlinux'
[cpassroot]='voidlinux'
[chostname]='voidbr'
[cgroups]='wheel,audio,video,tty,floppy,cdrom,optical,kvm,xbuilder'
)
#
declare -gA AConfFde=(
[partition]=''
[vg]='voidvm'
[passphrase]='voidlinux'
[verifypassphrase]='voidlinux'
[lvroot]='25%'
[lvswap]='2%'
[lvvar]=''
[lvhome]='100%'
)
declare -gA AConfDisk=(
[_DEVICE]='/dev/sdX'
[_FILESYSTEM]='ext4'
[_DISKTABLE]=''
[_BOOTLOADER]='/dev/sdX'
[_OSPROBER]=false
[_HEALTH]='/dev/sdX'
)
declare -gA AConfLocale=(
[_TIMEZONE]='America/Sao_Paulo'
[_KEYMAP]='br-abnt2'
[_CLOCK]='UTC'
[_FONT]='Uni3-TerminusBold24x12'
[_LOCALE]='pt_BR.utf8'
[_REGION]='Portuguese Brazil'
)
declare -gA AConfMirror=(
[_SOURCE]='network'
# [_MIRROR]='repo.fastly.voidlinux.org'
# [url_mirror]='https://repo-fastly.voidlinux.org'
# [location]='Fastly Global CDN'
[_MIRROR]='void.voidbr.org'
[url_mirror]='https://void.voidbr.org/voidlinux/'
[location]='M. do Paranapanema, Brazil'
)
declare -gA AConfAudio=(
[_AUDIOSERVER]='None'
)
declare -gA AConfKernel=(
[_KERNEL]='linux'
)
declare -gA AConfBootLoader=(
[_LOADER]='grub'
)
declare -gA AConfWifi=(
[_NETWORK]='wifi_ssid'
[_PASSWORD]='wifi_password'
)
declare -gA Alanguage=(
[pt_BR]=0
[en_US]=1
[de_DE]=2
[fr_FR]=3
[es_ES]=4
[it_IT]=5
)
declare -gA Alocale=(
[0]=pt_BR
[1]=en_US
[2]=de_DE
[3]=fr_FR
[4]=es_ES
[5]=it_IT
)
declare -gA AsDhcp=(
AsDhcp [IFACE]="${Asdhcp[IFACE]:-eth0}"
AsDhcp [IP]="${AsDhcp[IP]:-192.168.1.100}"
AsDhcp [CIDR]="${AsDhcp[CIDR]:-24}"
AsDhcp [GATEWAY]="${AsDhcp[GATEWAY]:-192.168.1.1}"
AsDhcp [DNS1]="${AsDhcp[DNS1]:-1.1.1.1}"
AsDhcp [DNS2]="${AsDhcp[DNS2]:-8.8.8.8}"
)
declare -gA AsDiskPercent=(
[_DISKTABLE]="EFI"
[root]="100"
[boot]="0"
[home]="0"
[swap]="0"
)
declare -gA AsDiskSize=(
[root]="0"
[boot]="0"
[home]="0"
[swap]="0"
)
declare -gA AsFs=(
[_DEVICE]='/dev/sdX'
[root]="ext4"
[boot]="ext4"
[home]="ext4"
[swap]="swap"
)
declare dialogRcFile="$HOME/.dialogrc"
declare _DISPLAYMANAGER='None'
declare _WINDOWMANAGER=('tty')
declare _WM='tty'
declare _WIFI_NETWORK="wifi_ssid"
declare _WIFI_PASSWORD="wifi_password"
declare Interrupted="$(gettext "Interrompido! Saindo...")"
trap 'printf "\n${red}$Interrupted\n"; cleanup; exit 0' INT TERM HUP
cleanup() {
# Silencia erros no cleanup para evitar loops de erro na saída
exec 2>/dev/null
info_msg "$(gettext 'Removendo arquivos temporários')..."
[[ -f "$BOOTLOG" ]] && rm -f "$BOOTLOG"
# Só tenta desmontar se o diretório de instalação existir e estiver montado
mountpoint -q "$dir_install" && sh_umount_fs
exit 1
}
detect_distro() {
local id=""
if [[ -r /etc/os-release ]]; then
# Lê ID=void|arch|debian|... exatamente como a distro declara
id=$(grep -E '^ID=' /etc/os-release | cut -d= -f2 | tr -d '"')
elif [[ -r /usr/lib/os-release ]]; then
id=$(grep -E '^ID=' /usr/lib/os-release | cut -d= -f2 | tr -d '"')
else
echo "unknown"
return
fi
echo "$id"
}
readconf() {
if [[ $LC_DEFAULT -eq 0 ]]; then
read -r -p "$@ [S/n]"
else
read -r -p "$@ [Y/n]"
fi
[[ ${REPLY^} == "" ]] && return 0
[[ ${REPLY^} == N ]] && return 1 || return 0
}
check_gettext() {
# 1. Se o gettext já estiver disponível, não faz nada e retorna sucesso
if command -v gettext >/dev/null; then
return 0
fi
# 2. Segurança: Operações de pacotes exigem root
if ((EUID != 0)); then
echo -e "${red}erro: você não pode realizar esta operação a menos que seja root.${reset}"
exit 1
fi
echo -e "Distro detectada: ${green}${DISTRO}${reset}"
# 3. Extração dos dados dos mapas que você definiu
local pkgs="${DISTRO_PKGS[$DISTRO]}"
local cmd="${DISTRO_MGR[$DISTRO]}"
# Se a distro atual não existir no mapa, precisamos avisar e parar
if [[ -z "$cmd" ]]; then
echo -e "${red}Erro: Nenhuma configuração de pacotes encontrada para a distro: '$DISTRO'${reset}"
exit 1
fi
# 4. Prompt ao usuário (usando sua função readconf)
# Se gettext não existe, as mensagens ainda precisam ser via echo/printf
if readconf "${red}FALHA:${reset} ${cyan}Pacote/Comando 'gettext' não encontrado. Instalar dependências base agora?${reset}"; then
echo -e "${blue}::${reset} Preparando ambiente para ${green}${DISTRO}${reset}..."
# Execução dinâmica: $cmd (gerenciador) + $pkgs (lista de pacotes)
if ! $cmd $pkgs; then
echo -e "${red}Erro Crítico:${reset} A instalação dos pacotes básicos falhou."
exit 1
fi
echo -e "${green}Sucesso:${reset} Dependências instaladas."
else
# Se o usuário negar a instalação de ferramentas básicas, o instalador não tem como seguir
echo -e "${yellow}Aviso:${reset} O gettext é indispensável para as traduções. Saindo..."
exit 1
fi
}
check_dependencies() {
local TMP_FILE="/tmp/$(basename "$0").restarted"
local d
local errorFound=false
local aCmdNotFound=()
clear
reset
for d in "${DEPENDENCIES[@]}"; do
if [[ -z $(command -v "$d") ]]; then
if has_command dialog; then
sh_info_msg "${RED} ✗ ${RST} ${cmsg_CommandNotFound} ${CYAN}'$d'${RST}"
else
printf '%s\n' "${red} ✗ ${rst} ${cmsg_CommandNotFound} ${cyan}'$d'${reset}"
fi
aCmdNotFound+=("$d")
errorFound=true
fi
done
if ! $errorFound; then
return 0
fi
if has_command dialog; then
sh_info_msg "Distro detectada: ${GREEN}${DISTRO}${RST}"
else
echo -e "Distro detectada: ${green}${DISTRO}${rst}"
fi
# 3. Extração dos dados dos mapas que você definiu
local pkgs="${DISTRO_PKGS[$DISTRO]}"
local cmd="${DISTRO_MGR[$DISTRO]}"
# Se a distro atual não existir no mapa, precisamos avisar e parar
if [[ -z "$cmd" ]]; then
if has_command dialog; then
alerta "${APP}" "${RED}Erro: Nenhuma configuração de pacotes encontrada para a distro: '$DISTRO'${RST}"
else
echo -e "${red}Erro: Nenhuma configuração de pacotes encontrada para a distro: '$DISTRO'${rst}"
fi
exit 1
fi
lprossiga=false
if has_command dialog; then
if conf "${APP}" \
"\n${BOLD}${RED} ✗ ${RST} ${cmsg_CommandNotFound} ${CYAN}'${aCmdNotFound[*]}'${RST}" \
"\n\n${YELLOW}Instalar dependências base agora ?"; then
lprossiga=true
fi
else
echo
if readconf "${cyan}Instalar dependências base agora?${rst}"; then
lprossiga=true
fi
fi
if $lprossiga; then
if has_command dialog; then
sh_info_msg "${BLUE}::${RST} Preparando ambiente para ${GREEN}${DISTRO}${RST}..."
else
echo -e "${blue}::${reset} Preparando ambiente para ${green}${DISTRO}${rst}..."
fi
# Execução dinâmica: $cmd (gerenciador) + $pkgs (lista de pacotes)
if ! $cmd $pkgs; then
if has_command dialog; then
alerta "${APP}" "${RED}Erro Crítico:${RST} A instalação dos pacotes básicos falhou."
else
echo -e "${red}Erro Crítico:${reset} A instalação dos pacotes básicos falhou."
fi
exit 1
fi
echo -e "${green}Sucesso:${reset} Dependências instaladas."
touch "$TMP_FILE"
exec "$0" "$@"
else
# Se o usuário negar a instalação de ferramentas básicas, o instalador não tem como seguir
if has_command dialog; then
alerta "${APP}" "${YELLOW}Aviso:${RST} Os comandos são indispensáveis. Saindo..."
else
echo -e "${yellow}Aviso:${rst} Os comandos são indispensáveis. Saindo..."
fi
exit 1
fi
}
has_command() {
command -v "$1" >/dev/null && return 0 || return 1
}
###########################################################################################################
# Corte para teste do gettext
DISTRO="$(detect_distro)"
check_gettext
###########################################################################################################
sh_enablePrintk() {
if [[ -w /proc/sys/kernel/printk ]]; then
echo 4 >/proc/sys/kernel/printk
fi
}
get_option() {
echo $(grep -E "^${1}.*" $app_conf | sed -e "s|${1}||")
}
die() {
local msg=$1
local erros
local tmp
if test $# -ge 2; then
evaluate_retval 1
fi
# mapfile -t erros < <(
# tail -n 30 "$BOOTLOG" | grep -Ei 'ERRO:|ERROR:|FAIL|FAILED'
# )
# if [[ "${#erros[@]}" -eq 0 ]]; then
# mapfile -t erros < <(
# tail -n 20 "$BOOTLOG"
# )
# fi
tmp="$(mktemp)"
# tail -n 40 "$BOOTLOG" | grep -Ei 'ERRO:|ERROR:|FAIL|FAILED' > "$tmp"
tail -n 13 "$BOOTLOG" >"$tmp"
printf '\n%s\n' "$msg" >>"$tmp"
shift
if has_command dialog; then
#alerta_die "DIE" "\n${BOLD}${RED}$msg${RST}" erros
${DIALOG} --title "ERRO - $msg" --textbox "$tmp" 20 120
rm -f "$tmp"
else
printf "%-75s\n" "$(DOT)${bold}${red}$msg${reset}" >&2
fi
sh_enablePrintk
exit 1
}
DOT() {
printf "%s" "${blue}:: ${reset}"
}
sh_create_dialogrc() {
cat >"$dialogRcFile" <<-'EOF'
screen_color = (white,black,off)
dialog_color = (white,black,off)
title_color = (green,black,on)
border_color = dialog_color
shadow_color = (black,black,on)
button_inactive_color = dialog_color
button_key_inactive_color = dialog_color
button_label_inactive_color = dialog_color
button_active_color = (black,green,on)
button_key_active_color = button_active_color
button_label_active_color = (white,green,on)
tag_key_selected_color = (white,green,on)
item_selected_color = tag_key_selected_color
form_text_color = (green,black,on)
form_item_readonly_color = (cyan,black,on)
itemhelp_color = (white,green,off)
inputbox_color = dialog_color
inputbox_border_color = dialog_color
searchbox_color = dialog_color
searchbox_title_color = title_color
searchbox_border_color = border_color
position_indicator_color = title_color
menubox_color = dialog_color
menubox_border_color = border_color
item_color = dialog_color
tag_color = title_color
tag_selected_color = button_label_active_color
tag_key_color = button_key_inactive_color
check_color = dialog_color
check_selected_color = button_active_color
uarrow_color = screen_color
darrow_color = screen_color
form_active_text_color = button_active_color
gauge_color = title_color
border2_color = dialog_color
searchbox_border2_color = dialog_color
menubox_border2_color = dialog_color
separate_widget = ''
tab_len = 0
visit_items = off
use_shadow = off
use_colors = on
EOF
export DIALOGRC="$dialogRcFile"
}
sh_cmd_job() {
local cmsg="$1"
local cjob="$2"
local erro_fatal="$3"
local lretval=0
local disk="${AConfDisk[_DEVICE]}"
# cmsg+=" ${cmsg_Em} ${yellow}${disk}"
last_msg="$cmsg"
msg "INFO" "$last_msg" "$(log_info_msg "$last_msg")"
if ((grafico)); then
read LINES COLUMNS <<<"$(stty size)"
cmsg=$(strip_ansi "$cmsg")
eval "$cjob" 2>&1 | tee -i -a "$BOOTLOG" |
${DIALOG} \
--colors \
--backtitle "$ccabec" \
--title "\Zb\Z3[$ufmt] ${WHITE}[$cmsg] ${CYAN}[$(sh_time_elapsed)]${RST}" \
--progressbox $((MAXROW / 2)) $((MAXCOL - 20))
else
eval "$cjob" 2>&1 | tee -i -a "$BOOTLOG" >$LOGGER
fi
lretval="${PIPESTATUS[0]}"
evaluate_retval "$lretval" "$erro_fatal"
shell='/bin/sh'
return "$lretval"
}
sh_chroot_job() {
local cmsg="$1"
local cjob="$2"
local erro_fatal="$3"
local level="$4"
local lretval=0
local disk="${AConfDisk[_DEVICE]}"
# cmsg+=" ${cmsg_Em} ${yellow}${disk}"
last_msg="$cmsg"
# CHAMADA DA MSG: Agora com "silent" para não cagar o progressbox abaixo
if [[ -n "$level" ]]; then
msg "INFO" "$last_msg" "$(log_info_msg_level "$last_msg")" "silent"
else
msg "INFO" "$last_msg" "$(log_info_msg "$last_msg")" "silent"
fi
if ((grafico)); then
read LINES COLUMNS <<<"$(stty size)"
clean_logmessage="$(strip_ansi "$logmessage")"
# SEU CÓDIGO ORIGINAL ABAIXO
chroot "$dir_install" "$shell" -c "$cjob" 2>&1 | tee -i -a "$BOOTLOG" |
${DIALOG} \
--colors \
--backtitle "$ccabec" \
--title "\Zb\Z3[$ufmt] \Z7[$clean_logmessage]\Zn \Z6[$(sh_time_elapsed)]\Zn" \
--progressbox $((MAXROW / 2)) $((MAXCOL - 20))
else
chroot "$dir_install" "$shell" -c "$cjob" 2>&1 | tee -i -a "$BOOTLOG" >$LOGGER
fi
lretval="${PIPESTATUS[0]}"
evaluate_retval "$lretval" "$erro_fatal" "" "$level"
shell='/bin/sh'
return "$lretval"
}
sh_update_sshd() {
sh_chroot_job "$(gettext 'Atualizando config sshd')" '
mkdir -p /etc/ssh/sshd_config.d/
cat >/etc/ssh/sshd_config.d/10-custom.conf <<'EOF'
# Configurações gerais
PermitTTY yes
PrintMotd yes
PrintLastLog yes
Banner /etc/issue.net
# Autenticação
PermitRootLogin yes
PasswordAuthentication yes
KbdInteractiveAuthentication yes
ChallengeResponseAuthentication yes
PubkeyAuthentication yes
PubkeyAcceptedKeyTypes=+ssh-rsa
AuthorizedKeysFile .ssh/authorized_keys
UsePAM yes
# Recursos
X11Forwarding yes
Subsystem sftp internal-sftp
EOF
' $err_not_fatal
}
sh_update_locale() {
local f="${dir_install}/etc/default/libc-locales"
local cConf_file="${dir_install}/etc/locale.conf"
local raw="${AConfLocale[_LOCALE]}"
raw="${raw%%.*}"
export base="${raw}.UTF-8"
export locale="${raw}.UTF-8 UTF-8"
sh_cmd_job "${cmsg_Ajustando} locales [/etc/default/libc-locales, /etc/locale.conf]" "
sed -i '/^[^#]/ s/^/#/' \"$f\"
printf '%s\n' \"$locale\" >>\"$f\"
touch "$cConf_file"
cat >"$cConf_file" <<EOF
LANG=$base
LANGUAGE=$base
LC_COLLATE=C
LC_ALL=$base
EOF
" $err_not_fatal
# sh_chroot_job "${cmsg_Configurando} locales" "
# xbps-reconfigure --force glibc-locales
# "
}
sh_update_self() {
local repo_url="https://raw.githubusercontent.com/voidlinuxbr/void-install/main/void-install"
local local_script="$0"
local temp_file
local remote_hash
local local_hash
# Cria um arquivo temporário para armazenar a versão remota
temp_file=$(mktemp)
log_msg "$(gettext 'Verificando por atualizações do script')..."
# Baixa a versão mais recente do repositório
if command -v curl >/dev/null 2>&1; then
curl -sSfL "$repo_url" -o "$temp_file"
elif command -v wget >/dev/null 2>&1; then
wget -q "$repo_url" -O "$temp_file"
else
log_msg "$(gettext 'Erro: nem curl nem wget estão instalados. Atualização não pode ser realizada.')"
rm -f "$temp_file"
return 1
fi
# Calcula os hashes das versões local e remota
remote_hash=$(sha256sum "$temp_file" | awk '{print $1}')
local_hash=$(sha256sum "$local_script" | awk '{print $1}')
# Compara os hashes para detectar mudanças
if [[ "$remote_hash" != "$local_hash" ]]; then
log_msg "$(gettext 'Nova versão encontrada. Atualizando o script...')"
mv "$temp_file" "$local_script"
chmod +x "$local_script"
log_msg "$(gettext 'Atualização concluída. Recarregando o script...')"
exec "$local_script" "$@" # Recarrega o script com os mesmos argumentos
else
log_msg "$(gettext 'O script já está atualizado.')"
rm -f "$temp_file"
fi
}
sh_configure_display_manager() {
if ! $LONLY_TTY; then
case $_DISPLAYMANAGER in
lxdm)
aDisplaymanager=(lxdm)
custom=(lxdm-theme-vdojo)
;;
sddm)
aDisplaymanager=(
sddm
weston # Reference implementation of a Wayland compositor
)
custom=(voidbr-sddm-themes)
;;
gdm)
aDisplaymanager=(gdm)
;;
lightdm)
aDisplaymanager=(
lightdm
lightdm-gtk-greeter
lightdm-gtk-greeter-settings
arc-theme
papirus-icon-theme
)
custom=(voidbr-lightdm-themes)
;;
*)
aDisplaymanager=()
custom=()
;;
esac
# aplica config custom somente se LCUSTOM for true
# if $LCUSTOM && ((${#custom[@]})); then
if $LCUSTOM; then
aDisplaymanagerConfig=("${custom[@]}")
fi
fi
}
sh_choose_common_packages() {
declare -ga aDisplaymanager=()
declare -ga aDisplaymanagerConfig=()
declare -ga custom=()
declare -ga aExtra=(
bash-completion
fzf
dialog
pv
tree
duf
parted
rsync
nvme-cli
curl
wget
nano
)
if $LCUSTOM; then
declare -ga aMicrocode=(
intel-ucode
linux-firmware-amd
)
declare -ga aSuplemento=(
voidbr-utils
voidbr-nano-config
voidbr-webapps
chili-utils
chili-clonedisk
)
aExtra+=(
parallel
)
fi
sh_configure_display_manager
if $LSERVER; then
aPackageDaemons+=(iptables)
aServicesTTY+=(dhcpcd iptables)
return
fi
#common
aPackageDaemons+=(NetworkManager dhcpcd)
aServicesTTY+=(NetworkManager)
if $LSWAY; then
return
fi
if $LMANGO; then
return
fi
if $LHYPRLAND; then
return
fi
if $LXORG; then
return
fi
if ! $LONLY_TTY; then
declare -ga aXorg=(xorg xinit xterm xorg-fonts dbus-x11 elogind dbus-elogind polkit-elogind xdg-user-dirs xrdb xorg-server-xwayland)
declare -ga aVideo=(mesa-dri linux-firmware-intel xf86-video-amdgpu xf86-video-ati mesa-nouveau-dri libavif libheif gdk-pixbuf libheif-pixbuf-loader)
declare -ga aPulseaudio=(pulseaudio pavucontrol pasystray gst-plugins-bad1 gst-plugins-good1 gst-plugins-ugly1 gst-plugins-base1 alsa-plugins-pulseaudio alsa-utils)
declare -ga aPipewire=(pipewire wireplumber alsa-pipewire pulseaudio-utils pavucontrol libspa-bluetooth libjack-pipewire alsa-plugins-pulseaudio alsa-utils)
if $LCUSTOM; then
declare -ga aIconsAndThemes=()
declare -ga aArchiverX=()
declare -ga aBrowser=()
declare -ga aFilemanager=()
declare -ga aBluetooth=(bluez bluez-alsa bluedevil blueman bluez-deprecated gnome-bluetooth1 blueberry)
declare -ga aFonts=()
declare -ga aPerfumery=()
declare -ga aPrinter=()
declare -ga aTerminal=(rxvt-unicode)
declare -ga aEditorX=()
declare -ga aNetworkX=(gvfs gvfs-smb gvfs-mtp gvfs-afc gvfs-cdda gvfs-gphoto2 udisks2)
declare -ga aUtilityX=(xkill lm_sensors)
declare -ga aArchiverTty=()
declare -ga aDownloader=()
# declare -ga aUtility=(binutils dfc btop parallel bubblewrap cmatrix pfetch bc bat xtools geoip geoipupdate)
declare -ga aUtility=(binutils bc)
aServicesX+=(bluetoothd)
else
declare -ga aIconsAndThemes=()
declare -ga aTerminal=()
declare -ga aBrowser=()
declare -ga aFilemanager=()
declare -ga aUtilityX=()
fi
aFonts+=(noto-fonts-emoji)
aFonts+=(
noto-fonts-cjk
dejavu-fonts-ttf
font-fira-ttf
font-firacode
font-hack-ttf
ttf-jetbrains-mono-nerd
#nerd-fonts
)
aIconsAndThemes+=(Adapta adwaita-icon-theme arc-theme)
aTerminal+=(xfce4-terminal)
aBrowser+=(firefox firefox-i18n-$(sh_get_language_without_utf8))
aFilemanager+=(octoxbps)
aUtilityX+=(chili-iso2usb voidbr-iso-writer)
aNetworkX+=(network-manager-applet)
fi
}
errorbeep() {
printf '\a' # beep
}
info_msg() {
# notify-send "$ccabec" "$@"
printf "\033[1m$@\n\033[m"
}
sh_setEnvironment() {
[[ ! -e "$dialogRcFile" ]] && sh_create_dialogrc
declare url_mirror='https://repo-fastly.voidlinux.org/'
declare -g app_conf='/tmp/void-install.conf'
declare -g dir_install='/mnt/voidbr'
readonly cnickefi='Void_install'
readonly _TARBALL_ROOTFS=void-x86_64-base-custom-current.tar.xz
readonly url_tarball="https://raw.githubusercontent.com/voidlinuxbr/void-install/refs/heads/main/${_TARBALL_ROOTFS}"
readonly url_tarball_md5="https://raw.githubusercontent.com/voidlinuxbr/void-install/refs/heads/main/${_TARBALL_ROOTFS}.md5"
#
readonly zero=0
readonly one=1
readonly err_not_fatal=0
readonly err_fatal=1
#
readonly BOOTLOG="/tmp/void-install-$(sh_diahora).log"
readonly LOGGER='/dev/tty8'
shell='/bin/sh'
# flag disk info
: "${DSK_NAME=1}"
: "${DSK_SIZE=2}"
: "${DSK_TRAN=3}"
: "${DSK_MODEL=4}"
: "${DSK_LABEL=5}"
: "${DSK_SERIAL=6}"
: "${DSK_PTTYPE=7}"
: "${DSK_FSTYPE=8}"
: "${DSK_PARTTYPENAME=9}"
# flag languages
: "${pt_BR=0}"
: "${PT_BR=0}"
: "${EN_US=1}"
: "${DE_DE=2}"
: "${FR_FR=3}"
: "${LC_DEFAULT=$(sh_get_Locale)}"
# flag dialog exit status codes
: "${D_OK=0}"
: "${D_DONE=0}"
: "${D_NO=1}"
: "${D_CANCEL=1}"
: "${D_AJUDA=2}"
: "${D_HELP=2}"
: "${D_EXTRA=3}"
: "${D_CONFIG=3}"
: "${D_ITEM_HELP=4}"
: "${D_ESC=255}"
# flag dialog menu
: "${LDISK=}"
: "${LFS=}"
: "${LPARTITION=}"
: "${LGRUB=}"
: "${LLOADER=}"
: "${LKEYMAP=}"
: "${LWM=}"
: "${LDM=}"
: "${LWIFI=}"
: "${LMIRROR=}"
: "${LSOURCE=}"
: "${LEXTRA=}"
: "${LAUDIO=}"
: "${LTIMEZONE=}"
: "${LKERNEL=}"
: "${LFILE=}"
: "${LCUSTOM=}"
# dialog colors
RESET="\Zn"
RST='\Zn'
BOLD="\Zb"
RED='\Z1'
GREEN="\Z2"
YELLOW="\Z3"
BLUE="\Z4"
MAGENTA="\Z5"
CYAN="\Z6"
WHITE="\Z7"
BLACK="\Z0"
REVERSE="\Zr"
UNDERLINE="\Zu"
: echo "$err_fatal"
size=$(stty size)
read -r MAXROW MAXCOL <<<"$size"
COLUMNS=$(stty size)
COLUMNS=${COLUMNS##* }
if [[ "${COLUMNS}" = "0" ]]; then
COLUMNS=80
fi
COL=$((COLUMNS - 8))
SET_COL="\\033[${COL}G" # at the $COL char
CURS_ZERO="\\033[0G"
: "${ccabec="${BOLD}${WHITE}${REVERSE}${APP} ${YELLOW}v$_VERSION_ ${BLUE}https://github.com/voidlinuxbr/void-install "}"
: "${baseccabec="${BOLD}${WHITE}${REVERSE}${APP} ${YELLOW}v$_VERSION_ ${BLUE}https://github.com/voidlinuxbr/void-install "}"
: "${ccabecmin="$APP v${_VERSION_}"}"
: "${DIALOG=${DIALOG:-dialog}}"
: "${ARCH:=x86_64}"
: "${CACHEDIR:="$(pwd -P)"/xbps-cachedir-${ARCH}}"
: "${XBPS_INSTALL_CMD:=xbps-install}"
: "${XBPS_INSTALL_UNPACK_ONLY:=xbps-install --unpack-only --yes --ignore-file-conflicts}"
: "${XBPS_REMOVE_CMD:=xbps-remove}"
: "${XBPS_QUERY_CMD:=xbps-query}"
: "${XBPS_RINDEX_CMD:=xbps-rindex}"
: "${XBPS_UHELPER_CMD:=xbps-uhelper}"
: "${XBPS_RECONFIGURE_CMD:=xbps-reconfigure}"
}
sh_touchConf() {
# _WINDOWMANAGER=(${_WINDOWMANAGER[*]})
cat >"$app_conf" <<-EOF
######################################################################
# void-install.conf
# Gerado por void-install
######################################################################
WIFI_NETWORK=$_WIFI_NETWORK
WIFI_PASSWORD=$_WIFI_PASSWORD
EOF
{
declare -p _WM
declare -p LEXTRA
declare -p aCustomPackages
declare -p LONLY_TTY
declare -p LSWAY
declare -p LMANGO
declare -p LHYPRLAND
declare -p LDHCP
declare -p LCUSTOM
declare -p LCUSTOM
declare -p LDISK
declare -p LEFI
declare -p LAUDIO
declare -p LGRUB
declare -p LLOADER