forked from taoteh1221/Slideshow_Crypto_Ticker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTICKER-INSTALL.bash
1430 lines (937 loc) · 41 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 2014-2022 GPLv3, Slideshow Crypto Ticker by Mike Kilday: [email protected]
echo " "
echo "PLEASE REPORT ANY ISSUES HERE: https://github.com/taoteh1221/Slideshow_Crypto_Ticker/issues"
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
######################################
# 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
# Get date / time
DATE=$(date '+%Y-%m-%d')
TIME=$(date '+%H:%M:%S')
# Current timestamp
CURRENT_TIMESTAMP=$(date +%s)
# Get the host ip address
IP=`hostname -I`
# 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")
# 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
######################################
echo " "
if [ "$EUID" -ne 0 ] || [ "$TERMINAL_USERNAME" == "root" ]; then
echo "${red}Please run as a NORMAL USER WITH 'sudo' PERMISSIONS (NOT LOGGED IN AS 'root').${reset}"
echo " "
echo "${cyan}Exiting...${reset}"
echo " "
exit
fi
######################################
# Get primary dependency apps, if we haven't yet
# Install git if needed
GIT_PATH=$(which git)
if [ -z "$GIT_PATH" ]; then
echo " "
echo "${cyan}Installing required component git, please wait...${reset}"
echo " "
sudo apt update
sudo apt install git -y
fi
# Install curl if needed
CURL_PATH=$(which curl)
if [ -z "$CURL_PATH" ]; then
echo " "
echo "${cyan}Installing required component curl, please wait...${reset}"
echo " "
sudo apt update
sudo apt install curl -y
fi
# Install jq if needed
JQ_PATH=$(which jq)
if [ -z "$JQ_PATH" ]; then
echo " "
echo "${cyan}Installing required component jq, please wait...${reset}"
echo " "
sudo apt update
sudo apt install jq -y
fi
# Install wget if needed
WGET_PATH=$(which wget)
if [ -z "$WGET_PATH" ]; then
echo " "
echo "${cyan}Installing required component wget, please wait...${reset}"
echo " "
sudo apt update
sudo apt install wget -y
fi
# Install sed if needed
SED_PATH=$(which sed)
if [ -z "$SED_PATH" ]; then
echo " "
echo "${cyan}Installing required component sed, please wait...${reset}"
echo " "
sudo apt update
sudo apt install sed -y
fi
# Install less if needed
LESS_PATH=$(which less)
if [ -z "$LESS_PATH" ]; then
echo " "
echo "${cyan}Installing required component less, please wait...${reset}"
echo " "
sudo apt update
sudo apt install less -y
fi
# Install expect if needed
EXPECT_PATH=$(which expect)
if [ -z "$EXPECT_PATH" ]; then
echo " "
echo "${cyan}Installing required component expect, please wait...${reset}"
echo " "
sudo apt update
sudo apt install expect -y
fi
# Install avahi-daemon if needed (for .local names on internal / home network)
AVAHID_PATH=$(which avahi-daemon)
if [ -z "$AVAHID_PATH" ]; then
echo " "
echo "${cyan}Installing required component avahi-daemon, please wait...${reset}"
echo " "
sudo apt update
sudo apt install avahi-daemon -y
fi
# Install bc if needed (for decimal math in bash)
BC_PATH=$(which bc)
if [ -z "$BC_PATH" ]; then
echo " "
echo "${cyan}Installing required component bc, please wait...${reset}"
echo " "
sudo apt update
sudo apt install bc -y
fi
# dependency check END
######################################
# Start in user home directory
# WE DON'T USE ~/ FOR PATHS IN THIS SCRIPT BECAUSE:
# 1) WE'RE #RUNNING AS SUDO# ANYWAYS (WE CAN INSTALL ANYWHERE WE WANT)
# 2) WE SET THE USER WE WANT TO INSTALL UNDER DYNAMICALLY
# 3) IN CASE THE USER INITIATES INSTALL AS ANOTHER ADMIN USER
cd /home/$TERMINAL_USERNAME
######################################
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."
echo " "
echo "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}"
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 operating systems (Ubuntu, Raspberry Pi OS [Raspbian], Armbian, DietPi, etc),"
echo "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 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"
echo "AFTER UPGRADING TO GUI / CHROME (trust me)."
echo " "
echo "(Chromium, Epiphany, Firefox, OR Midori are supported [chromium recommended ON LOW POWER DEVICES, all these browsers will be installed if available])${reset}"
echo " "
if [ -f "/etc/debian_version" ]; then
echo "${cyan}Your system has been detected as Debian-based, which is compatible with this automated installation script."
echo " "
echo "Continuing...${reset}"
echo " "
else
echo "${red}Your system has been detected as NOT BEING Debian-based. Your system is NOT compatible with this automated installation script."
echo " "
echo "Exiting...${reset}"
exit
fi
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 " "
fi
echo "PLEASE REPORT ANY ISSUES HERE: https://github.com/taoteh1221/Slideshow_Crypto_Ticker/issues"
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 " "
######################################
# SET EARLY (BUT #AFTER# SETTING $APP_USER VAR), WE USE THIS IN A FEW PLACES
if [ -f /usr/bin/raspi-config ]; then
# KNOWN raspi LXDE profile
LXDE_PROFILE="LXDE-pi"
else
# 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 /home/$APP_USER/.config/lxpanel
# (PRESUMING IT EXISTS ALREADY AT THIS POINT / ONLY ONE PROFILE PER LXDE USER IN USER FILES)
LXDE_PROFILE=$(ls /home/$APP_USER/.config/lxpanel)
LXDE_PROFILE=$(echo "${LXDE_PROFILE}" | xargs) # trim whitespace
# 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
fi
######################################
echo "${cyan}Making sure your system is updated before installation, please wait...${reset}"
echo " "
apt-get update
#DO NOT RUN dist-upgrade, bad things can happen, lol
apt-get upgrade -y
echo " "
echo "${cyan}System update completed.${reset}"
sleep 3
echo " "
# If we are NOT running raspi os, we need the lxde desktop
if [ ! -f /usr/bin/raspi-config ]; then
echo "${red}WE NEED TO MAKE SURE LXDE #AND# LIGHTDM RUN AT STARTUP, AS THE USER '${APP_USER}',"
echo "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, 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 " "
apt install xserver-xorg lightdm lxde -y
sleep 5
echo " "
echo "${cyan}Configuring lightdm auto-login at boot for user '${APP_USER}', please wait...${reset}"
echo " "
# Auto-login LXDE logic...
if [ -d /etc/lightdm/lightdm.conf.d ]; then
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
\r
EOF
# Setup LXDE to run at boot
touch /etc/lightdm/lightdm.conf
echo -e "$LXDE_AUTO_LOGIN" > /etc/lightdm/lightdm.conf
elif [ -f /etc/lightdm/lightdm.conf ]; then
DETECT_AUTOLOGIN=$(sudo sed -n '/autologin-user=/p' /etc/lightdm/lightdm.conf)
if [ "$DETECT_AUTOLOGIN" != "" ]; then
sed -i "s/#autologin-user=.*/autologin-user=${APP_USER}/g" /etc/lightdm/lightdm.conf
sleep 2
sed -i "s/autologin-user=.*/autologin-user=${APP_USER}/g" /etc/lightdm/lightdm.conf
elif [ "$DETECT_AUTOLOGIN" == "" ]; then
sudo bash -c "echo 'autologin-user=${APP_USER}' >> /etc/lightdm/lightdm.conf"
fi
sleep 2
sed -i "s/user-session=.*/user-session=LXDE/g" /etc/lightdm/lightdm.conf
elif [ -n "$CHECK_LIGHTDM_D" ]; then
# Find the PROPER config file in the /lightdm.conf.d/ directory
LIGHTDM_CONFIG_FILE=$(grep -r 'user-session' /etc/lightdm/lightdm.conf.d | awk -F: '{print $1}')
LIGHTDM_CONFIG_FILE=$(echo "${LIGHTDM_CONFIG_FILE}" | xargs) # trim whitespace
DETECT_AUTOLOGIN=$(sudo sed -n '/autologin-user=/p' $LIGHTDM_CONFIG_FILE)
if [ "$DETECT_AUTOLOGIN" != "" ]; then
sed -i "s/#autologin-user=.*/autologin-user=${APP_USER}/g" $LIGHTDM_CONFIG_FILE
sleep 2
sed -i "s/autologin-user=.*/autologin-user=${APP_USER}/g" $LIGHTDM_CONFIG_FILE
elif [ "$DETECT_AUTOLOGIN" == "" ]; then
sudo bash -c "echo 'autologin-user=${APP_USER}' >> ${LIGHTDM_CONFIG_FILE}"
fi
sleep 2
sed -i "s/user-session=.*/user-session=LXDE/g" $LIGHTDM_CONFIG_FILE
else
echo "${cyan}AUTO-LOGIN CONFIGURATION ERROR, AUTO-LOGIN #NOT# SETUP!${reset}"
fi
sleep 2
# Enable GUI on boot
systemctl set-default graphical
echo " "
echo "${cyan}LXDE desktop and required components have been installed and configured.${reset}"
echo " "
# If we are running dietpi OS, WARN USER AN ADDITIONAL STEP #MAY# BE NEEDED
if [ -f /boot/dietpi/.version ]; then
echo "${red}DietPi #SHOULD NOT REQUIRE# USING THE dietpi-autostart UTILITY TO SET LXDE TO AUTO-LOGIN"
echo "AS THE USER '${APP_USER}', SINCE #WE JUST SETUP LXDE AUTO-LOGIN ALREADY#.${reset}"
fi
break
elif [ "$opt" = "skip" ]; then
echo " "
echo "${green}Skipping LXDE desktop setup...${reset}"
break
fi
done
else
echo "${red}THIS TICKER #REQUIRES# RUNNING #LIGHTDM# AND THE DESKTOP INTERFACE #LXDE# AT STARTUP (#already the defaults# in Raspberry Pi OS Desktop),"
echo "AS THE USER '${APP_USER}', IF YOU WANT THE TICKER TO #AUTOMATICALLY RUN ON SYSTEM STARTUP# / REBOOT.${reset}"
fi
echo " "
######################################
echo "Do you want this script to automatically download the latest version of Slideshow Crypto Ticker"
echo "from Github.com, and install it?"
echo " "
echo "(auto-install will overwrite / upgrade any previous install located at: /home/$APP_USER/slideshow-crypto-ticker)"
echo " "
echo "${yellow}Select 1, 2, or 3 to choose whether to auto-install / remove Slideshow Crypto Ticker, or skip.${reset}"
echo " "
OPTIONS="install_ticker_app remove_ticker_app skip"
select opt in $OPTIONS; do
if [ "$opt" = "install_ticker_app" ]; then
echo " "
echo "${cyan}Proceeding with required component installation, please wait...${reset}"
echo " "
# bsdtar installs may fail (essentially the same package as libarchive-tools),
# SO WE RUN BOTH SEPERATELY IN CASE AN ERROR THROWS, SO OTHER PACKAGES INSTALL OK AFTERWARDS
echo "${yellow}(you can safely ignore any upcoming 'bsdtar' install errors, if 'libarchive-tools'"
echo "installs OK...and visa versa, as they are essentially the same package)${reset}"
echo " "
# Ubuntu 16.x, and other debian-based systems
apt-get install bsdtar -y
sleep 1
# Ubuntu 18.x and higher
apt-get install libarchive-tools -y
sleep 1
# midori on raspbian
apt-get install midori -y
sleep 1
# Firefox on raspbian
apt-get install firefox-esr -y
sleep 1
# Firefox on ubuntu, etc
apt-get install firefox -y
sleep 1
# epiphany on raspbian
apt-get install epiphany-browser -y
sleep 1
# Chromium on raspbian
apt-get install chromium-browser -y
sleep 10
# Look for 'epiphany-browser'
EPIPHANY_PATH=$(which epiphany-browser)
# If 'epiphany-browser' NOT found, install epiphany UNLESS THIS IS RASPI OS
if [ -z "$EPIPHANY_PATH" ] && [ ! -f /usr/bin/raspi-config ]; then
# epiphany on ubuntu, etc
apt-get install epiphany -y
sleep 1
fi
# Look for 'chromium-browser'
CHROMIUM_PATH=$(which chromium-browser)
# If 'chromium-browser' NOT found, install chromium UNLESS THIS IS RASPI OS
# ('chromium-browser' IS DEFAULT ON RASPI OS, AND THIS WOULD TRIGGER REPLACING IT WITH A #DOWNGRADED# VERSION)
if [ -z "$CHROMIUM_PATH" ] && [ ! -f /usr/bin/raspi-config ]; then
# Chromium on ubuntu, etc
apt-get install chromium -y
sleep 1
fi
# Grapics card detection support for firefox (for browser GPU acceleration)
apt install libpci-dev -y
sleep 1
# Not sure we need this Mesa 3D Graphics Library / OpenGL stuff, but leave for
# now until we determine why firefox is having issues enabling GPU acceleration
apt install freeglut3-dev -y
sleep 1
apt install libglu1-mesa-dev -y
sleep 1
apt install mesa-utils mesa-common-dev -y
sleep 1
apt install mesa-vulkan-drivers vulkan-icd -y
# Safely install other packages seperately, so they aren't cancelled by 'package missing' errors
apt-get install xdotool unclutter openssl x11-xserver-utils xautomation -y
sleep 5
# FIX FOR 2022-1-28 RASPI OS CHROMIUM BUG (DOES #NOT# FIX SAME ISSUE ON ARMBIAN)
# https://github.com/RPi-Distro/chromium-browser/issues/28
# /etc/chromium.d/ticker-fix-egl CAN BE NAMED ANYTHING, AS LONG AS IT'S IN /etc/chromium.d/
mkdir -p /etc/chromium.d/ > /dev/null 2>&1
sleep 2
CHROMIUM_GL=$(sed -n '/ --use-gl=egl/p' /etc/chromium.d/ticker-fix-egl)
if [ "$CHROMIUM_GL" == "" ]; then
echo " "
echo "${red}EGL not enabled for chromium, enabling it now, please wait...${reset}"
echo " "
# Add EGL config to /etc/chromium.d/ticker-fix-egl
echo 'export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --use-gl=egl"' | tee /etc/chromium.d/ticker-fix-egl
fi
echo " "
echo "${cyan}Required component installation completed.${reset}"
sleep 3
echo " "
if [ -f /home/$APP_USER/slideshow-crypto-ticker/config.js ]; then
\cp /home/$APP_USER/slideshow-crypto-ticker/config.js /home/$APP_USER/slideshow-crypto-ticker/config.js.BACKUP.$DATE
chown $APP_USER:$APP_USER /home/$APP_USER/slideshow-crypto-ticker/config.js.BACKUP.$DATE
CONFIG_BACKUP=1
fi
echo "${cyan}Downloading and installing the latest version of Slideshow Crypto Ticker, from Github.com, please wait...${reset}"
echo " "
mkdir Slideshow-Crypto-Ticker-TEMP
cd Slideshow-Crypto-Ticker-TEMP
ZIP_DL=$(curl -s 'https://api.github.com/repos/taoteh1221/Slideshow_Crypto_Ticker/releases/latest' | jq -r '.zipball_url')
wget -O Slideshow-Crypto-Ticker-TEMP.zip $ZIP_DL
bsdtar --strip-components=1 -xvf Slideshow-Crypto-Ticker-TEMP.zip
rm Slideshow-Crypto-Ticker-TEMP.zip
# Remove depreciated directory structure from any previous installs
rm -rf /home/$APP_USER/slideshow-crypto-ticker/apps > /dev/null 2>&1
rm -rf /home/$APP_USER/slideshow-crypto-ticker/scripts > /dev/null 2>&1
rm -rf /home/$APP_USER/slideshow-crypto-ticker/cache/json > /dev/null 2>&1
rm -rf /home/$APP_USER/slideshow-crypto-ticker/cache/js > /dev/null 2>&1
sleep 1
# Copy over the upgrade install files to the install directory, after cleaning up dev files
# No trailing forward slash here
mkdir -p /home/$APP_USER/slideshow-crypto-ticker
rm -rf .git > /dev/null 2>&1
rm -rf .github > /dev/null 2>&1
rm .gitattributes > /dev/null 2>&1
rm .gitignore > /dev/null 2>&1
rm .whitesource > /dev/null 2>&1
rm CODEOWNERS > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/bash/switch-display.bash > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/bash/ticker-auto-start.bash > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/bash/chromium-refresh.bash > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/bash/chromium.bash > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/bash/epiphany.bash > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/bash/firefox.bash > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/bash/ticker-init.bash > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/bash/cron.bash > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/bash/cron/kucoin-auth.bash > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/bash/cron/raspi-temps.bash > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/js/jquery.min.js > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/js/functions.js > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/js/init.js > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/cache/cache.js > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/cache/raspi_data.js > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/cache/browser.bash > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/ATTRIBUTION-CREDIT-INFO.txt > /dev/null 2>&1
rm /home/$APP_USER/slideshow-crypto-ticker/images/upload-cloud-fill.svg > /dev/null 2>&1
rm /home/$APP_USER/reload > /dev/null 2>&1
\cp -r ./ /home/$APP_USER/slideshow-crypto-ticker
sleep 3
cd ../
rm -rf Slideshow-Crypto-Ticker-TEMP
chmod -R 755 /home/$APP_USER/slideshow-crypto-ticker/bash
# No trailing forward slash here
chown -R $APP_USER:$APP_USER /home/$APP_USER/slideshow-crypto-ticker
# If an older depreciated version, just re-create the symlink after deleting to be safe
rm /home/$APP_USER/ticker-restart > /dev/null 2>&1
sleep 1
ln -s /home/$APP_USER/slideshow-crypto-ticker/bash/ticker-restart.bash /home/$APP_USER/ticker-restart
chown $APP_USER:$APP_USER /home/$APP_USER/ticker-restart
ln -s /home/$APP_USER/slideshow-crypto-ticker/bash/ticker-start.bash /home/$APP_USER/ticker-start
chown $APP_USER:$APP_USER /home/$APP_USER/ticker-start
ln -s /home/$APP_USER/slideshow-crypto-ticker/bash/ticker-stop.bash /home/$APP_USER/ticker-stop
chown $APP_USER:$APP_USER /home/$APP_USER/ticker-stop
echo " "
echo "${green}Slideshow Crypto Ticker has been installed.${reset}"
INSTALL_SETUP=1
break
elif [ "$opt" = "remove_ticker_app" ]; then
echo " "
echo "${cyan}Removing Slideshow Crypto Ticker and some required components, please wait...${reset}"
echo " "
# ONLY removing unclutter, AS WE DON'T WANT TO F!CK UP THE WHOLE SYSTEM, REMOVING ANY OTHER ALREADY-USED / DEPENDANT PACKAGES TOO!!
apt-get remove unclutter -y
echo " "
echo "${cyan}Removal of 'unclutter' app package completed, please wait...${reset}"
echo " "
echo "${yellow}(IF YOU USED unclutter FOR ANOTHER APP, RE-INSTALL WITH: sudo apt-get install unclutter)${reset}"
echo " "
sleep 3
# Remove ticker autostart line in LXDE autotart file
sed -i "/slideshow-crypto-ticker/d" /home/$APP_USER/.config/lxsession/$LXDE_PROFILE/autostart
# Remove any #OLD# ticker autostart systemd service (which we no longer use)
rm /lib/systemd/system/ticker.service > /dev/null 2>&1
rm /etc/cron.d/ticker > /dev/null 2>&1
rm /home/$APP_USER/ticker-restart > /dev/null 2>&1
rm /home/$APP_USER/ticker-start > /dev/null 2>&1
rm /home/$APP_USER/ticker-stop > /dev/null 2>&1
rm -rf /home/$APP_USER/slideshow-crypto-ticker > /dev/null 2>&1
sleep 3
echo " "
echo "${green}Slideshow Crypto Ticker has been removed from the system, PLEASE REBOOT to complete the removal process.${reset}"
break
elif [ "$opt" = "skip" ]; then
echo " "
echo "${green}Skipping auto-install of Slideshow Crypto Ticker.${reset}"
break
fi
done
echo " "
######################################
# REMOVE OLD DIRECTORY LOCATION (if we got this far in this script, new location is now the live install)
rm -rf /home/$APP_USER/dfd-crypto-ticker > /dev/null 2>&1
echo "Do you want to automatically configure Slideshow Crypto Ticker for your system (autostart at login / keep screen turned on)?"
echo " "
echo "${yellow}Select 1 or 2 to choose whether to auto-configure Slideshow Crypto Ticker system settings, or skip it.${reset}"
echo " "
OPTIONS="auto_config_ticker_system skip"
select opt in $OPTIONS; do
if [ "$opt" = "auto_config_ticker_system" ]; then
echo " "
echo "${yellow}Select the NUMBER next to the browser you want to use to render the ticker (chromium recommended ON LOW POWER DEVICES).${reset}"
echo " "
if [ -f /usr/bin/raspi-config ]; then
echo "${red}IT'S #HIGHLY RECOMMENDED# TO CHOOSE CHROMIUM ON A LOW POWER RASPBERRY PI DEVICE (FOR GRAPHICS ACCELERATION BENEFITS).${reset}"
echo " "
fi
USER_BROWSER="chromium epiphany firefox midori"
select opt in $USER_BROWSER; do
if [ "$opt" = "chromium" ]; then
SET_BROWSER=$opt
break
elif [ "$opt" = "epiphany" ]; then
SET_BROWSER=$opt
break
elif [ "$opt" = "firefox" ]; then
SET_BROWSER=$opt
break
elif [ "$opt" = "midori" ]; then
SET_BROWSER=$opt
break
fi
done
echo " "
echo "${green}Using $SET_BROWSER as the default ticker browser...${reset}"
echo " "
echo " "
echo "${cyan}Configuring Slideshow Crypto Ticker on your system, please wait...${reset}"
echo " "
# Create cache directory if it doesn't exist yet