forked from AdnanHodzic/displaylink-debian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
displaylink-debian.sh
executable file
·946 lines (840 loc) · 23.5 KB
/
displaylink-debian.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
#!/bin/bash
#
# displaylink-debian:
# DisplayLink driver installer for Debian and Ubuntu based Linux distributions: Debian, Ubuntu, Elementary OS,
# Mint, Kali, Deepin and more! Full list of all supported platforms: http://bit.ly/2zrwz2u
#
# DisplayLink driver installer for Debian GNU/Linux, Ubuntu, Elementary OS, Mint, Kali, Deepin and more! Full list of all supported Linux distributions
#
# Blog post: http://foolcontrol.org/?p=1777
#
# Copyleft: Adnan Hodzic <[email protected]>
# License: GPLv3
# Bash Strict Mode
set -eu
# set -o pipefail # TODO: Some code still fails this check, fix before enabling.
IFS=$'\n\t'
# define the version to get as the latest available version
version=`wget -q -O - https://www.displaylink.com/downloads/ubuntu | grep "download-version" | head -n 1 | perl -pe '($_)=/([0-9]+([.][0-9]+)+)/'`
# define download url to be the correct version
dlurl="https://www.displaylink.com/"`wget -q -O - https://www.displaylink.com/downloads/ubuntu | grep 'class="download-link"' | head -n 1 | perl -pe '($_)=/<a href="\/([^"]+)"[^>]+class="download-link"/'`
driver_dir=$version
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" && pwd )"
# globalvars
lsb="$(lsb_release -is)"
codename="$(lsb_release -cs)"
platform="$(lsb_release -ics | sed '$!s/$/ /' | tr -d '\n')"
kernel="$(uname -r)"
xorg_config_displaylink="/etc/X11/xorg.conf.d/20-displaylink.conf"
blacklist="/etc/modprobe.d/blacklist.conf"
sys_driver_version="$(ls /usr/src/ | grep "evdi" | cut -d "-" -f2)"
vga_info="$(lspci | grep -oP '(?<=VGA compatible controller: ).*')"
vga_info_3d="$(lspci | grep -i '3d controller' | sed 's/^.*: //')"
graphics_vendor="$(lspci -nnk | grep -i vga -A3 | grep 'in use' | cut -d ':' -f2 | sed 's/ //g')"
graphics_subcard="$(lspci -nnk | grep -i vga -A3 | grep Subsystem | cut -d ' ' -f5)"
providers="$(xrandr --listproviders)"
xorg_vcheck="$(dpkg -l | grep "ii xserver-xorg-core" | awk '{print $3}' | sed 's/[^,:]*://g')"
min_xorg=1.18.3
newgen_xorg=1.19.6
init_script='displaylink.sh'
evdi_modprobe='/etc/modules-load.d/evdi.conf'
kconfig_file="/lib/modules/$kernel/build/Kconfig"
# Using modules-load.d should always be preferred to 'modprobe evdi' in start
# command
separator(){
sep="\n-------------------------------------------------------------------"
echo -e $sep
}
# Wrong key error message
wrong_key(){
echo -e "\n-----------------------------"
echo -e "\nWrong value. Concentrate!\n"
echo -e "-----------------------------\n"
echo -e "Enter any key to continue"
read key
}
root_check(){
# root check
if (( $EUID != 0 ));
then
separator
echo -e "\nMust be run as root (i.e: 'sudo $0')."
separator
exit 1
fi
}
# list all xorg related configs
xconfig_list(){
x11_etc="/etc/X11/"
if [ ! -d "${x11_etc}" ] ; then # No directory found
echo "X11 configs: None"
return 0
fi
count_conf_in_etc=$(find $x11_etc -maxdepth 2 -name "*.conf" | wc -l)
if [ $count_conf_in_etc -gt 0 ]; then
find $x11_etc -type f -name "*.conf" | xargs echo "X11 configs:"
fi
}
# Dependencies
dep_check() {
echo -e "\nChecking dependencies\n"
if [ "$lsb" == "Deepin" ];
then
deps=(unzip linux-headers-$(uname -r) dkms lsb-release linux-source-deepin x11-xserver-utils wget libdrm-dev)
elif [ "$lsb" == "PureOS" ];
then
deps=(unzip linux-headers-$(uname -r) dkms lsb-release linux-source x11-xserver-utils wget libdrm-dev)
else
deps=(unzip linux-headers-$(uname -r) dkms lsb-release linux-source x11-xserver-utils wget libdrm-dev)
fi
for dep in ${deps[@]}
do
if ! dpkg -s $dep | grep "Status: install ok installed" > /dev/null 2>&1
then
default=y
read -p "$dep not found! Install? [Y/n] " response
response=${response:-$default}
if [[ $response =~ ^(yes|y|Y)$ ]]
then
if ! apt-get install $dep
then
echo "$dep installation failed. Aborting."
exit 1
fi
else
separator
echo -e "\nCannot continue without $dep. Aborting."
separator
exit 1
fi
else
echo "$dep is installed"
fi
done
}
distro_check(){
separator
# RedHat
if [ -f /etc/redhat-release ];
then
echo "This is a Redhat based distro ..."
# ToDo:
# Add platform type message for RedHat
exit 1
else
# Confirm dependencies are in place
dep_check
# Unsupported platform message
message(){
echo -e "\n---------------------------------------------------------------\n"
echo -e "Unsuported platform: $platform"
echo -e "Full list of all supported platforms: http://bit.ly/2zrwz2u"
echo -e ""
echo -e "This tool is Open Source and feel free to extend it"
echo -e "GitHub repo: https://github.com/AdnanHodzic/displaylink-debian/"
echo -e "\n---------------------------------------------------------------\n"
}
# Ubuntu
if [ "$lsb" == "Ubuntu" ];
then
if [ $codename == "trusty" ] || [ $codename == "vivid" ] || [ $codename == "wily" ] || [ $codename == "xenial" ] || [ $codename == "yakkety" ] || [ $codename == "zesty" ] || [ $codename == "artful" ] || [ $codename == "bionic" ] || [ $codename == "cosmic" ] || [ $codename == "disco" ] || [ $codename == "eoan" ] || [ $codename == "focal" ];
then
echo -e "\nPlatform requirements satisfied, proceeding ..."
else
message
exit 1
fi
# elementary OS
elif [ "$lsb" == "elementary OS" ] || [ "$lsb" == "elementary" ];
then
if [ $codename == "freya" ] || [ $codename == "loki" ] || [ $codename == "juno" ] || [ $codename == "hera" ];
then
echo -e "\nPlatform requirements satisfied, proceeding ..."
else
message
exit 1
fi
# Debian
elif [ "$lsb" == "Debian" ];
then
if [ $codename == "jessie" ] || [ $codename == "stretch" ] || [ $codename == "buster" ] || [ $codename == "bullseye" ] || [ $codename == "sid" ] || [ $codename == "n/a" ];
then
echo -e "\nPlatform requirements satisfied, proceeding ..."
else
message
exit 1
fi
# Devuan
elif [ "$lsb" == "Devuan" ]
then
if [ "$codename" == "ascii" ]
then
echo -e "\nPlatform requirements satisfied, proceeding ..."
else
message
exit 1
fi
# Mint
elif [ "$lsb" == "LinuxMint" ];
then
if [ $codename == "sarah" ] || [ $codename == "rosa" ] || [ $codename == "petra" ] || [ $codename == "olivia" ] || [ $codename == "serena" ] || [ $codename == "sonya" ] || [ $codename == "sylvia" ] || [ $codename == "tara" ] || [ $codename == "tessa" ] || [ $codename == "betsy" ] || [ $codename == "cindy" ] || [ $codename == "tina" ] || [ $codename == "tricia" ];
then
echo -e "\nPlatform requirements satisfied, proceeding ..."
else
message
exit 1
fi
# Kali
elif [ "$lsb" == "Kali" ];
then
# issue: 204
if [ $codename == "kali-rolling" ] || [ $codename == "2016.2" ] || [ $codename == "2017.3" ] || [ $codename == "2018.3" ] || [ $codename == "2018.4" ] || [ $codename == "n/a" ];
then
echo -e "\nPlatform requirements satisfied, proceeding ..."
else
message
exit 1
fi
# Deepin
elif [ "$lsb" == "Deepin" ];
then
if [ $codename == "unstable" ] || [ $codename == "stable" ];
then
echo -e "\nPlatform requirements satisfied, proceeding ..."
else
message
exit 1
fi
# MX Linux
elif [ "$lsb" == "MX" ];
then
if [ $codename == "Horizon" ] || [ $codename == "Continuum" ];
then
echo -e "\nPlatform requirements satisfied, proceeding ..."
else
message
exit 1
fi
# BunsenLabs
elif [ "$lsb" == "BunsenLabs" ];
then
if [ $codename == "helium" ];
then
echo -e "\nPlatform requirements satisfied, proceeding ..."
else
message
exit 1
fi
# Parrot
elif [ "$lsb" == "Parrot" ];
then
if [ $codename == "n/a" ];
then
echo -e "\nPlatform requirements satisfied, proceeding ..."
else
message
exit 1
fi
elif [ "$lsb" == "PureOS" ];
then
if [ $codename == "amber" ];
then
echo -e "\nPlatform requirements satisfied, proceeding ..."
else
message
exit 1
fi
else
message
exit 1
fi
fi
}
pre_install() {
if [ -f $kconfig_file ];
then
kconfig_exists="true"
else
kconfig_exists="false"
touch $kconfig_file
fi
}
sysinitdaemon_get(){
sysinitdaemon="systemd"
if [ "$lsb" == "Ubuntu" ];
then
if [ $codename == "trusty" ];
then
sysinitdaemon="upstart"
fi
# Elementary
elif [ "$lsb" == "elementary OS" ];
then
if [ $codename == "freya" ];
then
sysinitdaemon="upstart"
fi
elif [ "$lsb" == "Devuan" ]
then
sysinitdaemon="sysvinit"
fi
echo $sysinitdaemon
}
displaylink_service_check () {
sysinitdaemon=$(sysinitdaemon_get)
if [ "$sysinitdaemon" == "systemd" ]
then
systemctl is-active --quiet displaylink-driver.service && \
echo up and running
elif [ "$sysinitdaemon" == "sysvinit" ]
then
/etc/init.d/$init_script status
fi
}
clean_up(){
# remove obsolete/redundant files which can only hamper reinstalls
separator
echo -e "\nPerforming clean-up"
# go back to displaylink-debian
cd - &> /dev/null
if [ -f "DisplayLink_Ubuntu_$version.zip" ]
then
echo "Removing redundant: \"DisplayLink_Ubuntu_$version.zip\" file"
rm "DisplayLink_Ubuntu_$version.zip"
fi
if [ -d $driver_dir ]
then
echo "Removing redundant: \"$driver_dir\" directory"
rm -r $driver_dir
fi
}
setup_complete(){
default=Y
ack=${ack:-$default}
read -p "Reboot now? [Y/n] " ack
ack=${ack:-$default}
for letter in "$ack"; do
if [[ "$letter" == [Yy] ]];
then
echo "Rebooting ..."
reboot
elif [[ "$letter" == [Nn] ]];
then
echo -e "\nReboot postponed, changes won't be applied until reboot"
else
wrong_key
fi
done
}
download() {
local dlfileid=$(echo $dlurl | perl -pe '($_)=/.+\?id=(\d+)/')
default=y
echo -en "\nPlease read the Software License Agreement available at: \n$dlurl\nDo you accept?: [Y/n]: "
read ACCEPT
ACCEPT=${ACCEPT:-$default}
case $ACCEPT in
y*|Y*)
echo -e "\nDownloading DisplayLink Ubuntu driver:\n"
wget -O DisplayLink_Ubuntu_${version}.zip "--post-data=fileId=$dlfileid&accept_submit=Accept" $dlurl
# make sure file is downloaded before continuing
if [ $? -ne 0 ]
then
echo -e "\nUnable to download Displaylink driver\n"
exit
fi
;;
*)
echo "Can't download the driver without accepting the license agreement!"
exit 1
;;
esac
}
install(){
separator
download
# prep
# Check whether prior drivers have been downloaded
if [ -d $driver_dir ]
then
echo "Removing prior: \"$driver_dir\" directory"
rm -r $driver_dir
fi
mkdir $driver_dir
separator
echo -e "\nPreparing for install\n"
test -d $driver_dir && /bin/rm -Rf $driver_dir
unzip -d $driver_dir DisplayLink_Ubuntu_${version}.zip
chmod +x $driver_dir/displaylink-driver-${version}.[0-9]*.run
./$driver_dir/displaylink-driver-${version}.[0-9]*.run --keep --noexec
mv displaylink-driver-${version}.[0-9]*/ $driver_dir/displaylink-driver-${version}
# get sysinitdaemon
sysinitdaemon=$(sysinitdaemon_get)
# modify displaylink-installer.sh
sed -i "s/SYSTEMINITDAEMON=unknown/SYSTEMINITDAEMON=$sysinitdaemon/g" $driver_dir/displaylink-driver-${version}/displaylink-installer.sh
# issue: 227
if [ "$lsb" == "Debian" ] || [ "$lsb" == "Devuan" ] || [ "$lsb" == "Kali" ] || [ "$lsb" == "Deepin" ] || [ "$lsb" == "BunsenLabs" ] || [ "$lsb" == "MX" ];
then
sed -i 's#/lib/modules/$KVER/build/Kconfig#/lib/modules/$KVER/build/scripts/kconfig/conf#g' $driver_dir/displaylink-driver-${version}/displaylink-installer.sh
ln -s /lib/modules/$(uname -r)/build/Makefile /lib/modules/$(uname -r)/build/Kconfig
fi
# install
separator
############################################################
####START of Modifications for EVDI Kernel 5.4 issues ####
############################################################
#Build EVDI from SRC
./evdi.sh
#Replace Broken tgz with new
tgzName=`ls $driver_dir/displaylink-driver-${version}/*.gz | cut -d'/' -f3`
cd ./evdi/module/
tar -czf $tgzName *
cp -f $tgzName ../../$driver_dir/displaylink-driver-${version}/$tgzName
#Replace Broken libs with new compiled ones
cp -f ../library/libevdi.so.1.* ../../$driver_dir/displaylink-driver-${version}/x64-ubuntu-1604/libevdi.so
cp -f ../library/libevdi.so.1.* ../../$driver_dir/displaylink-driver-${version}/x86-ubuntu-1604/libevdi.so
cd ../../
rm -rf evdi/
############################################################
####END of Modifications for EVDI Kernel 5.4 issues ####
############################################################
# run displaylink install
echo -e "\nInstalling driver version: $version\n"
cd $driver_dir/displaylink-driver-${version}
./displaylink-installer.sh install
# udlfb kernel version check
kernel_check="$(uname -r | egrep -o '[0-9]+\.[0-9]+')"
# add udlfb to blacklist (issue #207)
udl_block(){
# if necessary create blacklist.conf
if [ ! -f $blacklist ]; then
touch $blacklist
fi
if ! grep -Fxq "blacklist udlfb" $blacklist
then
echo "Adding udlfb to blacklist"
echo "blacklist udlfb" >> $blacklist
fi
# add udl to blacklist (issue #207)
if ! grep -Fxq "blacklist udl" $blacklist
then
echo "Adding udl to blacklist"
echo "blacklist udl" >> $blacklist
fi
}
# add udl/udlfb to blacklist depending on kernel version (issue #207)
function ver2int {
echo "$@" | awk -F "." '{ printf("%03d%03d%03d\n", $1,$2,$3); }';
}
if [ "$(ver2int $kernel_check)" -ge "$(ver2int '4.14.9')" ];
then
udl_block
fi
}
# post install
post_install(){
separator
echo -e "\nPerforming post install steps\n"
if [ "$kconfig_exists" == "false" ];
then
rm $kconfig_file
fi
# fix: issue #42 (dlm.service can't start)
# note: for this to work libstdc++6 package needs to be installed from >= Stretch
if [ "$lsb" == "Debian" ] || [ "$lsb" == "Devuan" ] || [ "$lsb" == "Kali" ];
then
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /opt/displaylink/libstdc++.so.6
fi
sysinitdaemon=$(sysinitdaemon_get)
if [ "$sysinitdaemon" == "systemd" ]
then
# Fix inability to enable displaylink-driver.service
sed -i "/RestartSec=5/a[Install]\nWantedBy=multi-user.target" /lib/systemd/system/displaylink-driver.service
echo "Enable and start displaylink-driver service"
systemctl enable displaylink-driver.service
systemctl start displaylink-driver.service
elif [ "$sysinitdaemon" == "sysvinit" ]
then
echo "Copying init script to /etc/init.d\n"
cp "$dir/$init_script" /etc/init.d/
chmod +x "/etc/init.d/$init_script"
echo "Load evdi at startup"
cat > "$evdi_modprobe" <<EOF
evdi
EOF
echo "Enable and start displaylink service"
update-rc.d "$init_script" defaults
/etc/init.d/$init_script start
fi
# setup xorg.conf depending on graphics card
modesetting(){
test ! -d /etc/X11/xorg.conf.d && mkdir -p /etc/X11/xorg.conf.d
drv=$(lspci -nnk | grep -i vga -A3 | grep 'in use'|cut -d":" -f2|sed 's/ //g')
drv_nvidia=$(lspci | grep -i '3d controller' | sed 's/^.*: //' | awk '{print $1}')
cardsub=$(lspci -nnk | grep -i vga -A3|grep Subsystem|cut -d" " -f5)
# intel displaylink xorg.conf
xorg_intel(){
cat > $xorg_config_displaylink <<EOL
Section "Device"
Identifier "Intel"
Driver "intel"
EndSection
EOL
}
# modesetting displaylink xorg.conf
xorg_modesetting(){
cat > $xorg_config_displaylink <<EOL
Section "Device"
Identifier "DisplayLink"
Driver "modesetting"
Option "PageFlip" "false"
EndSection
EOL
}
# modesetting displaylink xorg.conf
xorg_modesetting_newgen(){
cat > $xorg_config_displaylink <<EOL
Section "OutputClass"
Identifier "DisplayLink"
MatchDriver "evdi"
Driver "modesetting"
Option "AccelMethod" "none"
EndSection
EOL
}
nvidia_pregame(){
xsetup_loc="/usr/share/sddm/scripts/Xsetup"
nvidia_xrandr(){
cat >> $xsetup_loc << EOL
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
EOL
}
nvidia_xrandr_full(){
cat >> $xsetup_loc << EOL
#!/bin/sh
# Xsetup - run as root before the login dialog appears
if [ -e /sbin/prime-offload ]; then
echo running NVIDIA Prime setup /sbin/prime-offload
/sbin/prime-offload
fi
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
EOL
}
# create Xsetup file if not there + make necessary changes (issue: #201, #206)
if [ ! -f $xsetup_loc ];
then
echo "$xsetup_loc not found, creating"
mkdir -p /usr/share/sddm/scripts/
touch $xsetup_loc
nvidia_xrandr_full
chmod +x $xsetup_loc
echo -e "Wrote changes to $xsetup_loc"
fi
# make necessary changes to Xsetup
if ! grep -q "setprovideroutputsource modesetting" $xsetup_loc
then
mv $xsetup_loc $xsetup_loc.org.bak
echo -e "\nMade backup of: $xsetup_loc file"
echo -e "\nLocation: $xsetup_loc.org.bak"
nvidia_xrandr
chmod +x $xsetup_loc
echo -e "Wrote changes to $xsetup_loc"
fi
# xorg.conf ops
xorg_config="/etc/x11/xorg.conf"
usr_xorg_config_displaylink="/usr/share/X11/xorg.conf.d/20-displaylink.conf"
if [ -f $xorg_config ];
then
mv $xorg_config $xorg_config.org.bak
echo -e "\nMade backup of: $xorg_config file"
echo -e "\nLocation: $xorg_config.org.bak"
fi
if [ -f $xorg_config_displaylink ];
then
mv $xorg_config_displaylink $xorg_config_displaylink.org.bak
echo -e "\nMade backup of: $xorg_config_displaylink file"
echo -e "\nLocation: $xorg_config_displaylink.org.bak"
fi
if [ -f $usr_xorg_config_displaylink ];
then
mv $usr_xorg_config_displaylink $usr_xorg_config_displaylink.org.bak
echo -e "\nMade backup of: $usr_xorg_config_displaylink file"
echo -e "\nLocation: $usr_xorg_config_displaylink.org.bak"
fi
}
# nvidia displaylink xorg.conf (issue: 176)
xorg_nvidia(){
cat > $xorg_config_displaylink <<EOL
Section "ServerLayout"
Identifier "layout"
Screen 0 "nvidia"
Inactive "intel"
EndSection
Section "Device"
Identifier "intel"
Driver "modesetting"
Option "AccelMethod" "None"
EndSection
Section "Screen"
Identifier "intel"
Device "intel"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
Option "ConstrainCursor" "off"
EndSection
Section "Screen"
Identifier "nvidia"
Device "nvidia"
Option "AllowEmptyInitialConfiguration" "on"
Option "IgnoreDisplayDevices" "CRT"
EndSection
EOL
}
# issue: 204, 216
nvidia_hashcat(){
echo "Installing hashcat-nvidia, 'contrib non-free' must be enabled in apt sources"
apt-get install hashcat-nvidia
}
# amd displaylink xorg.conf
xorg_amd(){
cat > $xorg_config_displaylink <<EOL
Section "Device"
Identifier "AMDGPU"
Driver "amdgpu"
Option "PageFlip" "false"
EndSection
EOL
}
# set xorg for Nvidia cards (issue: 176, 179, 211, 217)
if [ "$drv_nvidia" == "NVIDIA" ] || [ "$drv" == "nvidia" ];
then
nvidia_pregame
xorg_nvidia
#nvidia_hashcat
# set xorg for AMD cards (issue: 180)
elif [ "$drv" == "amdgpu" ];
then
xorg_amd
# set xorg for Intel cards
elif [ "$drv" == "i915" ];
then
# set xorg modesetting for Intel cards (issue: 179, 68, 88, 192)
if [ "$cardsub" == "v2/3rd" ] || [ "$cardsub" == "[HD" ] || [ "$cardsub" == "620" ] || [ "$cardsub" == "530" ] || [ "$cardsub" == "540" ] || [ "$cardsub" == "UHD" ];
then
if [ "$(ver2int $xorg_vcheck)" -gt "$(ver2int $newgen_xorg)" ];
then
# reference: issue #200
xorg_modesetting_newgen
else
xorg_modesetting
fi
# generic intel
else
xorg_intel
fi
# default xorg modesetting
else
if [ "$(ver2int $xorg_vcheck)" -gt "$(ver2int $newgen_xorg)" ];
then
# reference: issue #200
xorg_modesetting_newgen
else
xorg_modesetting
fi
fi
echo -e "Wrote X11 changes to: $xorg_config_displaylink"
chown root: $xorg_config_displaylink
chmod 644 $xorg_config_displaylink
}
function ver2int {
echo "$@" | awk -F "." '{ printf("%03d%03d%03d\n", $1,$2,$3); }';
}
# depending on X11 version start modesetting func
if [ "$(ver2int $xorg_vcheck)" -gt "$(ver2int $min_xorg)" ];
then
echo "Setup DisplayLink xorg.conf depending on graphics card"
modesetting
else
echo "No need to disable PageFlip for modesetting"
fi
}
# uninstall
uninstall(){
separator
echo -e "\nUninstalling ...\n"
# displaylink-installer uninstall
if [ "$lsb" == "Debian" ] || [ "$lsb" == "Devuan" ] || [ "$lsb" == "Kali" ] || [ "$lsb" == "Deepin" ] || [ "$lsb" == "BunsenLabs" ];
then
rm /lib/modules/$(uname -r)/build/Kconfig
fi
if [ "$(sysinitdaemon_get)" == "sysvinit" ]
then
update-rc.d "$init_script" remove
rm -f "/etc/init.d/$init_script"
rm -f "$evdi_modprobe"
fi
# run unintsall script
bash /opt/displaylink/displaylink-installer.sh uninstall && 2>&1>/dev/null
# remove modesetting file
if [ -f $xorg_config_displaylink ]
then
echo "Removing Displaylink Xorg config file"
rm $xorg_config_displaylink
fi
# delete udl/udlfb from blacklist (issue #207)
sed -i '/blacklist udlfb/d' $blacklist
sed -i '/blacklist udl/d' $blacklist
}
# debug: get system information for issue debug
debug(){
separator
echo -e "\nStarting Debug ...\n"
default=N
ack=${ack:-$default}
read -p "Did you read Post Installation Guide? http://bit.ly/2TbZleK [y/N] " ack
ack=${ack:-$default}
for letter in "$ack"; do
if [[ "$letter" == [Yy] ]];
then
echo ""
continue
elif [[ "$letter" == [Nn] ]];
then
echo -e "\nPlease read Post Installation Guide: http://bit.ly/2TbZleK\n"
exit 1
else
wrong_key
fi
done
read -p "Did you read Troubleshooting most common issues? http://bit.ly/2Rofd0x [y/N] " ack
ack=${ack:-$default}
for letter in "$ack"; do
if [[ "$letter" == [Yy] ]];
then
echo -e ""
continue
elif [[ "$letter" == [Nn] ]];
then
echo -e "\nPlease read Troubleshooting most common issues: http://bit.ly/2Rofd0x\n"
exit 1
else
wrong_key
fi
done
evdi_version="$(cat /sys/devices/evdi/version)"
echo -e "--------------- Linux system info ----------------\n"
echo -e "Distro: $lsb"
echo -e "Release: $codename"
echo -e "Kernel: $kernel"
echo -e "\n---------------- DisplayLink info ----------------\n"
echo -e "Driver version: $sys_driver_version"
echo -e "DisplayLink service status: $(displaylink_service_check)"
echo -e "EVDI service version: $evdi_version"
echo -e "\n------------------ Graphics card -----------------\n"
echo -e "Vendor: $graphics_vendor"
echo -e "Subsystem: $graphics_subcard"
echo -e "VGA: $vga_info"
echo -e "VGA (3D): $vga_info_3d"
echo -e "X11 version: $xorg_vcheck"
xconfig_list
echo -e "\n-------------- DisplayLink xorg.conf -------------\n"
echo -e "File: $xorg_config_displaylink"
echo -e "Contents:\n $(cat $xorg_config_displaylink)"
echo -e "\n-------------------- Monitors --------------------\n"
echo -e "$providers"
}
# interactively asks for operation
ask_operation(){
echo -e "\n--------------------------- displaylink-debian -------------------------------"
echo -e "\nDisplayLink driver installer for Debian and Ubuntu based Linux distributions:\n"
echo -e "* Debian, Ubuntu, Elementary OS, Mint, Kali, Deepin and many more!"
echo -e "* Full list of all supported platforms: http://bit.ly/2zrwz2u"
echo -e "* When submitting a new issue, include Debug information"
echo -e "\nOptions:\n"
read -p "[I]nstall
[D]ebug
[R]e-install
[U]ninstall
[Q]uit
Select a key: [i/d/r/u/q]: " answer
}
root_check
if [[ "$#" -lt 1 ]];
then
ask_operation
else
case "${1}" in
"--install")
answer="i"
;;
"--uninstall")
answer="u"
;;
"--reinstall")
answer="r"
;;
"--debug")
answer="d"
;;
*)
answer="n"
;;
esac
fi
if [[ $answer == [Ii] ]];
then
distro_check
pre_install
install
post_install
clean_up
separator
echo -e "\nInstall complete, please reboot to apply the changes"
echo -e "After reboot, make sure to consult post-install guide! http://bit.ly/2TbZleK"
setup_complete
separator
echo ""
elif [[ $answer == [Uu] ]];
then
distro_check
uninstall
clean_up
separator
echo -e "\nUninstall complete, please reboot to apply the changes"
setup_complete
separator
echo ""
elif [[ $answer == [Rr] ]];
then
distro_check
uninstall
clean_up
distro_check
install
post_install
clean_up
separator
echo -e "\nInstall complete, please reboot to apply the changes"
echo -e "After reboot, make sure to consult post-install guide! http://bit.ly/2TbZleK"
setup_complete
separator
echo ""
elif [[ $answer == [Dd] ]];
then
debug
separator
echo -e "\nUse this information when submitting an issue (http://bit.ly/2GLDlpY)"
separator
echo ""
elif [[ $answer == [Qq] ]];
then
separator
echo ""
exit 0
else
echo -e "\nWrong key, aborting ...\n"
exit 1
fi