This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
forked from ferion11/LogosLinuxInstaller
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LogosLinuxInstaller.sh
executable file
·1385 lines (1241 loc) · 50.2 KB
/
LogosLinuxInstaller.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
# shellcheck disable=SC2317
export LOGOS_SCRIPT_TITLE="Logos Linux Installer" # From https://github.com/ferion11/LogosLinuxInstaller
export LOGOS_SCRIPT_AUTHOR="Ferion11, John Goodman, T. H. Wright"
export LOGOS_SCRIPT_VERSION="3.7.5" # Script version for this Installer Script
#####
# Originally written by Ferion11.
# Modified to install Logoos 10 by Revd. John Goodman M0RVJ
# Made script agnostic to Logos and Verbum as well as version; made script functions abstract, added optargs, made CLI first class, general code refactoring by Revd. T. H. Wright
#####
# BEGIN ENVIRONMENT
if [ -z "${WINE64_APPIMAGE_FULL_VERSION}" ]; then WINE64_APPIMAGE_FULL_VERSION="v7.18-staging"; export WINE64_APPIMAGE_FULL_VERSION; fi
if [ -z "${WINE64_APPIMAGE_FULL_URL}" ]; then WINE64_APPIMAGE_FULL_URL="https://github.com/ferion11/LogosLinuxInstaller/releases/download/wine-devel-8.19/wine-devel_8.19-x86_64.AppImage"; export WINE64_APPIMAGE_FULL_URL; fi
if [ -z "${WINE64_APPIMAGE_FULL_FILENAME}" ]; then WINE64_APPIMAGE_FULL_FILENAME="$(basename "${WINE64_APPIMAGE_FULL_URL}")"; export WINE64_APPIMAGE_FULL_FILENAME; fi
if [ -z "${WINE64_APPIMAGE_VERSION}" ]; then WINE64_APPIMAGE_VERSION="v7.18-staging"; export WINE64_APPIMAGE_VERSION; fi
if [ -z "${WINE64_APPIMAGE_URL}" ]; then WINE64_APPIMAGE_URL="https://github.com/ferion11/LogosLinuxInstaller/releases/download/v10.0-1/wine-staging_7.18-x86_64.AppImage"; export WINE64_APPIMAGE_URL; fi
if [ -z "${WINE64_BOTTLE_TARGZ_URL}" ]; then WINE64_BOTTLE_TARGZ_URL="https://github.com/ferion11/wine64_bottle_dotnet/releases/download/v5.11b/wine64_bottle.tar.gz"; export WINE64_BOTTLE_TARGZ_URL; fi
if [ -z "${WINE64_BOTTLE_TARGZ_NAME}" ]; then WINE64_BOTTLE_TARGZ_NAME="wine64_bottle.tar.gz"; export WINE64_BOTTLE_TARGZ_NAME; fi
if [ -z "${WINE64_APPIMAGE_FILENAME}" ]; then WINE64_APPIMAGE_FILENAME="$(basename "${WINE64_APPIMAGE_URL}" .AppImage)"; export WINE64_APPIMAGE_FILENAME; fi
if [ -z "${APPIMAGE_LINK_SELECTION_NAME}" ]; then APPIMAGE_LINK_SELECTION_NAME="selected_wine.AppImage"; export APPIMAGE_LINK_SELECTION_NAME; fi
if [ -z "${WINETRICKS_URL}" ]; then WINETRICKS_URL="https://raw.githubusercontent.com/Winetricks/winetricks/5904ee355e37dff4a3ab37e1573c56cffe6ce223/src/winetricks"; export WINETRICKS_URL; fi
if [ -z "${LAUNCHER_TEMPLATE_URL}" ]; then LAUNCHER_TEMPLATE_URL="https://raw.githubusercontent.com/ferion11/LogosLinuxInstaller/master/Launcher-Template.sh"; export LAUNCHER_TEMPLATE_URL; fi
if [ -z "${CONTROL_PANEL_TEMPLATE_URL}" ]; then CONTROL_PANEL_TEMPLATE_URL="https://raw.githubusercontent.com/ferion11/LogosLinuxInstaller/master/controlPanel-Template.sh"; export CONTROL_PANEL_TEMPLATE_URL; fi
if [ -z "${WINETRICKS_DOWNLOADER+x}" ]; then WINETRICKS_DOWNLOADER="wget" ; export WINETRICKS_DOWNLOADER; fi
if [ -z "${WINETRICKS_UNATTENDED+x}" ]; then WINETRICKS_UNATTENDED="" ; export WINETRICKS_UNATTENDED; fi
if [ -z "${WORKDIR}" ]; then WORKDIR="$(mktemp -d /tmp/LBS.XXXXXXXX)"; export WORKDIR ; fi
if [ -z "${PRESENT_WORKING_DIRECTORY}" ]; then PRESENT_WORKING_DIRECTORY="${PWD}" ; export PRESENT_WORKING_DIRECTORY; fi
if [ -z "${LOGOS_FORCE_ROOT+x}" ]; then export LOGOS_FORCE_ROOT="" ; fi
if [ -z "${WINEBOOT_GUI+x}" ]; then export WINEBOOT_GUI="" ; fi
if [ -z "${EXTRA_INFO}" ]; then EXTRA_INFO="The following packages are usually necessary: winbind cabextract libjpeg8."; export EXTRA_INFO; fi
if [ -z "${DEFAULT_CONFIG_PATH}" ]; then DEFAULT_CONFIG_PATH="${HOME}/.config/Logos_on_Linux/Logos_on_Linux.conf"; export DEFAULT_CONFIG_PATH; fi
if [ -z "${LOGOS_LOG}" ]; then LOGOS_LOG="${HOME}/.local/state/Logos_on_Linux/install.log"; mkdir -p "${HOME}/.local/state/Logos_on_Linux"; touch "${LOGOS_LOG}"; export LOGOS_LOG; fi
if [ -z "${WINEDEBUG}" ]; then WINEDEBUG="fixme-all,err-all"; fi; export WINEDEBUG # Make wine output less verbose
if [ -z "${DEBUG}" ]; then DEBUG="FALSE"; fi; export DEBUG
if [ -z "${VERBOSE}" ]; then VERBOSE="FALSE"; fi; export VERBOSE
# END ENVIRONMENT
# BEGIN FUNCTION DECLARATIONS
usage() {
cat << EOF
$LOGOS_SCRIPT_TITLE, by $LOGOS_SCRIPT_AUTHOR, $LOGOS_SCRIPT_VERSION.
Usage: ./LogosLinuxInstaller.sh
Installs ${FLPRODUCT} Bible Software with Wine on Linux.
Options:
-h --help Prints this help message and exit.
-v --version Prints version information and exit.
-V --verbose Enable extra CLI verbosity.
-D --debug Makes Wine print out additional info.
-c --config Use the Logos on Linux config file when
setting environment variables. Defaults to:
\$HOME/.config/Logos_on_Linux/Logos_on_Linux.conf
Optionally can accept a config file provided by
the user.
-b --custom-binary-path Set a custom path to search for wine binaries
during the install.
-r --regenerate-scripts Regenerates the Logos.sh and controlPanel.sh
scripts using the config file.
-F --skip-fonts Skips installing corefonts and tahoma.
-f --force-root Sets LOGOS_FORCE_ROOT to true, which permits
the root user to run the script.
-k --make-skel Make a skeleton install only.
EOF
}
die-if-running() {
PIDF=/tmp/LogosLinuxInstaller.pid
if [ -f "${PIDF}" ]; then
if logos_continue_question "The script is already running on PID $(cat "${PIDF}"). Should it be killed to allow this instance to run?" "The script is already running. Exiting." "1"; then
kill -9 "$(cat "${PIDF}")"
fi
fi
trap 'rm -f -- "${PIDF}"' EXIT
echo $$ > "${PIDF}"
}
die-if-root() {
if [ "$(id -u)" -eq '0' ] && [ -z "${LOGOS_FORCE_ROOT}" ]; then
logos_error "Running Wine/winetricks as root is highly discouraged. Use -f|--force-root if you must run as root. See https://wiki.winehq.org/FAQ#Should_I_run_Wine_as_root.3F"
fi
}
verbose() { [[ $VERBOSE = true ]] && return 0 || return 1; };
debug() { [[ $DEBUG = true ]] && return 0 || return 1; };
setDebug() {
DEBUG="true";
VERBOSE="true";
WINEDEBUG="";
set -x;
echo "Debug mode enabled." >> "${LOGOS_LOG}";
}
die() { echo >&2 "$*"; exit 1; };
t(){ type "$1"&>/dev/null; };
# Sources:
# https://askubuntu.com/a/1021548/680649
# https://unix.stackexchange.com/a/77138/123999
getDialog() {
if [ -z "${DISPLAY}" ]; then
logos_error "The installer does not work unless you are running a display"
exit 1
fi
DIALOG=""
DIALOG_ESCAPE=""
if [[ -t 0 ]]; then
verbose && echo "Running in terminal."
while :; do
t whiptail && DIALOG=whiptail && break
t dialog && DIALOG=dialog && DIALOG_ESCAPE=-- && export DIALOG_ESCAPE && break
if test "${XDG_CURRENT_DESKTOP}" != "KDE"; then
t zenity && DIALOG=zenity && GUI=true && break
#t kdialog && DIALOG=kdialog && GUI=true && break
elif test "${XDG_CURRENT_DESKTOP}" == "KDE"; then
#t kdialog && DIALOG=kdialog && GUI=true && break
t zenity && DIALOG=zenity && GUI=true && break
else
echo "No dialog program found. Please install either dialog, whiptail, zenity, or kdialog";
fi
done;
else
verbose && echo "Running by double click." >> "${LOGOS_LOG}"
while :; do
if test "${XDG_CURRENT_DESKTOP}" != "KDE"; then
t zenity && DIALOG=zenity && GUI=true && break
#t kdialog && DIALOG=kdialog && GUI=true && break
elif test "${XDG_CURRENT_DESKTOP}" == "KDE"; then
#t kdialog && DIALOG=kdialog && GUI=true && break
t zenity && DIALOG=zenity && GUI=true && break
else
no-diag-msg "No dialog program found. Please install either zenity or kdialog."
fi
done;
fi; export DIALOG; export GUI;
}
have_dep() {
command -v "$1" >/dev/null 2>&1
}
clean_all() {
logos_info "Cleaning all temp files…"
rm -fr "/tmp/LBS.*"
rm -fr "${WORKDIR}"
logos_info "done"
}
light_wineserver_wait() {
${WINESERVER_EXE} -w | logos_progress "Waiting for ${WINE_EXE} to end properly…" "Waiting for ${WINE_EXE} to end properly…"
}
heavy_wineserver_wait() {
wait_process_using_dir "${WINEPREFIX}" | logos_progress "Waiting for ${WINE_EXE} to end properly…" "Waiting for ${WINE_EXE} to end properly…"
"${WINESERVER_EXE}" -w | logos_progress "Waiting for ${WINE_EXE} proper end" "Waiting for ${WINE_EXE} to end properly…"
}
mkdir_critical() {
mkdir "$1" || logos_error "Can't create the $1 directory"
}
## BEGIN DIALOG FUNCTIONS
no-diag-msg() {
echo "${1}" >> "${LOGOS_LOG}";
xterm -hold -e printf "%s\n" "${1}";
die;
}
cli_msg() {
printf "%s\n" "${1}" | sed 's/\\n/\n/g'
}
gtk_info() {
zenity --info --width=300 --height=200 --text="$*" --title='Information'
}
gtk_progress() {
zenity --progress --title="${1}" --text="${2}" --pulsate --auto-close --no-cancel
}
gtk_warn() {
zenity --warning --width=300 --height=200 --text="$*" --title='Warning!'
}
gtk_error() {
zenity --error --width=300 --height=200 --text="$*" --title='Error!'
}
logos_info() {
INFO_MESSAGE="${1}"
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
cli_msg "${INFO_MESSAGE}"
elif [[ "${DIALOG}" == "zenity" ]]; then
gtk_info "${INFO_MESSAGE}";
echo "$(date) ${INFO_MESSAGE}" >> "${LOGOS_LOG}";
elif [[ "${DIALOG}" == "kdialog" ]]; then
:
fi
}
logos_progress() {
PROGRESS_TITLE="${1}"
PROGRESS_TEXT="${2}"
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
cli_msg "${PROGRESS_TEXT}"
elif [[ "${DIALOG}" == "zenity" ]]; then
gtk_progress "${PROGRESS_TITLE}" "${PROGRESS_TEXT}"
elif [[ "${DIALOG}" == "kdialog" ]]; then
:
fi
}
logos_warn() {
WARN_MESSAGE="${1}"
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
cli_msg "${WARN_MESSAGE}"
elif [[ "${DIALOG}" == "zenity" ]]; then
gtk_warn "${WARN_MESSAGE}"
echo "$(date) ${WARN_MESSAGE}" >> "${LOGOS_LOG}";
elif [[ "${DIALOG}" == "kdialog" ]]; then
:
fi
}
logos_error() {
WIKI_LINK="https://github.com/ferion11/LogosLinuxInstaller/wiki"
TELEGRAM_LINK="https://t.me/linux_logos"
MATRIX_LINK="https://matrix.to/#/#logosbible:matrix.org"
ERROR_MESSAGE="${1}"
SECONDARY="${2}"
HELP_MESSAGE="If you need help, please consult:\n\n${WIKI_LINK}\n${TELEGRAM_LINK}\n${MATRIX_LINK}"
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
cli_msg "${ERROR_MESSAGE}\n\n${HELP_MESSAGE}";
elif [[ "${DIALOG}" == "zenity" ]]; then
gtk_error "${ERROR_MESSAGE}\n\n${HELP_MESSAGE}";
echo "$(date) ${ERROR_MESSAGE}" >> "${LOGOS_LOG}";
elif [[ "${DIALOG}" == "kdialog" ]]; then
:
fi
if [ -z "${SECONDARY}" ]; then
rm /tmp/LogosLinuxInstaller.pid
kill -SIGKILL "-$(($(ps -o pgid= -p "${$}")))"
fi
exit 1;
}
cli_question() {
QUESTION_TEXT=${1}
while true; do
read -rp "${QUESTION_TEXT} [Y/n]: " yn
case $yn in
[yY]* ) return 0; break;;
[nN]* ) return 1; break;;
* ) echo "Type Y[es] or N[o].";;
esac
done
}
cli_continue_question() {
QUESTION_TEXT="${1}"
NO_TEXT="${2}"
SECONDARY="${3}"
if ! cli_question "${QUESTION_TEXT}"; then logos_error "${NO_TEXT}" "${SECONDARY}"; fi
}
cli_acknowledge_question() {
QUESTION_TEXT=${1}
NO_TEXT="${2}"
if ! cli_question "${QUESTION_TEXT}"; then logos_info "${NO_TEXT}"; fi
}
gtk_question() {
if zenity --question --width=300 --height=200 --text "$@" --title='Question:'
then return 0
else return 1
fi
}
gtk_continue_question() {
QUESTION_TEXT="${1}"
NO_TEXT="${2}"
SECONDARY="${3}"
if ! gtk_question "${QUESTION_TEXT}"; then logos_error "The installation was cancelled!" "${SECONDARY}"; fi
}
gtk_acknowledge_question() {
QUESTION_TEXT="${1}"
NO_TEXT=${2}
if ! gtk_question "${QUESTION_TEXT}"; then logos_info "${NO_TEXT}"; fi
}
logos_continue_question() {
QUESTION_TEXT="${1}"
NO_TEXT=${2}
SECONDARY="${3}"
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
cli_continue_question "${QUESTION_TEXT}" "${NO_TEXT}" "${SECONDARY}"
elif [[ "${DIALOG}" == "zenity" ]]; then
gtk_continue_question "${QUESTION_TEXT}" "${NO_TEXT}" "${SECONDARY}"
elif [[ "${DIALOG}" == "kdialog" ]]; then
:
fi
}
logos_acknowledge_question() {
QUESTION_TEXT="${1}"
NO_TEXT="${2}"
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
cli_acknowledge_question "${QUESTION_TEXT}" "${NO_TEXT}"
elif [[ "${DIALOG}" == "zenity" ]]; then
gtk_acknowledge_question "${QUESTION_TEXT}" "${NO_TEXT}"
elif [[ "${DIALOG}" == "kdialog" ]]; then
:
fi
}
cli_download() {
# NOTE: here must be a limitation to handle it easily. $2 can be dir if it already exists or if it ends with '/'
URI="${1}"
DESTINATION="${2}"
# extract last field of URI as filename:
FILENAME="${URI##*/}"
if [ "${DESTINATION}" != "${DESTINATION%/}" ]; then
# it has '/' at the end or it is existing directory
TARGET="${DESTINATION}/${1##*/}"
[ -d "${DESTINATION}" ] || mkdir -p "${DESTINATION}" || logos_error "Cannot create ${DESTINATION}"
elif [ -d "${DESTINATION}" ]; then
# it's existing directory
TARGET="${DESTINATION}/${1##*/}"
else
TARGET="${DESTINATION}"
# ensure that the directory where the target file will be exists
[ -d "${DESTINATION%/*}" ] || mkdir -p "${DESTINATION%/*}" || logos_error "Cannot create directory ${DESTINATION%/*}"
fi
wget -c "${URI}" -O "${TARGET}"
}
# shellcheck disable=SC2028
gtk_download() {
# NOTE: here must be a limitation to handle it easily. $2 can be dir if it already exists or if it ends with '/'
URI="${1}"
DESTINATION="${2}"
# extract last field of URI as filename:
FILENAME="${URI##*/}"
if [ "${DESTINATION}" != "${DESTINATION%/}" ]; then
# it has '/' at the end or it is existing directory
TARGET="${DESTINATION}/${1##*/}"
[ -d "${DESTINATION}" ] || mkdir -p "${DESTINATION}" || logos_error "Cannot create ${DESTINATION}"
elif [ -d "${DESTINATION}" ]; then
# it's existing directory
TARGET="${DESTINATION}/${1##*/}"
else
TARGET="${DESTINATION}"
# ensure that the directory where the target file will be exists
[ -d "${DESTINATION%/*}" ] || mkdir -p "${DESTINATION%/*}" || logos_error "Cannot create directory ${DESTINATION%/*}"
fi
pipe_progress="$(mktemp)"
rm -rf "${pipe_progress}"
mkfifo "${pipe_progress}"
pipe_wget="$(mktemp)"
rm -rf "${pipe_wget}"
mkfifo "${pipe_wget}"
# zenity GUI feedback
# NOTE: Abstracting this progress dialog to a function breaks download capabilities due to the pipe.
zenity --progress --title "Downloading ${FILENAME}..." --text="Downloading: ${FILENAME}\ninto: ${DESTINATION}\n" --percentage=0 --auto-close < "${pipe_progress}" &
ZENITY_PID="${!}"
# download the file with wget:
wget -c "${URI}" -O "${TARGET}" > "${pipe_wget}" 2>&1 &
WGET_PID="${!}"
# process the dialog progress bar
total_size="Starting…"
percent="0"
current="Starting…"
speed="Starting…"
remain="Starting…"
while read -r data; do
if echo "${data}" | grep -q '^Length:' ; then
result="$(echo "${data}" | grep "^Length:" | sed 's/.*\((.*)\).*/\1/' | tr -d '()')"
if [ ${#result} -le 10 ]; then total_size=${result} ; fi
fi
if echo "${data}" | grep -q '[0-9]*%' ;then
result="$(echo "${data}" | grep -o "[0-9]*%" | tr -d '%')"
if [ ${#result} -le 3 ]; then percent=${result} ; fi
result="$(echo "${data}" | grep "[0-9]*%" | sed 's/\([0-9BKMG]\+\).*/\1/' )"
if [ ${#result} -le 10 ]; then current=${result} ; fi
result="$(echo "${data}" | grep "[0-9]*%" | sed 's/.*\(% [0-9BKMG.]\+\).*/\1/' | tr -d ' %')"
if [ ${#result} -le 10 ]; then speed=${result} ; fi
result="$(echo "${data}" | grep -o "[0-9A-Za-z]*$" )"
if [ ${#result} -le 10 ]; then remain=${result} ; fi
fi
if [ -z "$(pgrep -P "${$}" zenity)" ]; then
WGET_PID_CURRENT="$(pgrep -P "${$}" wget)"
[ -n "${WGET_PID_CURRENT}" ] && kill -SIGKILL "${WGET_PID_CURRENT}"
fi
[ "${percent}" == "100" ] && break
# Update zenity's progress bar
echo "${percent}"
echo "#Downloading: ${FILENAME}\ninto: ${DESTINATION}\n\n${current} of ${total_size} \(${percent}%\)\nSpeed : ${speed}/Sec\nEstimated time : ${remain}"
done < "${pipe_wget}" > "${pipe_progress}"
wait "${WGET_PID}"
WGET_RETURN="${?}"
wait "${ZENITY_PID}"
ZENITY_RETURN="${?}"
fuser -TERM -k -w "${pipe_progress}"
rm -rf "${pipe_progress}"
fuser -TERM -k -w "${pipe_wget}"
rm -rf "${pipe_wget}"
# NOTE: sometimes the process finishes before the wait command, giving the error code 127
if [ "${ZENITY_RETURN}" == "0" ] || [ "${ZENITY_RETURN}" == "127" ] ; then
if [ "${WGET_RETURN}" != "0" ] && [ "${WGET_RETURN}" != "127" ] ; then
logos_error "ERROR: The installation was cancelled because of an error while attempting a download.\n\nAttmpted Downloading: ${URI}\n\nTarget Destination: ${DESTINATION}\n\n File Name: ${FILENAME}\n\n - Error Code: WGET_RETURN: ${WGET_RETURN}"
fi
else
logos_error "The installation was cancelled!\n * ZENITY_RETURN: ${ZENITY_RETURN}"
fi
verbose && echo "${FILENAME} download finished!"
}
logos_download() {
URI="${1}"
DESTINATION="${2}"
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
cli_download "${URI}" "${DESTINATION}"
elif [[ "${DIALOG}" == "zenity" ]]; then
gtk_download "${URI}" "${DESTINATION}"
elif [[ "${DIALOG}" == "kdialog" ]]; then
no-diag-msg "kdialog not implemented."
else
no-diag-msg "No dialog tool found."
fi
}
logos_reuse_download() {
SOURCEURL="${1}"
FILE="${2}"
TARGETDIR="${3}"
DOWNLOADS="${HOME}/Downloads"
DIRS=(
"${INSTALLDIR}"
"${PRESENT_WORKING_DIRECTORY}"
"${DOWNLOADS}"
)
FOUND=1
for i in "${DIRS[@]}"; do
if [ -f "${i}/${FILE}" ]; then
logos_info "${FILE} exists in ${i}. Using it…"
cp "${i}/${FILE}" "${TARGETDIR}/" | logos_progress "Copying…" "Copying ${FILE}\ninto ${TARGETDIR}"
FOUND=0
break
fi
done
if [[ "${FOUND}" == 1 ]]; then
logos_info "${FILE} does not exist. Downloading…"
logos_download "${SOURCEURL}" "${DOWNLOADS}/${FILE}"
cp "${DOWNLOADS}/${FILE}" "${TARGETDIR}/" | logos_progress "Copying…" "Copying: ${FILE}\ninto: ${TARGETDIR}"
fi
}
## END DIALOG FUNCTIONS
# wait on all processes that are using the ${1} directory to finish
wait_process_using_dir() {
VERIFICATION_DIR="${1}"
VERIFICATION_TIME=7
VERIFICATION_NUM=3
verbose && echo "* Starting wait_process_using_dir…"
i=0 ; while true; do
i=$((i+1))
verbose && echo "wait_process_using_dir: loop with i=${i}"
echo "wait_process_using_dir: sleep ${VERIFICATION_TIME}"
sleep "${VERIFICATION_TIME}"
FIST_PID="$(lsof -t "${VERIFICATION_DIR}" | head -n 1)"
verbose && echo "wait_process_using_dir FIST_PID: ${FIST_PID}"
if [ -n "${FIST_PID}" ]; then
i=0
verbose && echo "wait_process_using_dir: tail --pid=${FIST_PID} -f /dev/null"
tail --pid="${FIST_PID}" -f /dev/null
continue
fi
[ "${i}" -lt "${VERIFICATION_NUM}" ] || break
done
verbose && echo "* End of wait_process_using_dir."
}
make_skel() {
# ${1} - SET_APPIMAGE_FILENAME
export SET_APPIMAGE_FILENAME="${1}"
verbose && echo "* Making skel64 inside ${INSTALLDIR}"
mkdir -p "${INSTALLDIR}"
mkdir "${APPDIR}" || die "can't make dir: ${APPDIR}"
mkdir "${APPDIR_BINDIR}" || die "can't make dir: ${APPDIR_BINDIR}"
# Making the links
cd "${APPDIR_BINDIR}" || die "ERROR: Can't open dir: ${APPDIR_BINDIR}"
ln -s "${SET_APPIMAGE_FILENAME}" "${APPDIR_BINDIR}/${APPIMAGE_LINK_SELECTION_NAME}"
ln -s "${APPIMAGE_LINK_SELECTION_NAME}" wine
ln -s "${APPIMAGE_LINK_SELECTION_NAME}" wine64
ln -s "${APPIMAGE_LINK_SELECTION_NAME}" wineserver
cd - || die "ERROR: Can't go back to preview dir!"
mkdir "${APPDIR}/wine64_bottle"
verbose && echo "skel64 done!"
}
## BEGIN CHECK DEPENDENCIES FUNCTIONS
check_commands() {
for cmd in "$@"; do
if have_dep "${cmd}"; then
verbose && echo "* command ${cmd} is installed!"
else
verbose && echo "* command ${cmd} not installed!"
MISSING_CMD+=("${cmd}")
fi
done
if [ "${#MISSING_CMD[@]}" -ne 0 ]; then
logos_error "Your system is missing ${MISSING_CMD[*]}. Please install your distro's ${MISSING_CMD[*]} package(s).\n ${EXTRA_INFO}"
fi
}
# shellcheck disable=SC2001
check_libs() {
for lib in "$@"; do
HAVE_LIB="$(ldconfig -N -v "$(sed 's/:/ /g' <<< "${LD_LIBRARY_PATH}")" 2>/dev/null | grep "${lib}")"
if [ -n "${HAVE_LIB}" ]; then
verbose && echo "* ${lib} is installed!"
else
logos_error "Your system does not have lib: ${lib}. Please install ${lib} package.\n ${EXTRA_INFO}"
fi
done
}
checkDependencies() {
verbose && echo "Checking system's for dependencies:"
check_commands mktemp patch lsof wget find sed grep ntlm_auth awk tr bc xmllint curl;
}
checkDependenciesLogos10() {
verbose && echo "All dependencies found. Continuing…"
}
checkDependenciesLogos9() {
verbose && echo "Checking dependencies for Logos 9."
check_commands xwd cabextract;
verbose && echo "All dependencies found. Continuing…"
}
## END CHECK DEPENDENCIES FUNCTIONS
## BEGIN INSTALL OPTIONS FUNCTIONS
chooseProduct() {
BACKTITLE="Choose Product Menu"
TITLE="Choose Product"
QUESTION_TEXT="Choose which FaithLife product the script should install:"
if [ -z "${FLPRODUCT}" ]; then
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
productChoice="$($DIALOG --backtitle "${BACKTITLE}" --title "${TITLE}" --radiolist "${QUESTION_TEXT}" 0 0 0 "Logos" "Logos Bible Software." ON "Verbum" "Verbum Bible Software." OFF "Exit" "Exit." OFF 3>&1 1>&2 2>&3 3>&-)"
elif [[ "${DIALOG}" == "zenity" ]]; then
productChoice="$(zenity --width="700" --height="310" --title="${TITLE}" --text="${QUESTION_TEXT}" --list --radiolist --column "S" --column "Description" TRUE "Logos Bible Software." FALSE "Verbum Bible Software." FALSE "Exit.")"
#zenity --width="700" --height="310" --title="${TITLE}" --text="${QUESTION_TEXT}" --list --radiolist --column "S" --column "Description" TRUE "Logos Bible Software." FALSE "Verbum Bible Software." FALSE "Exit."
elif [[ "${DIALOG}" == "kdialog" ]]; then
no-diag-msg "kdialog not implemented."
else
no-diag-msg "No dialog tool found"
fi
else
productChoice="${FLPRODUCT}"
fi
case "${productChoice}" in
"Logos"*)
verbose && echo "Installing Logos Bible Software"
export FLPRODUCT="Logos"
export FLPRODUCTi="logos4" #This is the variable referencing the icon path name in the repo.
;;
"Verbum"*)
verbose && echo "Installing Verbum Bible Software"
export FLPRODUCT="Verbum"
export FLPRODUCTi="verbum" #This is the variable referencing the icon path name in the repo.
export VERBUM_PATH="Verbum/"
;;
"Exit"*)
logos_error "Exiting installation.";;
*)
logos_error "Unknown product. Installation canceled!";;
esac
if [ -z "${LOGOS_ICON_URL}" ]; then export LOGOS_ICON_URL="https://raw.githubusercontent.com/ferion11/LogosLinuxInstaller/master/img/${FLPRODUCTi}-128-icon.png" ; fi
}
chooseVersion() {
BACKTITLE="Choose Version Menu"
TITLE="Choose Product Version"
QUESTION_TEXT="Which version of ${FLPRODUCT} should the script install?"
if [ -z "$TARGETVERSION" ]; then
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
versionChoice="$($DIALOG --backtitle "${BACKTITLE}" --title "${TITLE}" --radiolist "${QUESTION_TEXT}" 0 0 0 "${FLPRODUCT} 10" "10" ON "${FLPRODUCT} 9" "9" OFF "Exit." "Exit." OFF 3>&1 1>&2 2>&3 3>&-)"
elif [[ "${DIALOG}" == "zenity" ]]; then
versionChoice="$(zenity --width="700" --height="310" --title="${TITLE}" --text="${QUESTION_TEXT}" --list --radiolist --column "S" --column "Description" TRUE "${FLPRODUCT} 10" FALSE "${FLPRODUCT} 9" FALSE "Exit")"
elif [[ "${DIALOG}" == "kdialog" ]]; then
no-diag-msg "kdialog not implemented."
else
no-diag-msg "No dialog tool found."
fi
else
versionChoice="$TARGETVERSION"
fi
case "${versionChoice}" in
*"10")
checkDependenciesLogos10;
export TARGETVERSION="10";
;;
*"9")
checkDependenciesLogos9;
export TARGETVERSION="9";
;;
"Exit.")
exit
;;
*)
logos_error "Unknown version. Installation canceled!"
esac
LOGOS_RELEASE_VERSION=$(curl -s "https://clientservices.logos.com/update/v1/feed/logos${TARGETVERSION}/stable.xml" | xmllint --format - | sed -e 's/ xmlns.*=".*"//g' | sed -e 's@logos:minimum-os-version@minimum-os-version@g' | sed -e 's@logos:version@version@g' | xmllint --xpath "/feed/entry[1]/version/text()" -); export LOGOS_RELEASE_VERSION;
if [ -z "${LOGOS64_URL}" ]; then export LOGOS64_URL="https://downloads.logoscdn.com/LBS${TARGETVERSION}/${VERBUM_PATH}Installer/${LOGOS_RELEASE_VERSION}/${FLPRODUCT}-x64.msi" ; fi
if [ "${FLPRODUCT}" = "Logos" ]; then
LOGOS_VERSION="$(echo "${LOGOS64_URL}" | cut -d/ -f6)";
elif [ "${FLPRODUCT}" = "Verbum" ]; then
LOGOS_VERSION="$(echo "${LOGOS64_URL}" | cut -d/ -f7)";
else
logos_error "FLPRODUCT not set in config. Please update your config to specify either 'Logos' or 'Verbum'."
fi
export LOGOS_VERSION;
LOGOS64_MSI="$(basename "${LOGOS64_URL}")"; export LOGOS64_MSI
if [ -z "${INSTALLDIR}" ]; then
export INSTALLDIR="${HOME}/${FLPRODUCT}Bible${TARGETVERSION}" ;
fi
if [ -z "${APPDIR}" ]; then
export APPDIR="${INSTALLDIR}/data"
fi
if [ -z "${APPDIR_BINDIR}" ]; then
export APPDIR_BINDIR="${APPDIR}/bin"
fi
}
wineBinaryVersionCheck() {
# Does not check for Staging. Will not implement: expecting merging of commits in time.
TESTBINARY="${1}"
if [ "${TARGETVERSION}" == "10" ]; then
WINE_MINIMUM="7.18"
elif [ "${TARGETVERSION}" == "9" ]; then
WINE_MINIMUM="7.0"
else
logos_error "TARGETVERSION not set."
fi
# Check if the binary is executable. If so, check if TESTBINARY's version is ≥ WINE_MINIMUM, or if it is Proton or a link to a Proton binary, else remove.
if [ -x "${TESTBINARY}" ]; then
TESTWINEVERSION=$("$TESTBINARY" --version | awk -F' ' '{print $1}' | awk -F'-' '{print $2}' | awk -F'.' '{print $1"."$2}');
if (( $(echo "$TESTWINEVERSION >= $WINE_MINIMUM" | bc -l) )); then
if (( $(echo "$TESTWINEVERSION != 8.0" | bc -l) )); then
return 0;
fi
elif [[ ${TESTBINARY} =~ .*"Proton - Experimental".* ]]; then
return 0;
# If it is a symlink, check its actual path. If it is Proton, let it pass.
elif [ -L "${TESTBINARY}" ]; then
TESTWINE=$(readlink -f "$TESTBINARY")
if [[ "${TESTWINE}" =~ .*"Proton - Experimental".* ]]; then
return 0;
fi
else
return 1;
fi
fi
}
checkPath() {
IFS=:
for dir in $PATH; do
if [ -x "$dir/$1" ]; then
echo "$dir/$1"
fi
done
}
createWineBinaryList() {
logos_info "Creating binary list."
#TODO: Make optarg to add custom path to this array.
WINEBIN_PATH_ARRAY=( "/usr/local/bin" "$HOME/bin" "$HOME/PlayOnLinux/wine/linux-amd64/*/bin" "$HOME/.steam/steam/steamapps/common/Proton - Experimental/files/bin" "${CUSTOMBINPATH}" )
# Temporarily modify PATH for additional WINE64 binaries.
for p in "${WINEBIN_PATH_ARRAY[@]}"; do
if [[ ":$PATH:" != *":${p}:"* ]] && [ -d "${p}" ]; then
PATH="$PATH:${p}"
fi
done
# Check each directory in PATH for wine64; add to list
checkPath wine64 > "${WORKDIR}/winebinaries"
cp "${WORKDIR}/winebinaries" "${WORKDIR}/winebinaries.bak"
# Check remaining binary versions
while read -r i; do
if wineBinaryVersionCheck "$i"; then
# Skip
:
else
sed -i "\@$i@d" "${WORKDIR}/winebinaries"
fi
done < "${WORKDIR}/winebinaries.bak";
}
getAppImage() {
logos_reuse_download "${WINE64_APPIMAGE_FULL_URL}" "${WINE64_APPIMAGE_FULL_FILENAME}" "${APPDIR_BINDIR}"
}
chooseInstallMethod() {
if [ -z "$WINEPREFIX" ]; then
export WINEPREFIX="${APPDIR}/wine64_bottle"
fi
if [ -z "$WINE_EXE" ]; then
createWineBinaryList;
WINEBIN_OPTIONS=()
# Add AppImage to list
if [[ "${TARGETVERSION}" != "9" ]]; then
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
# NOTE: The missing quotations in this array are intentional and accounted for below.
WINEBIN_OPTIONS+=("AppImage ${APPDIR_BINDIR}/${WINE64_APPIMAGE_FULL_FILENAME}" "AppImage of Wine64 ${WINE64_APPIMAGE_FULL_VERSION}" ON)
elif [[ "${DIALOG}" == "zenity" ]]; then
WINEBIN_OPTIONS+=(TRUE "AppImage" "AppImage of Wine64 ${WINE64_APPIMAGE_FULL_VERSION}" "${APPDIR_BINDIR}/${WINE64_APPIMAGE_FULL_FILENAME}")
elif [[ "${DIALOG}" == "kdialog" ]]; then
no-diag-msg "kdialog not implemented."
else
no-diag-msg "No dialog tool found."
fi
fi
while read -r line; do
# Set binary code, description, and path based on path
if [ -L "$line" ]; then
WINEOPT=$(readlink -f "$line")
else
WINEOPT="$line"
fi
if [[ "$WINEOPT" == *"/usr/bin/"* ]]; then
WINEOPT_CODE="System"
WINEOPT_DESCRIPTION="\"Use the system binary (i.e., /usr/bin/wine64). WINE must be 7.18-staging or later. Stable or Devel do not work.\""
WINEOPT_PATH="${line}"
elif [[ "$WINEOPT" == *"Proton"* ]]; then
WINEOPT_CODE="Proton"
WINEOPT_DESCRIPTION="\"Install using the Steam Proton fork of WINE.\""
WINEOPT_PATH="${line}"
elif [[ "$WINEOPT" == *"PlayOnLinux"* ]]; then
WINEOPT_CODE="PlayOnLinux"
WINEOPT_DESCRIPTION="\"Install using a PlayOnLinux WINE64 binary.\""
WINEOPT_PATH="${line}"
else
WINEOPT_CODE="Custom"
WINEOPT_DESCRIPTION="\"Use a WINE64 binary from another directory.\""
WINEOPT_PATH="${line}"
fi
# Create wine binary option array
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
# NOTE: The missing quotations in this array are intentional and accounted for below.
WINEBIN_OPTIONS+=("${WINEOPT_CODE} ${WINEOPT_PATH}" "${WINEOPT_DESCRIPTION}" OFF)
elif [[ "${DIALOG}" == "zenity" ]]; then
WINEBIN_OPTIONS+=(FALSE "${WINEOPT_CODE}" "${WINEOPT_DESCRIPTION}" "${WINEOPT_PATH}")
elif [[ "${DIALOG}" == "kdialog" ]]; then
no-diag-msg "kdialog not implemented."
else
no-diag-msg "No dialog tool found."
fi
done < "${WORKDIR}/winebinaries"
BACKTITLE="Choose Wine Binary Menu"
TITLE="Choose Wine Binary"
QUESTION_TEXT="Which Wine binary and install method should the script use to install ${FLPRODUCT} v${LOGOS_VERSION} in ${INSTALLDIR}?"
WINEBIN_OPTIONS_LENGTH="${#WINEBIN_OPTIONS[@]}"
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
installationChoice=$( $DIALOG --backtitle "${BACKTITLE}" --title "${TITLE}" --radiolist "${QUESTION_TEXT}" 0 0 "${WINEBIN_OPTIONS_LENGTH}" "${WINEBIN_OPTIONS[@]}" 3>&1 1>&2 2>&3 3>&- )
read -r -a installArray <<< "${installationChoice}"
WINEBIN_CODE=$(echo "${installArray[0]}" | awk -F' ' '{print $1}'); export WINEBIN_CODE
WINE_EXE=$(echo "${installArray[0]}" | awk -F' ' '{print $2}'); export WINE_EXE
elif [[ "${DIALOG}" == "zenity" ]]; then
column_names=(--column "Choice" --column "Code" --column "Description" --column "Path")
installationChoice=$(zenity --width=1024 --height=480 \
--title="${TITLE}" \
--text="${QUESTION_TEXT}" \
--list --radiolist "${column_names[@]}" "${WINEBIN_OPTIONS[@]}" --print-column=2,3,4);
OIFS=$IFS
IFS='|' read -r -a installArray <<< "${installationChoice}"
IFS=$OIFS
export WINEBIN_CODE=${installArray[0]}
export WINE_EXE=${installArray[2]}
elif [[ "${DIALOG}" == "kdialog" ]]; then
no-diag-msg "kdialog not implemented."
else
no-diag-msg "No dialog tool found."
fi
fi
verbose && echo "chooseInstallMethod(): WINEBIN_CODE: ${WINEBIN_CODE}; WINE_EXE: ${WINE_EXE}"
}
checkExistingInstall() {
# Now that we know what the user wants to install and where, determine whether an install exists and whether to continue.
if [ -d "${INSTALLDIR}" ]; then
if find "${INSTALLDIR}" -name Logos.exe -o -name Verbum.exe | grep -qE "(Logos\/Logos.exe|Verbum\/Verbum.exe)"; then
EXISTING_LOGOS_INSTALL=1; export EXISTING_LOGOS_INSTALL;
logos_error "An install was found at ${INSTALLDIR}. Please remove/rename it or use another location by setting the INSTALLDIR variable."
else
EXISTING_LOGOS_DIRECTORY=1; export EXISTING_LOGOS_DIRECTORY;
logos_error "A directory exists at ${INSTALLDIR}. Please remove/rename it or use another location by setting the INSTALLDIR variable."
fi
else
verbose && echo "Installing to an empty directory at ${INSTALLDIR}."
fi
}
beginInstall() {
if [ "${SKEL}" = "1" ]; then
verbose && echo "Making a skeleton install of the project only. Exiting after completion."
make_skel "none.AppImage"
exit 0;
fi
if [ -n "${WINEBIN_CODE}" ]; then
case "${WINEBIN_CODE}" in
"AppImage"*)
check_libs libfuse;
verbose && echo "Installing ${FLPRODUCT} Bible ${TARGETVERSION} using ${WINE64_APPIMAGE_FULL_VERSION} AppImage…"
if [ -z "${REGENERATE}" ]; then
make_skel "${WINE64_APPIMAGE_FULL_FILENAME}"
# exporting PATH to internal use if using AppImage, doing backup too:
export OLD_PATH="${PATH}"
export PATH="${APPDIR_BINDIR}":"${PATH}"
# Geting the AppImage:
getAppImage;
chmod +x "${APPDIR_BINDIR}/${WINE64_APPIMAGE_FULL_FILENAME}"
export WINE_EXE="${APPDIR_BINDIR}/wine64"
fi
;;
"System"|"Proton"|"PlayOnLinux"|"Custom")
verbose && echo "Installing ${FLPRODUCT} Bible ${TARGETVERSION} using a ${WINEBIN_CODE} WINE64 binary…"
if [ -z "${REGENERATE}" ]; then
make_skel "none.AppImage"
fi
;;
*)
logos_error "WINEBIN_CODE error. Installation canceled!"
esac
else
verbose && echo "WINEBIN_CODE is not set in your config file."
fi
verbose && echo "Using: $(${WINE_EXE} --version)"
# Set WINESERVER_EXE based on WINE_EXE.
if [ -z "${WINESERVER_EXE}" ]; then
if [ -x "$(dirname "${WINE_EXE}")/wineserver" ]; then
WINESERVER_EXE="$(echo "$(dirname "${WINE_EXE}")/wineserver" | tr -d '\n')"; export WINESERVER_EXE;
else
logos_error "$(dirname "${WINE_EXE}")/wineserver not found. Please either add it or create a symlink to it, and rerun."
fi
fi
}
## END INSTALL OPTIONS FUNCTIONS
## BEGIN WINE BOTTLE AND WINETRICKS FUNCTIONS
prepareWineBottle() {
logos_continue_question "Now the script will create and configure the Wine Bottle at ${WINEPREFIX}. You can cancel the installation of Mono. Do you wish to continue?" "The installation was cancelled!"
verbose && echo "${WINE_EXE} wineboot"
if [ -z "${WINEBOOT_GUI}" ]; then
(DISPLAY="" ${WINE_EXE} wineboot) | logos_progress "Waiting for ${WINE_EXE} wineboot" "Waiting for ${WINE_EXE} wineboot…"
else
${WINE_EXE} wineboot
fi
light_wineserver_wait
}
wine_reg_install() {
REG_FILENAME="${1}"
verbose && echo "${WINE_EXE} regedit.exe ${REG_FILENAME}"
"${WINE_EXE}" regedit.exe "${WORKDIR}"/"${REG_FILENAME}" | logos_progress "Wine regedit" "Wine is installing ${REG_FILENAME} in ${WINEPREFIX}"
light_wineserver_wait
verbose && echo "${WINE_EXE} regedit.exe ${REG_FILENAME} DONE!"
}
downloadWinetricks() {
logos_reuse_download "${WINETRICKS_URL}" "winetricks" "${APPDIR_BINDIR}"
chmod 755 "${APPDIR_BINDIR}/winetricks"
}
setWinetricks() {
# Check if local winetricks version available; else, download it
if [ -z "${WINETRICKSBIN}" ]; then
if [ "$(which winetricks)" ]; then
# Check if local winetricks version is up-to-date; if so, offer to use it or to download; else, download it
LOCAL_WINETRICKS_VERSION=$(winetricks --version | awk -F' ' '{print $1}')
if [ "${LOCAL_WINETRICKS_VERSION}" -ge "20220411" ]; then
BACKTITLE="Choose Winetricks Menu"
TITLE="Choose Winetricks"
QUESTION_TEXT="Should the script use the system's local winetricks or download the latest winetricks from the Internet? The script needs to set some Wine options that ${FLPRODUCT} requires on Linux."
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
winetricksChoice="$($DIALOG --backtitle "${BACKTITLE}" --title "${TITLE}" --radiolist "${QUESTION_TEXT}" 0 0 0 "1" "Use local winetricks." ON "2" "Download winetricks from the Internet." OFF 3>&1 1>&2 2>&3 3>&-)"
elif [[ "${DIALOG}" == "zenity" ]]; then
winetricksChoice="$(zenity --width=700 --height=310 \
--title="${TITLE}" \
--text="${QUESTION_TEXT}" \
--list --radiolist --column "S" --column "Description" \
TRUE "1- Use local winetricks." \
FALSE "2- Download winetricks from the Internet." )"
elif [[ "${DIALOG}" == "kdialog" ]]; then
no-diag-msg "kdialog not implemented."
else
no-diag-msg "No dialog tool found."
fi
case "${winetricksChoice}" in
1*)
verbose && echo "Setting winetricks to the local binary…"
WINETRICKSBIN="$(which winetricks)";
export WINETRICKSBIN;
;;
2*)
downloadWinetricks;
WINETRICKSBIN="${APPDIR_BINDIR}/winetricks";
export WINETRICKSBIN;
;;
*)
logos_error "Installation canceled!"
esac
else
logos_info "The system's winetricks is too old. Downloading an up-to-date winetricks from the Internet…"
downloadWinetricks;
export WINETRICKSBIN="${APPDIR_BINDIR}/winetricks"
fi
else
verbose && echo "Local winetricks not found. Downloading winetricks from the Internet…"
downloadWinetricks;
export WINETRICKSBIN="${APPDIR_BINDIR}/winetricks"
fi
fi
verbose && echo "Winetricks is ready to be used."
}
winetricks_install() {
verbose && echo "winetricks ${*}"
if [[ "${DIALOG}" == "whiptail" ]] || [[ "${DIALOG}" == "dialog" ]]; then
"$WINETRICKSBIN" "${@}"
elif [[ "${DIALOG}" == "zenity" ]]; then
pipe_winetricks="$(mktemp)"
rm -rf "${pipe_winetricks}"
mkfifo "${pipe_winetricks}"
# zenity GUI feedback
logos_progress "Winetricks ${*}" "Winetricks installing ${*}" < "${pipe_winetricks}" &
ZENITY_PID="${!}";
"$WINETRICKSBIN" "${@}" | tee "${pipe_winetricks}";
WINETRICKS_STATUS="${?}";
wait "${ZENITY_PID}";
ZENITY_RETURN="${?}";
rm -rf "${pipe_winetricks}";
# NOTE: sometimes the process finishes before the wait command, giving the error code 127
if [ "${ZENITY_RETURN}" == "0" ] || [ "${ZENITY_RETURN}" == "127" ] ; then
if [ "${WINETRICKS_STATUS}" != "0" ] ; then
${WINESERVER_EXE} -k;
logos_error "Winetricks Install ERROR: The installation was cancelled because of sub-job failure!\n * winetricks ${*}\n - WINETRICKS_STATUS: ${WINETRICKS_STATUS}";
fi
else
"${WINESERVER_EXE}" -k;
logos_error "The installation was cancelled!\n * ZENITY_RETURN: ${ZENITY_RETURN}";
fi
elif [[ "${DIALOG}" == "kdialog" ]]; then
no-diag-msg "kdialog not implemented."