-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·786 lines (627 loc) · 26.1 KB
/
install.sh
File metadata and controls
executable file
·786 lines (627 loc) · 26.1 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
#!/usr/bin/env bash
# If you think I forgot about set -e:
# Nope, I didn't. It just does not work as you expected:
# set -e
# somefunc() {
# echo true
# false
# echo should not run
# }
# somefunc || true
# Prints "should not run"
set -u
# Global variables keep installer state
# Default screen title can be overwritten in screen menu
screen_title="ITG Machine"
itgmachine_apt_updated="false"
itgmachine_efi_dir="/boot/efi/EFI/itgmachine"
itgmachine_user=itg
itgmachine_home=/home/itg
itgmachine_cache=/var/cache/itgmachine
itgmachine_install=/usr/local/games
### Whiptail interface
# Each function unsets or returns wt_out
msgbox() {
local message="$1"
unset wt_out # nothing to out
whiptail --title "$screen_title" \
--backtitle "Use <up>/<down> to navigate, <enter> to select, <tab> to switch between buttons." \
--scrolltext \
--msgbox "$message" 0 0
}
yesnobox() {
local message="$1"
unset wt_out # nothing to out
whiptail --title "$screen_title" \
--backtitle "Use <up>/<down> to navigate, <enter> to select, <tab> to switch between buttons." \
--yesno "$message" 0 0
}
inputbox() {
local message="$1"
local default="$2"
unset wt_out
wt_out=$(whiptail --title "$screen_title" \
--backtitle "Use <up>/<down> to navigate, <enter> to select, <tab> to switch between buttons." \
--inputbox "$message" 12 80 \
"$default" 3>&1 1>&2 2>&3)
}
passbox() {
local message="$1"
local default="$2"
wt_out=$(whiptail --title "$screen_title" \
--backtitle "Use <up>/<down> to navigate, <enter> to select, <tab> to switch between buttons." \
--passwordbox "$message" 12 80 \
"$default" 3>&1 1>&2 2>&3)
}
textbox() {
local file="$1";
unset wt_out # nothing to out
whiptail --title "$screen_title" \
--backtitle "Use <up>/<down> to navigate, <enter> to select, <tab> to switch between buttons." \
--scrolltext \
--textbox "$file" 0 0
}
radiobox() {
local text="Choose item from the list below:"
local wtst
if [[ $(($# % 3)) -eq 1 ]]; then text="$1"; shift; fi
local items=("$@")
wt_out=$(whiptail --title "$screen_title" \
--backtitle "Use <up>/<down> to navigate, <space> to select, <tab> to switch between buttons." \
--ok-button "Select" \
--cancel-button "Back" \
--notags \
--radiolist "$text" \
0 0 0 \
"${items[@]}" 3>&1 1>&2 2>&3)
}
checkbox() {
local text="Choose items from the list below:"
local wtst
if [[ $(($# % 3)) -eq 1 ]]; then text="$1"; shift; fi
local items=("$@")
wt_out=$(whiptail --title "$screen_title" \
--backtitle "Use <up>/<down> to navigate, <space> to select, <tab> to switch between buttons." \
--ok-button "Select" \
--cancel-button "Back" \
--notags \
--separate-output \
--checklist "$text" \
0 0 0 \
"${items[@]}" 3>&1 1>&2 2>&3)
}
menubox() {
# screen title can be changed in submenu
# this way we recursively persist it for the selected menu
local title="$screen_title"
local selected="none"
local text="Select an action:"
local wtst
if [[ $(($# % 2)) -eq 1 ]]; then text="$1"; shift; fi
local items=("$@")
while :; do
wt_out=$(whiptail --title "$title" \
--backtitle "Use <up>/<down> to navigate, <enter> to select, <tab> to switch between buttons." \
--ok-button "Select" \
--cancel-button "Back" \
--notags \
--default-item "$selected" \
--menu "$text" \
0 0 0 \
"${items[@]}" 3>&1 1>&2 2>&3)
wtst=$?
selected="$wt_out"
if [[ $wtst -ne 0 ]]; then return $wtst; fi
if [[ "$wt_out" == screen_* ]]; then $wt_out; else return 0; fi
done
# never can get here
return 100
}
# Runs command and delays so you can see result
run() {
"$@" || { echo "Exist status $?. Press enter to continue"; read -r; return 1; }
}
screen_ensure_root() {
if [[ $UID -ne 0 ]]; then
msgbox "You must run this program as root"
exit 1
fi
}
screen_reboot() {
yesnobox "Reboot ITG Machine?" && run reboot
}
screen_directory_create() {
if [[ $# -eq 0 ]]; then return 1; fi
[[ -d "$1" ]] || run mkdir -p "$1"
}
screen_apt_update() {
if [[ $# -gt 0 ]]; then itgmachine_apt_updated="false"; fi
if [[ "$itgmachine_apt_updated" == "true" ]]; then return 0; fi
run apt -o APT::Update::Error-Mode=any update \
&& itgmachine_apt_updated="true"
}
screen_apt_upgrade() {
screen_title="ITG Machine - Upgrading"
screen_apt_update && run apt dist-upgrade
}
screen_apt_repository() {
screen_title="ITG Machine - APT"
local uri="http://deb.debian.org/debian"
local suite="testing"
local components="main contrib non-free non-free-firmware"
local keyring="/usr/share/keyrings/debian-archive-keyring.pgp"
local file="/etc/apt/sources.list.d/debian.sources"
true \
&& inputbox "Enter Debian repository URI:" "$uri" \
&& uri="$wt_out" \
&& inputbox "Enter Debian Suite:" "$suite" \
&& suite="$wt_out" \
&& inputbox "Enter Debian components:" "$components" \
&& components="$wt_out" \
&& yesnobox "Update sources with:\nURIs: $uri\nSuites: $suite\nComponents: $components" \
&& echo "Types: deb" > "$file" \
&& echo "URIs: $uri" >> "$file" \
&& echo "Suites: $suite" >> "$file" \
&& echo "Components: $components" >> "$file" \
&& echo "Signed-By: $keyring" >> "$file" \
&& screen_apt_update force
}
screen_apt_package() {
screen_title="ITG Machine - Package install"
screen_apt_update && run apt install "$@"
}
screen_ensure_command() {
if [[ $# -lt 2 ]]; then
msgbox "BUG: Too few arguments in ensure command screen: '$*'"
return 1
fi
local cmd="$1"
local screen="$2"
if command -v "$cmd" &> /dev/null; then return 0; fi
yesnobox "Command $cmd was not found. The error will be fixed now. Continue?" && $screen
}
screen_console_tools() {
screen_title="ITG Machine - Console Tools"
yesnobox "Install vim mc htop?" \
&& screen_apt_package vim mc htop
}
screen_network_dhclient() {
screen_title="ITG Machine - DHCLIENT"
msgbox "You current network configuration is displayed below.
If you pluged in any wired connection this will try dhclient to set it up.
If you already have Internet connection, say no.
If you did it already as said in the README, also say no.
$(ip addr)"
yesnobox "Try dhclient?" && run dhclient
}
screen_network_manager() {
screen_title="ITG Machine - Network Manager"
screen_apt_update && run apt install network-manager
}
screen_wifi_connect() {
local ssid="$1"
screen_ensure_command nmcli network-manager \
&& passbox "Enter password for $ssid" "" \
&& run nmcli device wifi connect "$ssid" password "$wt_out"
}
screen_wifi() {
screen_title="ITG Machine - WIFI"
screen_ensure_command nmcli screen_network_manager
local menuitems=()
local wifi_networks
wifi_networks=$(nmcli -g SSID,RATE,BARS device wifi list)
while IFS=: read -r ssid rate bars; do
menuitems+=("screen_wifi_connect $ssid")
menuitems+=("$ssid ($rate $bars)")
done <<< "$wifi_networks"
menubox "${menuitems[@]}"
}
screen_uefi_dir() {
if ! mountpoint -q /boot/efi; then
msgbox "It looks like /boot/efi is not mounted. Do you have UEFI? Check and try again."
return 1
fi
if [[ ! -d "/boot/efi/EFI" ]]; then
msgbox "While your /boot/efi partition is mounted, there is no EFI directory. Something went wrong here."
return 1
fi
screen_directory_create "$itgmachine_efi_dir"
}
screen_kernel_uefi_hook() {
local hook=/etc/kernel/postinst.d/zz-update-efi
if [[ -x "$hook" && -f "$itgmachine_efi_dir/vmlinuz" ]]; then return 0; fi
cat << EOF > "$hook" || { msgbox "Unable to create kernel hook: $hook"; return 1; }
#!/bin/sh
cp -v /vmlinuz $itgmachine_efi_dir
EOF
chmod +x "$hook"
run "$hook" || { msgbox "Error while running $hook"; return 1; }
[[ -f "$itgmachine_efi_dir/vmlinuz" ]] || {
msgbox "Something went wrong with kernel hook. File $itgmachine_efi_dir/vmlinuz was not found"
return 1
}
}
screen_initramfs_uefi_hook() {
local hook=/etc/initramfs/post-update.d/zz-update-efi
if [[ -x "$hook" && -f "$itgmachine_efi_dir/initrd.img" ]]; then return 0; fi
screen_directory_create "$(dirname "$hook")" || return 1
cat << EOF > "$hook" || { msgbox "Unable to create initramfs hook: $hook"; return 1; }
#!/bin/sh
cp -v /initrd.img $itgmachine_efi_dir
EOF
chmod +x "$hook"
run "$hook" || { msgbox "Error while running $hook"; return 1; }
[[ -f "$itgmachine_efi_dir/initrd.img" ]] || {
msgbox "Something went wrong with initramfs hook. File $itgmachine_efi_dir/initrd.img was not found"
return 1
}
}
screen_uefi_bootmgr() {
local bootlabel="ITG Machine"
local fstabroot fstabefi disk bootentry bootnum
# Get root fs as in fstab
fstabroot=$(findmnt -n --fstab -o SOURCE --target /)
if [[ -z "$fstabroot" ]]; then
msgbox "Unable to detect rootfs in /etc/fstab. This is unexpected"
return 1;
fi
# Get efi boot, but resolve to a device name
fstabefi=$(findmnt -ne --fstab -o SOURCE --target /boot/efi)
if [[ -z "$fstabefi" ]]; then
msgbox "Unable to detect EFI partition in /etc/fstab. Do you have it?"
return 1;
fi
# Get disk by fstabefi device name
disk=$(lsblk -ndpo pkname "$fstabefi")
if [[ -z "$disk" ]]; then
msgbox "Unable to detect disk for EFI partition $fstabefi. Bug in lsblk?"
return 1;
fi
if bootentry=$(efibootmgr -u | grep "$bootlabel"); then
bootnum="${bootentry:4:4}"
yesnobox "UEFI Boot Entry '$bootlabel' is already exist:\n$bootentry\nDelete existing?" \
&& run efibootmgr -b "$bootnum" -B || return 1
fi
run efibootmgr -c -g -L "$bootlabel" \
-d "$disk" \
-l '\EFI\itgmachine\vmlinuz' \
-u "root=$fstabroot rw quiet nmi_watchdog=0 initrd=\\EFI\\itgmachine\\initrd.img"
}
screen_uefi() {
screen_title="ITG Machine - UEFI"
yesnobox "This can improve the boot time of your ITG Machine. When you turn on the machine, UEFI loads first. It then boots something from the EFI Boot partition, usually the Grub bootloader. Grub has its own settings and countdown timer, then it loads the ram disk (initramfs) and the kernel (vmlinuz). The kernel then initializes and runs the OS loader, which is Systemd in Debian. This setup skips Grub and directly loads the kernel when UEFI starts, making the boot process faster.
NOTE: If $(readlink -f /initrd.img) file is too big to copy on EFI partition, try to optimize the initramfs size by setting 'MODULES=dep' in '/etc/initramfs-tools/initramfs.conf' and running 'update-initramfs -k all -c -v'.
Continue?" || return 1
true \
&& screen_uefi_dir \
&& screen_kernel_uefi_hook \
&& screen_initramfs_uefi_hook \
&& screen_uefi_bootmgr \
&& msgbox "All checks have passed! You are on UEFI now. If something goes wrong you still have your previous boot options. You can choose different boot options from UEFI Boot Menu."
}
screen_openssh() {
screen_apt_package openssh-server
}
screen_vsftpd() {
screen_apt_package vsftpd \
&& run sed -i 's/#write_enable=YES/write_enable=YES/' /etc/vsftpd.conf \
&& run systemctl restart vsftpd
}
screen_sound_pipewire() {
screen_apt_package pipewire pipewire-audio wireplumber
}
screen_crudini() {
screen_apt_package crudini
}
screen_itgmania_dependencies() {
screen_apt_package libusb-0.1-4 libgl1 libglvnd0 libglu1-mesa libxtst6 \
libxinerama1 libgdk-pixbuf-2.0-0 libgtk-3-0t64
}
screen_itgmania_install_archive() {
if [[ $# -eq 0 ]]; then return 1; fi
local archive_url="$1"
local archive_name archive_file target_dir
archive_name="$(basename "$archive_url")"
archive_file="$itgmachine_cache/$archive_name"
target_dir="$itgmachine_install/$(basename "$archive_name" .tar.gz)"
screen_directory_create "$itgmachine_cache" || return 1
[[ -f "$archive_file" ]] || run wget -q --tries 3 --show-progress -O "$archive_file" "$archive_url" \
|| { msgbox "Failed to download $archive_name from url:\n$archive_url"; return 1; }
[[ -x "$target_dir/itgmania" ]] \
&& yesnobox "Looks like already installed.\nDelete $target_dir?" \
&& run rm -rf "$target_dir"
screen_directory_create "$target_dir" || return 1
[[ -x "$target_dir/itgmania" ]] || run tar -C "$target_dir" -xf "$archive_file" --strip-components 2 \
|| { msgbox "Can't unpack ITGmania from archive: $archive_file"; return 1; }
run ln -sfn "$target_dir" "$itgmachine_install"/itgmania || { msgbox "Can't update symlink"; return 1; }
msgbox "ITGmania has been cached and installed.
Also symlink $itgmachine_install/itgmania has been updated.
Name: $archive_name
DIR: $target_dir"
}
screen_itgmania_install_cached() {
local menuitems=()
local archive_file
while read -r archive_file; do
menuitems+=("$archive_file" "$(basename "$archive_file")")
done < <(find "$itgmachine_cache" -type f -name '*.tar.gz')
[[ ${#menuitems[@]} -eq 0 ]] \
&& { msgbox "No cached files were found."; return 1; }
menubox "Select ITGmania version from the list below:" "${menuitems[@]}" || return 1
screen_itgmania_install_archive "$wt_out" || return 1
}
screen_itgmania_install_release() {
local ghapi="https://api.github.com/repos/itgmania/itgmania/releases?page=1&per_page=5"
local releases='https://github.com/itgmania/itgmania/releases/download/.*Linux-no-songs.tar.gz'
local menuitems=()
local archive_url
while read -r archive_url; do
menuitems+=("$archive_url" "$(basename "$archive_url")")
done < <(wget -qO- "$ghapi" | grep -o "$releases")
[[ ${#menuitems[@]} -eq 0 ]] \
&& { msgbox "Impossible, can't find any releases!"; return 1; }
menubox "Select ITGmania version from the list below:" "${menuitems[@]}" || return 1
screen_itgmania_install_archive "$wt_out" || return 1
}
screen_itgmania_install() {
screen_title="ITG Machine - ITG Mania Installation Center"
menubox \
screen_itgmania_install_release "Install release version" \
screen_itgmania_install_cached "Install from cache"
}
screen_itgmania_sddm() {
screen_apt_package --no-install-recommends --no-install-suggests sddm || return 1
screen_directory_create /etc/sddm.conf.d || return 1
cat << EOF > /etc/sddm.conf.d/autologin.conf
[Autologin]
User=$itgmachine_user
Session=itgmania
Relogin=true
EOF
screen_directory_create /usr/local/share/xsessions || return 1
cat << EOF > /usr/local/share/xsessions/itgmania.desktop
[Desktop Entry]
Type=XSession
Exec=$itgmachine_install/itgmania/itgmania
DesktopNames=ITGmania
Name=ITGmania (X11)
EOF
}
screen_itgmania_user() {
local userent
local _x
inputbox "By default installer will use user 'itg' and home '/home/itg'. But you can change the user.
Current user: $itgmachine_user
Current home: $itgmachine_home
Please enter the existing username that will be used to run ITGmania:" "$itgmachine_user" || return 1
if userent=$(getent passwd "$wt_out"); then
IFS=: read -r itgmachine_user _x _x _x _x itgmachine_home _x <<< "$userent"
else
msgbox "User $wt_out does not exist. Try again"
return 1
fi
}
screen_itgmania_prefs() {
if [[ ! -d "$itgmachine_home" ]]; then msgbox "Home directory does not exist. Select an existing user"; return 1; fi
if [[ ! -d "$itgmachine_home/.itgmania/Save" ]]; then
screen_directory_create "$itgmachine_home/.itgmania/Save" \
&& run chown "$itgmachine_user:$itgmachine_user" "$itgmachine_home/.itgmania" \
&& run chown "$itgmachine_user:$itgmachine_user" "$itgmachine_home/.itgmania/Save" \
|| return 1
fi
screen_ensure_command crudini screen_crudini || return 1
local prefs="$itgmachine_home/.itgmania/Save/Preferences.ini"
run crudini --ini-options=nospace --set "$prefs" "$1" "$2" "$3"
}
screen_itgmania_configure() {
if yesnobox "Set arcade style navigation?"; then
screen_itgmania_prefs "Options" "ArcadeOptionsNavigation" "1"
else
screen_itgmania_prefs "Options" "ArcadeOptionsNavigation" "0"
fi
if yesnobox "Never play sounds during the attract mode, which is
the mode where the game displays a demo or other visuals to attract
players when not in use?"; then
screen_itgmania_prefs "Options" "AttractSoundFrequency" "Never"
else
screen_itgmania_prefs "Options" "AttractSoundFrequency" "EveryTime"
fi
if yesnobox "Turn off joysticks auto mapping?"; then
screen_itgmania_prefs "Options" "AutoMapOnJoyChange" "0"
else
screen_itgmania_prefs "Options" "AutoMapOnJoyChange" "1"
fi
if inputbox "Set uniq machine name" "$(hostname -f)"; then
screen_itgmania_prefs "Options" "MachineName" "$wt_out"
else
screen_itgmania_prefs "Options" "MachineName" ""
fi
if yesnobox "Use only dedicated menu buttons for navigation?"; then
screen_itgmania_prefs "Options" "OnlyDedicatedMenuButtons" "1"
else
screen_itgmania_prefs "Options" "OnlyDedicatedMenuButtons" "0"
fi
if yesnobox "Turn off Vsync (recommended)?"; then
screen_itgmania_prefs "Options" "Vsync" "0"
else
screen_itgmania_prefs "Options" "Vsync" "1"
fi
if yesnobox "Set full screen mode (recommended)?"; then
screen_itgmania_prefs "Options" "Windowed" "0"
else
screen_itgmania_prefs "Options" "Windowed" "1"
fi
}
screen_simplylove_gsapi() {
local slgs="$itgmachine_install/itgmania/Themes/Simply Love/Scripts/SL-Helpers-GrooveStats.lua"
sed -i "s|.*local url_prefix = .*| local url_prefix = \"$1\"|" "$slgs"
}
screen_boogiestats() {
if yesnobox "Turn on BoogieStats?"; then
screen_itgmania_prefs "Options" "HttpAllowHosts" "*.groovestats.com,boogiestats.andr.host"
screen_simplylove_gsapi "https://boogiestats.andr.host/"
else
screen_itgmania_prefs "Options" "HttpAllowHosts" "*.groovestats.com"
screen_simplylove_gsapi "https://api.groovestats.com/"
fi
}
screen_itgmania_inputdevices() {
screen_title="ITG Machine - Input Devices"
local checkitems=()
local dev
msgbox "ITG Mania allows to explicitly define which joysticks in which order to load. This is very useful when you have two similar pad joystick which do initialization in different order randomly. Specifying input device by uniq id can freeze the order so keymap configuration is always correct. You can manually specify your devices using comma in Preferences.ini:
InputDeviceOrder=/dev/input/by-id/p1-joystick,/dev/input/by-id/p2-joystick
or
InputDeviceOrder=/dev/input/by-path/u1-joystick,/dev/input/by-path/u2-joystick
Now trying to detect joysticks 'by-id'"
if [[ ! -d "/dev/input/by-id" ]]; then
msgbox "Udev hasn't found any input devices by-id. Try to find them and add manually"
return 1
fi
for dev in /dev/input/by-id/*-joystick; do
[[ -c "$dev" ]] || continue
[[ "$dev" == *-event-joystick ]] && continue
checkitems+=("$dev" "$(basename "$dev")" "on")
done
checkbox "Select your joysticks used for pads and control if any:" "${checkitems[@]}" || return 1
if [[ -n "$wt_out" ]]; then
screen_itgmania_prefs "Options" "InputDeviceOrder" "$(echo -n "$wt_out" | tr '\n' ',')"
else
screen_itgmania_prefs "Options" "InputDeviceOrder" ""
fi
}
screen_udev_ghettio() {
yesnobox "GHETT-io joystick (v3) resets in a loop until a read attempt. This fix will add udev rule to automatically read joystick device using dd endlessly immediately after joystick is connected. Expected joystick has vendor id 16d0 and product id 0d02. You can run lsusb to see vendor and product ids.
Add ghettio udev rule?" \
&& cat << EOF > /etc/udev/rules.d/80-ghettio-joystick.rules \
&& run udevadm control --reload-rules
# Workaround for ghettio: read joystick immediately so it stop resets in a loop:
KERNEL=="js*", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0d02", ACTION=="add", RUN+="/usr/bin/systemd-run dd if=/dev/input/%k of=/dev/null"
EOF
}
screen_pacdrive() {
screen_itgmania_user || return 1
[[ "$(getent group input)" == *"$itgmachine_user"* ]] \
|| run adduser "$itgmachine_user" input \
|| return 1
cat << EOF > /etc/udev/rules.d/75-linux-pacdrive.rules \
&& run udevadm control --reload-rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="150[0-9]", GROUP="input"
KERNEL=="hidraw*", ATTRS{idVendor}=="d209", ATTRS{idProduct}=="150[0-9]", GROUP="input"
EOF
screen_itgmania_prefs "Options" "LightsDriver" "LinuxPacDrive"
}
screen_machine_shutdown() {
if yesnobox "Perform shutdown when user switch on tty6 (CTRL+ALT+F6)?"; then
run mkdir -p /etc/systemd/system/getty@tty6.service.d \
&& cat << EOF > /etc/systemd/system/getty@tty6.service.d/override.conf \
&& run systemctl daemon-reload
[Service]
ExecStart=
ExecStart=/usr/bin/systemctl poweroff
EOF
else
run rm -rf /etc/systemd/system/getty@tty6.service.d \
&& systemctl daemon-reload
fi
}
# # For usb profiles required
# screen_fstab_validate() {
# local out
# if ! out=$(findmnt --verify); then
# msgbox "/etc/fstab validation failed:\n$out"
# return 1
# fi
# }
# screen_fstab() {
# screen_title="ITG Machine - FSTab"
# local updates
# local fstabroot
# local fstabsongs
# #screen_partition_validate "$root_partition" || return 1
# #screen_partition_validate "$songs_partition" || return 1
# if [[ "$root_partition" != "SKIP" ]]; then
# if fstabroot=$(findmnt -n --fstab -o SOURCE --target /); then
# updates="$updates s|$fstabroot|$root_partition|;"
# else
# msgbox "Installer couldn't detect root in fstab. Running validation.."
# screen_fstab_validate
# fi
# fi
# if [[ "$songs_partition" != "SKIP" ]]; then
# if fstabsongs=$(findmnt -n --fstab -o SOURCE --target /home/itg/.itgmania/Songs); then
# updates="$updates s|$fstabsongs|$songs_partition|;"
# else
# echo "$songs_partition /home/itg/.itgmania/Songs ext4 discard,noatime,nodiratime,errors=remount-ro 0 0" >> /etc/fstab
# screen_fstab_validate
# fi
# fi
# sed -i.bak "$updates" /etc/fstab
# }
# fstab_flash() {
# # todo: songs nofail, usb nofail
# cat << EOF > /tmp/fstab
# /dev/disk/by-path/pci-0000:00:13.2-usb-0:6:1.0-scsi-0:0:0:0-part1 /mnt/P1 auto rw,noatime,noauto,user 0 0
# /dev/disk/by-path/pci-0000:00:13.2-usb-0:6:1.0-scsi-0:0:0:0 /mnt/P1 auto rw,noatime,noauto,user 0 0
# /dev/disk/by-path/pci-0000:00:13.2-usb-0:5:1.0-scsi-0:0:0:0-part1 /mnt/P2 auto rw,noatime,noauto,user 0 0
# /dev/disk/by-path/pci-0000:00:13.2-usb-0:5:1.0-scsi-0:0:0:0 /mnt/P2 auto rw,noatime,noauto,user 0 0
# EOF
# }
screen_system() {
screen_title="ITG Machine - System"
menubox \
screen_network_dhclient "Ad-hoc connect to the network " \
screen_apt_repository "Setup Debian Repository" \
screen_apt_upgrade "Upgrade Debian" \
screen_network_manager "Install Network Manager" \
screen_wifi "Setup WiFi Network (optional)" \
screen_console_tools "Install useful console tools" \
screen_openssh "Install openssh server (optional)" \
screen_vsftpd "Install simple FTP server (vsftpd)" \
screen_uefi "Install kernel to UEFI partition" \
screen_sound_pipewire "Install Pipewire audio system" \
screen_video_intel "Install Intel video drivers (not implemented)" \
screen_video_nvidia "Install NVidia video drivers (not implemented)" \
screen_video_amd "Install AMD video drivers (not implemented)" \
screen_reboot "Reboot after initial setup and upgrade"
}
screen_itgmania() {
screen_title="ITG Machine - ITG Mania"
menubox \
screen_itgmania_user "Select ITGmania user" \
screen_itgmania_dependencies "Install ITGmania runtime dependencies" \
screen_itgmania_install "Install ITGmania" \
screen_itgmania_sddm "Configure SDDM to run ITGMania" \
screen_itgmania_configure "Configure ITGmania" \
screen_itgmania_inputdevices "Configure input device order" \
screen_boogiestats "Configure BoogieStats" \
screen_reboot "Reboot to your new ITG Machine!"
}
screen_tweaks() {
screen_title="ITG Machine - Tweaks"
menubox \
screen_udev_ghettio "Fix ghettio endless reset under Linux" \
screen_pacdrive "Configure Linux PacDrive" \
screen_itgmania_usbprofiles "Configure USB Profiles (TODO)" \
screen_machine_shutdown "Setup machine shutdown"
}
screen_main() {
screen_title="ITG Machine - Main"
menubox \
screen_system "Setup System" \
screen_itgmania "Setup ITG Mania" \
screen_tweaks "Apply miscellaneous tweaks"
}
# TUI is based on whiptail. We must check it manually before anything else
if ! command -v whiptail &> /dev/null; then
echo "whiptail is not available. Graphic install is not possible!"
echo "This should not happen because whiptail has important priority"
echo "and installed automatically with any Debian. Not nice"
# This is not nice: !69=!(0b1000101)=(0b0111010)=58
exit 58
fi
# Only run main flow when executed directly, not when sourced
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
screen_ensure_root
screen_main
fi