File: getDriver

package info (click to toggle)
displaylink-driver 6.1-2
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 41,200 kB
  • sloc: sh: 1,219; makefile: 10
file content (87 lines) | stat: -rwxr-xr-x 3,142 bytes parent folder | download
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
#/bin/bash

WGET=/usr/bin/wget
PERL=/usr/bin/perl

if [ ! -f $WGET ]; then
  echo "E: please install package wget: sudo apt install wget"
  exit 1
fi
if [ ! -f $PERL ]; then
  echo "E: please install package perl: sudo apt install perl"
  exit 1
fi

# Get latest versions
versions=$(wget -q -O - https://www.synaptics.com/products/displaylink-graphics/downloads/ubuntu | grep "<p>Release: " | head -n 2 | perl -pe '($_)=/([0-9]+([.][0-9]+)+(\ Beta)*)/; exit if $. > 1;')
# if versions contains "Beta", try to download previous version
if [[ $versions =~ Beta ]]; then
    version=$(wget -q -O - https://www.synaptics.com/products/displaylink-graphics/downloads/ubuntu | grep "<p>Release: " | head -n 2 | perl -pe '($_)=/([0-9]+([.][0-9]+)+(?!\ Beta))/; exit if $. > 1;')
    dlurl="https://www.synaptics.com/$(wget -q -O - https://www.synaptics.com/products/displaylink-graphics/downloads/ubuntu | grep -B 2 $version'-Release' | perl -pe '($_)=/<a href="\/([^"]+)"[^>]+class="download-link"/')"
    driver_url="https://www.synaptics.com/$(wget -q -O - ${dlurl} | grep '<a class="no-link"' | head -n 1 | perl -pe '($_)=/href="\/([^"]+)"/')"
else
    version=`wget -q -O - https://www.synaptics.com/products/displaylink-graphics/downloads/ubuntu | grep "<p>Release: " | head -n 1 | perl -pe '($_)=/([0-9]+([.][0-9]+)+)/; exit if $. > 1;'`
    dlurl="https://www.synaptics.com/$(wget -q -O - https://www.synaptics.com/products/displaylink-graphics/downloads/ubuntu | grep -B 2 $version'-Release' | perl -pe '($_)=/<a href="\/([^"]+)"[^>]+class="download-link"/')"
    driver_url="https://www.synaptics.com/$(wget -q -O - ${dlurl} | grep '<a class="no-link"' | head -n 1 | perl -pe '($_)=/href="\/([^"]+)"/')"
fi
driver_dir=$version

echo "I: driver_url: $driver_url"

packageVersion=${version}
packageName=displaylink-driver
origName=${packageName}_$packageVersion.orig
dlName=DisplayLink_Ubuntu_${version}.zip 

TMPDLDIR=tmp-displaylink
if [ -d $TMPDLDIR ]; then
  echo "E: directory $TMPDLDIR already exists, please remove"
  exit 1
fi
mkdir $TMPDLDIR
cd $TMPDLDIR

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 $dlName "${driver_url}"
        # make sure file is downloaded before continuing
        if [ $? -ne 0 ]; then
           echo -e "\nE: Unable to download Displaylink driver\n"
           exit
        fi
        ;;
  *)
	echo "E: Can't download the driver without accepting the license agreement!"
        exit 1
  ;;
esac

mkdir $origName
mv $dlName $origName
# move other stuff here as well
cd $origName
unzip $dlName
moreInstaller=`find |grep "\.run"`
# extract files
bash $moreInstaller --noexec --keep
# we no longer need that *.run and the zip file
rm $moreInstaller $dlName
cd ..

tar -czf $origName.tar.gz $origName

origTarName=$origName.tar.gz

if [ -f ../../../$origTarName ]; then
  echo "E: a file ../../../$origTarName already exists, please remove it"
  exit 1
fi
cp $origTarName ../../..

cd ..
rm -rf $TMPDLDIR