-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathTICKER-INSTALL.bash
executable file
·2010 lines (1297 loc) · 60.1 KB
/
TICKER-INSTALL.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Copyright 2019-2024 GPLv3, Slideshow Crypto Ticker by Mike Kilday: [email protected] (leave this copyright / attribution intact in ALL forks / copies!)
ISSUES_URL="https://github.com/taoteh1221/Slideshow_Crypto_Ticker/issues"
echo " "
echo "PLEASE REPORT ANY ISSUES HERE: $ISSUES_URL"
echo " "
echo "Initializing, please wait..."
echo " "
######################################
# EXPLICITLY set any dietpi paths
# Export too, in case we are calling another bash instance in this script
if [ -f /boot/dietpi/.version ]; then
PATH=/boot/dietpi:$PATH
export PATH=$PATH
fi
# EXPLICITLY set any ~/.local/bin paths
# Export too, in case we are calling another bash instance in this script
if [ -d ~/.local/bin ]; then
PATH=~/.local/bin:$PATH
export PATH=$PATH
fi
# EXPLICITLY set any /usr/sbin path
# Export too, in case we are calling another bash instance in this script
if [ -d /usr/sbin ]; then
PATH=/usr/sbin:$PATH
export PATH=$PATH
fi
# In case we are recursing back into this script (for filtering params etc),
# flag export of a few more basic sys vars if present
# Authentication of X sessions
export XAUTHORITY=~/.Xauthority
# Working directory
export PWD=$PWD
######################################
# Get date / time
DATE=$(date '+%Y-%m-%d')
TIME=$(date '+%H:%M:%S')
# Current timestamp
CURRENT_TIMESTAMP=$(date +%s)
# Are we running on Ubuntu OS?
IS_UBUNTU=$(cat /etc/os-release | grep "PRETTY_NAME" | grep "Ubuntu")
# Are we already using lightdm, as the display manager?
LIGHTDM_DISPLAY=$(cat /etc/X11/default-display-manager | grep "lightdm")
# If a symlink, get link target for script location
# WE ALWAYS WANT THE FULL PATH!
if [[ -L "$0" ]]; then
SCRIPT_LOCATION=$(readlink "$0")
else
SCRIPT_LOCATION="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/"$(basename "$0")""
fi
# Now set path / file vars, after setting SCRIPT_LOCATION
SCRIPT_PATH="$( cd -- "$(dirname "$SCRIPT_LOCATION")" >/dev/null 2>&1 ; pwd -P )"
SCRIPT_NAME=$(basename "$SCRIPT_LOCATION")
# Parent directory of the script location
PARENT_DIR="$(dirname "$SCRIPT_LOCATION")"
# Get the operating system and version
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
...
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
...
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
VER=$(uname -r)
fi
# For setting user agent header in curl, since some API servers !REQUIRE! a set user agent OR THEY BLOCK YOU
CUSTOM_CURL_USER_AGENT_HEADER="User-Agent: Curl (${OS}/$VER; compatible;)"
######################################
# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
if hash tput > /dev/null 2>&1; then
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
blue=`tput setaf 4`
magenta=`tput setaf 5`
cyan=`tput setaf 6`
reset=`tput sgr0`
else
red=``
green=``
yellow=``
blue=``
magenta=``
cyan=``
reset=``
fi
######################################
# Get logged-in username (if sudo, this works best with logname)
TERMINAL_USERNAME=$(logname)
# If logname doesn't work, use the $SUDO_USER or $USER global var
if [ -z "$TERMINAL_USERNAME" ]; then
if [ -z "$SUDO_USER" ]; then
TERMINAL_USERNAME=$USER
else
TERMINAL_USERNAME=$SUDO_USER
fi
fi
if [ "$EUID" -ne 0 ] || [ "$TERMINAL_USERNAME" == "root" ]; then
echo " "
echo "${red}Please run as a NORMAL USER WITH 'sudo' PERMISSIONS (NOT LOGGED IN AS 'root').${reset}"
echo "${yellow} "
read -n1 -s -r -p $"PRESS ANY KEY to exit..." key
echo "${reset} "
if [ "$key" = 'y' ] || [ "$key" != 'y' ]; then
echo " "
echo "${green}Exiting...${reset}"
echo " "
exit
fi
fi
######################################
if [ -f "/etc/debian_version" ]; then
echo "${cyan}Your system has been detected as Debian-based, which is compatible with this automated script."
# USE 'apt-get' IN SCRIPTING!
# https://askubuntu.com/questions/990823/apt-gives-unstable-cli-interface-warning
PACKAGE_INSTALL="sudo apt-get install"
PACKAGE_REMOVE="sudo apt-get --purge remove"
echo " "
echo "Continuing...${reset}"
echo " "
elif [ -f "/etc/redhat-release" ]; then
echo "${cyan}Your system has been detected as Redhat-based, which is ${red}CURRENTLY STILL IN DEVELOPMENT TO EVENTUALLY BE (BUT IS *NOT* YET) ${cyan}compatible with this automated script."
PACKAGE_INSTALL="sudo yum install"
PACKAGE_REMOVE="sudo yum remove"
echo " "
echo "Continuing...${reset}"
echo " "
else
echo "${red}Your system has been detected as NOT BEING Debian-based OR Redhat-based. Your system is NOT compatible with this automated script."
echo "${yellow} "
read -n1 -s -r -p $"PRESS ANY KEY to exit..." key
echo "${reset} "
if [ "$key" = 'y' ] || [ "$key" != 'y' ]; then
echo " "
echo "${green}Exiting...${reset}"
echo " "
exit
fi
fi
echo "${yellow} "
read -n1 -s -r -p $"PRESS ANY KEY to continue..." key
echo "${reset} "
if [ "$key" = 'y' ] || [ "$key" != 'y' ]; then
echo " "
echo "${green}Continuing...${reset}"
echo " "
fi
echo " "
######################################
# Path to app (CROSS-DISTRO-COMPATIBLE)
get_app_path() {
app_path_result=$(whereis -b $1)
app_path_result="${app_path_result#*$1: }"
app_path_result=${app_path_result%%[[:space:]]*}
app_path_result="${app_path_result#*$1:}"
# If we have found the library already installed on this system
if [ ! -z "$app_path_result" ]; then
PATH_CHECK_REENTRY="" # Reset reentry flag
echo "$app_path_result"
# If we are re-entering from the else statement below, quit trying, with warning sent to terminal (NOT function output)
elif [ ! -z "$PATH_CHECK_REENTRY" ]; then
PATH_CHECK_REENTRY="" # Reset reentry flag
echo "${red} " > /dev/tty
echo "System path for '$1' NOT FOUND, even AFTER package installation attempts, giving up." > /dev/tty
echo " " > /dev/tty
echo "*PLEASE* REPORT THIS ISSUE HERE, *IF THIS SCRIPT FAILS TO RUN PROPERLY FROM THIS POINT ONWARD*:" > /dev/tty
echo " " > /dev/tty
echo "$ISSUES_URL" > /dev/tty
echo "${reset} " > /dev/tty
echo "${yellow} " > /dev/tty
read -n1 -s -r -p $"PRESS ANY KEY to continue..." key
echo "${reset} " > /dev/tty
if [ "$key" = 'y' ] || [ "$key" != 'y' ]; then
echo " " > /dev/tty
echo "${green}Continuing...${reset}" > /dev/tty
echo " " > /dev/tty
fi
echo " " > /dev/tty
# If library not found, attempt package installation
else
# Handle package name exceptions...
# bsdtar on Ubuntu 18.x and higher
if [ "$1" == "bsdtar" ] && [ -f "/etc/debian_version" ]; then
SYS_PACK="libarchive-tools"
# xdg-user-dir (debian package name differs slightly)
elif [ "$1" == "xdg-user-dir" ] && [ -f "/etc/debian_version" ]; then
SYS_PACK="xdg-user-dirs"
# rsyslogd (debian package name differs slightly)
elif [ "$1" == "rsyslogd" ] && [ -f "/etc/debian_version" ]; then
SYS_PACK="rsyslog"
# xorg (debian package name differs)
elif [ "$1" == "xorg" ] && [ -f "/etc/debian_version" ]; then
SYS_PACK="xserver-xorg"
# chromium-browser (debian package name differs)
elif [ "$1" == "chromium-browser" ] && [ -f "/etc/debian_version" ]; then
SYS_PACK="chromium"
# epiphany-browser (debian package name differs)
elif [ "$1" == "epiphany-browser" ] && [ -f "/etc/debian_version" ]; then
SYS_PACK="epiphany"
else
SYS_PACK="$1"
fi
# Terminal alert for good UX...
if [ "$1" != "$SYS_PACK" ]; then
echo " " > /dev/tty
echo "${yellow}'$1' is found WITHIN '$SYS_PACK', changing package request accordingly...${reset}" > /dev/tty
echo " " > /dev/tty
fi
echo " " > /dev/tty
echo "${cyan}Installing required component '$SYS_PACK', please wait...${reset}" > /dev/tty
echo " " > /dev/tty
sleep 3
$PACKAGE_INSTALL $SYS_PACK -y > /dev/tty
# If UBUNTU (*NOT* any other OS) snap was detected on the system, try a snap install too
# (as they moved some libs over to snap / snap-only? now)
if [ ! -z "$UBUNTU_SNAP_PATH" ]; then
UBUNTU_SNAP_INSTALL="sudo $UBUNTU_SNAP_PATH install"
echo " " > /dev/tty
echo "${yellow}CHECKING FOR UBUNTU SNAP PACKAGE '$SYS_PACK', please wait...${reset}" > /dev/tty
echo " " > /dev/tty
sleep 3
$UBUNTU_SNAP_INSTALL $SYS_PACK > /dev/tty
fi
sleep 2
PATH_CHECK_REENTRY=1 # Set reentry flag, right before reentry
echo $(get_app_path "$1")
fi
}
# Ubuntu uses snaps for very basic libraries these days, so we need to configure for possible snap installs
if [ "$IS_UBUNTU" != "" ]; then
UBUNTU_SNAP_PATH=$(get_app_path "snap")
fi
######################################
# Make sure automatic suspend / sleep is disabled
if [ -f "/etc/debian_version" ]; then
echo "${red}We need to make sure your system will NOT AUTO SUSPEND / SLEEP, or your app server could stop running.${reset}"
echo "${yellow} "
read -n1 -s -r -p $"PRESS F to fix this (disables auto suspend / sleep), OR any other key to skip fixing..." key
echo "${reset} "
if [ "$key" = 'f' ] || [ "$key" = 'F' ]; then
echo " "
echo "${cyan}Disabling auto suspend / sleep...${reset}"
echo " "
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target > /dev/null 2>&1
else
echo " "
echo "${green}Skipping...${reset}"
echo " "
fi
elif [ -f "/etc/redhat-release" ]; then
echo "${red}We need to make sure your system will NOT AUTO SUSPEND / SLEEP, or your app server could stop running.${reset}"
echo "${yellow} "
read -n1 -s -r -p $"PRESS F to fix this (disables auto suspend / sleep), OR any other key to skip fixing..." key
echo "${reset} "
if [ "$key" = 'f' ] || [ "$key" = 'F' ]; then
echo " "
echo "${cyan}Disabling auto suspend / sleep...${reset}"
echo " "
sudo -u gdm dbus-run-session gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0 > /dev/null 2>&1
else
echo " "
echo "${green}Skipping...${reset}"
echo " "
fi
fi
######################################
# ON DEBIAN-BASED SYSTEMS ONLY:
# Do we have less than 900MB PHYSICAL RAM (IN KILOBYTES),
# AND no swap / less swap virtual memory than 900MB (IN BYTES)?
if [ -f "/etc/debian_version" ] && [ "$(awk '/MemTotal/ {print $2}' /proc/meminfo)" -lt 900000 ] && (
[ "$(free | awk '/^Swap:/ { print $2 }')" = "0" ] || [ "$(free --bytes | awk '/^Swap:/ { print $2 }')" -lt 900000000 ]
); then
echo "${red}YOU HAVE LESS THAN 900MB *PHYSICAL* MEMORY, AND ALSO HAVE LESS THAN 900MB SWAP *VIRTUAL* MEMORY. This MAY cause your system to FREEZE, *IF* you have a desktop display attached!${reset}"
echo "${yellow} "
read -n1 -s -r -p $"PRESS F to fix this (sets swap virtual memory to 1GB), OR any other key to skip fixing..." key
echo "${reset} "
if [ "$key" = 'f' ] || [ "$key" = 'F' ]; then
echo " "
echo "${cyan}Changing Swap Virtual Memory size to 1GB, please wait (THIS MAY TAKE AWHILE ON SMALLER SYSTEMS)...${reset}"
echo " "
# Required components check...
# dphys-swapfile
DPHYS_PATH=$(get_app_path "dphys-swapfile")
# sed
SED_PATH=$(get_app_path "sed")
sudo $DPHYS_PATH swapoff
sleep 5
if [ -f /etc/dphys-swapfile ]; then
DETECT_SWAP_CONF=$(sudo sed -n '/CONF_SWAPSIZE=/p' /etc/dphys-swapfile)
if [ "$DETECT_SWAP_CONF" != "" ]; then
sudo sed -i "s/CONF_SWAPSIZE=.*/CONF_SWAPSIZE=1024/g" /etc/dphys-swapfile
elif [ "$DETECT_SWAP_CONF" == "" ]; then
sudo bash -c "echo 'CONF_SWAPSIZE=1024' >> /etc/dphys-swapfile"
fi
sudo $DPHYS_PATH setup
sleep 5
sudo $DPHYS_PATH swapon
sleep 5
echo " "
echo "${green}Swap Memory size has been updated to 1GB.${reset}"
echo " "
else
echo " "
echo "${red}Swap Memory config file could NOT be located, skipping update of Swap Memory size!${reset}"
echo " "
fi
else
echo " "
echo "${green}Skipping...${reset}"
echo " "
fi
fi
######################################
# clean_system_update function START
clean_system_update () {
if [ -z "$ALLOW_FULL_UPGRADE" ]; then
echo " "
echo "${yellow}Does the Operating System on this device update using the \"Rolling Release\" model (Kali, Manjaro, Ubuntu Rolling Rhino, Debian Unstable, etc), or the \"Long-Term Release\" model (Debian, Ubuntu, Raspberry Pi OS, Armbian Stable, Diet Pi, etc)?"
echo " "
echo "${red}(You can SEVERLY MESS UP a \"Rolling Release\" Operating System IF YOU DO NOT CHOOSE CORRECTLY HERE! In that case, you can SAFELY choose \"I don't know\".)${reset}"
echo " "
echo "Enter the NUMBER next to your chosen option.${reset}"
echo " "
OPTIONS="rolling long_term i_dont_know"
select opt in $OPTIONS; do
if [ "$opt" = "long_term" ]; then
ALLOW_FULL_UPGRADE="yes"
echo " "
echo "${green}Allowing system-wide updates before installs.${reset}"
break
else
ALLOW_FULL_UPGRADE="no"
echo " "
echo "${green}Disabling system-wide updates before installs.${reset}"
break
fi
done
echo " "
fi
if [ -z "$PACKAGE_CACHE_REFRESHED" ]; then
if [ -f "/etc/debian_version" ]; then
echo "${cyan}Making sure your APT sources list is updated before installations, please wait...${reset}"
echo " "
# In case package list was ever corrupted (since we are about to rebuild it anyway...avoids possible errors)
sudo rm -rf /var/lib/apt/lists/* -vf > /dev/null 2>&1
sleep 2
sudo apt-get update
echo " "
echo "${cyan}APT sources list update complete.${reset}"
echo " "
fi
if [ "$ALLOW_FULL_UPGRADE" == "yes" ]; then
echo "${cyan}Making sure your system is updated before installations, please wait...${reset}"
echo " "
if [ -f "/etc/debian_version" ]; then
#DO NOT RUN dist-upgrade, bad things can happen, lol
sudo apt-get upgrade -y
elif [ -f "/etc/redhat-release" ]; then
sudo yum upgrade -y
fi
sleep 2
echo " "
echo "${cyan}System updated.${reset}"
echo " "
fi
PACKAGE_CACHE_REFRESHED=1
fi
}
# clean_system_update function END
# Clears / updates cache, then upgrades (if NOT a rolling release)
clean_system_update
######################################
# Get PRIMARY dependency lib's paths (for bash scripting commands...auto-install is attempted, if not found on system)
# (our usual standard library prerequisites [ordered alphabetically], for 99% of advanced bash scripting needs)
# avahi-daemon
AVAHID_PATH=$(get_app_path "avahi-daemon")
# bc
BC_PATH=$(get_app_path "bc")
# bsdtar
BSDTAR_PATH=$(get_app_path "bsdtar")
# curl
CURL_PATH=$(get_app_path "curl")
# expect
EXPECT_PATH=$(get_app_path "expect")
# git
GIT_PATH=$(get_app_path "git")
# jq
JQ_PATH=$(get_app_path "jq")
# less
LESS_PATH=$(get_app_path "less")
# lightdm (NEEDED TO BE USED AS THE DISPLAY MANAGER, FOR LXDE / AUTOBOOT)
LIGHTDM_PATH=$(get_app_path "lightdm")
# sed
SED_PATH=$(get_app_path "sed")
# wget
WGET_PATH=$(get_app_path "wget")
# xorg (NEEDED TO BE USED AS THE WINDOW SYSTEM, FOR LXDE / AUTOBOOT)
XORG_PATH=$(get_app_path "xorg")
# PRIMARY dependency lib's paths END
######################################
# Get the *INTERNAL* NETWORK ip address
IP=$(ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p')
######################################
echo " "
echo "${yellow}Enter the system username to configure installation for:"
echo "(leave blank / hit enter for default of username '${TERMINAL_USERNAME}')${reset}"
echo " "
read APP_USER
echo " "
if [ -z "$APP_USER" ]; then
APP_USER=${1:-$TERMINAL_USERNAME}
echo "${green}Using default username: $APP_USER${reset}"
else
echo "${green}Using username: $APP_USER${reset}"
fi
if [ ! -d "/home/$APP_USER/" ]; then
echo " "
echo "${red}Directory /home/$APP_USER/ DOES NOT exist, cannot install Slideshow Crypto Ticker. Please create user $APP_USER's home directory before running this installation.${reset}"
exit
fi
echo " "
######################################
echo "${green}You have set the user information as..."
echo " "
echo "User: $APP_USER"
echo " "
echo "User home directory: /home/$APP_USER/${reset}"
echo " "
echo "${yellow}If this information is NOT correct, please exit installation and start again.${reset}"
echo " "
echo "${yellow} "
read -n1 -s -r -p $"Press Y to continue (or press N to exit)..." key
echo "${reset} "
if [ "$key" = 'y' ] || [ "$key" = 'Y' ]; then
echo " "
echo "${green}Continuing...${reset}"
# If all clear for takeoff, make sure a group exists with same name as user,
# AND user is a member of it (believe it or not, I've seen this not always hold true!)
groupadd -f $APP_USER > /dev/null 2>&1
sleep 3
usermod -a -G $APP_USER $APP_USER > /dev/null 2>&1
echo " "
else
echo " "
echo "${green}Exiting...${reset}"
echo " "
exit
fi
echo " "
######################################
# MIGRATE SAFELY TO NEW APP NAMED DIR (we delete the old one if the user completes installation)
\cp -r /home/$APP_USER/dfd-crypto-ticker /home/$APP_USER/slideshow-crypto-ticker > /dev/null 2>&1
echo "${yellow}TECHNICAL NOTE:"
echo " "
echo "This script was designed to install on popular Debian-based ${green}(STABLE / POLISHED)${yellow} / RedHat-based ${red}(UNSTABLE / WORK-IN-PROGRESS)${yellow} operating systems (Debian, Ubuntu, Raspberry Pi OS [Raspbian], Armbian, DietPi, Fedora, RHEL, CentOS, etc), for small single-board computers WITH SMALL LCD SCREENS TO RUN THE TICKER 24/7 (ALL THE TIME)."
echo " "
echo "It is ONLY recommended to install this ticker app IF your device has an LCD screen installed.${reset}"
echo " "
echo "${yellow}This script MAY NOT work on ALL Debian-based / RedHat-based system setups.${reset}"
echo " "
echo "${cyan}Your operating system has been detected as:"
echo " "
echo "$OS v$VER${reset}"
echo " "
echo "${red}USE A #FULL# DESKTOP SETUP, #NOT# LITE, OR YOU LIKELY WILL HAVE SOME #UNICODE SYMBOL ISSUES# WITH CHROMIUM BROWSER EVEN AFTER UPGRADING TO GUI / CHROME (trust me)."
echo " "
echo "Chromium, Epiphany, and Firefox are supported (firefox is recommended for reliability, all these browsers will be installed if available). IF A BROWSER DOES NOT WORK, PLEASE CHECK MANUALLY THAT IT IS INSTALLED PROPERLY, AND MAKE SURE IT IS NOT CRASHING ON STARTUP!${reset}"
echo " "
echo "${yellow} "
read -n1 -s -r -p $"PRESS ANY KEY to continue..." key
echo "${reset} "
if [ "$key" = 'y' ] || [ "$key" != 'y' ]; then
echo " "
echo "${green}Continuing...${reset}"
echo " "
fi
echo " "
if [ -f /home/$APP_USER/slideshow-crypto-ticker/config.js ]; then
echo "${yellow}A configuration file from a previous install of Slideshow Crypto Ticker has been detected on your system."
echo " "
echo "${green}During this upgrade / re-install, it will be backed up to:"
echo " "
echo "/home/$APP_USER/slideshow-crypto-ticker/config.js.BACKUP.$DATE${reset}"
echo " "
echo "This will save any custom settings within it."
echo " "
echo "You will need to manually move any custom settings in this backup file to the new config.js file with a text editor.${reset}"
echo " "
echo "${red}IF ANYTHING STOPS WORKING AFTER UPGRADING, CLEAR YOUR BROWSER CACHE (temporary files), AND RELOAD OR RESTART THE APP. This will load the latest Javascript / Style Sheet upgrades properly.${reset}"
echo " "
fi
echo "${yellow}PLEASE REPORT ANY ISSUES HERE: $ISSUES_URL${reset}"
echo " "
echo "${yellow} "
read -n1 -s -r -p $"Press Y to continue (or press N to exit)..." key
echo "${reset} "
if [ "$key" = 'y' ] || [ "$key" = 'Y' ]; then
echo " "
echo "${green}Continuing...${reset}"
echo " "
else
echo " "
echo "${green}Exiting...${reset}"
echo " "
exit
fi
echo " "
######################################
# If we are NOT running raspi os, AND lxde desktop IS NOT INSTALLED,
# then we offer the option to install LXDE, AND WE SET THE DISPLAY MANAGER TO LIGHTDM (IF NOT ALREADY SET)
if [ "$LIGHTDM_PATH" != "" ] && [ ! -f /usr/bin/raspi-config ] && [ ! -d /etc/xdg/lxsession ]; then
echo "${red}WE NEED TO MAKE SURE LXDE #AND# LIGHTDM ARE SETUP, IF YOU WANT THE TICKER TO #AUTOMATICALLY RUN ON SYSTEM STARTUP# / REBOOT."
echo " "
echo "CHOOSE \"LIGHTDM\" IF ASKED, FOR \"AUTO-LOGIN AT BOOT\" CAPABILITIES."
echo "(THIS SCRIPT WILL ALSO AUTO-SETUP LIGHTDM, EVEN IF YOU DO NOT GET A PROMPT)${reset}"
echo " "
echo "${yellow}Select 1 or 2 to choose whether to install LXDE Desktop, or skip.${reset}"
echo " "
OPTIONS="setup_lxde skip"
select opt in $OPTIONS; do
if [ "$opt" = "setup_lxde" ]; then
echo " "
echo "${cyan}Installing LXDE desktop and required components, please wait...${reset}"
echo " "
$PACKAGE_INSTALL lxde -y
sleep 3
echo " "
echo "${cyan}LXDE desktop has been installed.${reset}"
echo " "
if [ "$LIGHTDM_DISPLAY" == "" ]; then
# Set lightdm as the new display manager
echo -e "$LIGHTDM_PATH" > /etc/X11/default-display-manager
echo " "
echo "${cyan}'lightdm' has been set as the display manager.${reset}"
echo " "
else
echo " "
echo "${cyan}'lightdm' was already set as the display manager.${reset}"
echo " "
fi
# Enable GUI on boot
systemctl set-default graphical
# Assure lightdm is being used
dpkg-reconfigure lightdm
# Assure a graphical TARGET is set, or system MAY hang on boot
# https://askubuntu.com/questions/74551/lightdm-not-starting-on-boot/939995#939995
rm /etc/systemd/system/default.target
echo " "
systemctl set-default graphical.target
echo " "
break
elif [ "$opt" = "skip" ]; then
echo " "
echo "${green}Skipping LXDE desktop installation...${reset}"
break
fi
done
elif [ "$LIGHTDM_PATH" == "" ]; then
echo "${red}'lightdm' (display manager) could NOT be found or installed. PLEASE INSTALL MANUALLY, OR TRY A DIFFERENT OPERATING SYSTEM (Ubuntu, Debian, RaspberryPi OS, Armbian, etc)."
echo "${yellow} "
read -n1 -s -r -p $"PRESS ANY KEY to exit..." key
echo "${reset} "
if [ "$key" = 'y' ] || [ "$key" != 'y' ]; then
echo " "
echo "${green}Exiting...${reset}"
echo " "
exit
fi
fi
######################################
# SET EARLY (IMMEADIATELY #AFTER# ANY LXDE INSTALL ABOVE), AS WE USE THIS IN A FEW PLACES
# KNOWN raspi LXDE profile
if [ -d /etc/xdg/lxsession/LXDE-pi ]; then
LXDE_PROFILE="LXDE-pi"
# UNKNOWN generic LXDE profile
elif [ -d /etc/xdg/lxsession/LXDE ]; then
# Auto-detect or set to KNOWN LXDE default
# Unfortunately not much documentation on listing LXDE profile names,
# BUT looks fairly reliable to just check in /etc/xdg/lxsession
# (IT SHOULD EXIST ALREADY AT THIS POINT)
LXDE_PROFILE=$(ls /etc/xdg/lxsession)
LXDE_PROFILE=$(echo "${LXDE_PROFILE}" | xargs) # REMOVE any whitespace ON ENDS ONLY
LXDE_PROFILE=$(echo "${LXDE_PROFILE}" | sed "s/LXDE //") # REMOVE "LXDE "
# If LXDE profile var was NOT auto-setup properly
# (contains whitespace MID-VARIABLE or is empty),
# go with KNOWN default from LXDE documentation
if [[ $LXDE_PROFILE =~ " " ]] || [ -z "$LXDE_PROFILE" ]; then
LXDE_PROFILE="LXDE"
LXDE_ALERT=1
fi
else
echo " "
echo "${red}LXDE Desktop NOT detected (please install it, it is REQUIRED to continue).${reset}"
echo "${yellow} "
read -n1 -s -r -p $"PRESS ANY KEY to exit..." key
echo "${reset} "
if [ "$key" = 'y' ] || [ "$key" != 'y' ]; then
echo " "
echo "${green}Exiting...${reset}"
echo " "
exit
fi
fi
######################################
# If LXDE is installed
if [ -d /etc/xdg/lxsession ]; then
echo "${red}WE NEED TO MAKE SURE LXDE #AND# LIGHTDM AUTO-LOGIN AT STARTUP, AS THE USER '${APP_USER}', IF YOU WANT THE TICKER TO #AUTOMATICALLY RUN ON SYSTEM STARTUP# / REBOOT."
echo " "
echo "CHOOSE \"LIGHTDM\" IF ASKED, FOR \"AUTO-LOGIN AT BOOT\" CAPABILITIES.${reset}"
echo " "
echo "${yellow}Select 1 or 2 to choose whether to setup LXDE Desktop auto-login, or skip.${reset}"
echo " "
OPTIONS="autologin_lxde skip"
select opt in $OPTIONS; do
if [ "$opt" = "autologin_lxde" ]; then
echo " "
echo "${cyan}Configuring lightdm auto-login at boot for user '${APP_USER}', please wait...${reset}"
echo " "
# Auto-login LXDE logic...
if [ -d /usr/share/lightdm/lightdm.conf.d ]; then
LIGHTDM_CONF_DIR="/usr/share/lightdm/lightdm.conf.d"
CHECK_LIGHTDM_D=$(ls /usr/share/lightdm/lightdm.conf.d)
CHECK_LIGHTDM_D=$(echo "${CHECK_LIGHTDM_D}" | xargs) # trim whitespace
elif [ -d /etc/lightdm/lightdm.conf.d ]; then
LIGHTDM_CONF_DIR="/etc/lightdm/lightdm.conf.d"
CHECK_LIGHTDM_D=$(ls /etc/lightdm/lightdm.conf.d)
CHECK_LIGHTDM_D=$(echo "${CHECK_LIGHTDM_D}" | xargs) # trim whitespace
else
CHECK_LIGHTDM_D=""
fi
if [ ! -f /etc/lightdm/lightdm.conf ] && [ -z "$CHECK_LIGHTDM_D" ]; then
# Don't nest / indent, or it could malform the settings
read -r -d '' LXDE_AUTO_LOGIN <<- EOF
\r
autologin-user=$APP_USER
user-session=$LXDE_PROFILE
autologin-session=$LXDE_PROFILE
\r
EOF
# Setup LXDE to run at boot