wok view get-anydesk/stuff/get-anydesk @ rev 24042

modified stuff/get-anydesk
author Hans-G?nter Theisgen
date Thu Apr 15 15:26:18 2021 +0100 (2021-04-15)
parents 0bc71e393813
children 0a67bf248823
line source
1 #!/bin/sh
2 #
3 # get-anydesk - create and install SliTaz package anydesk
4 #
5 # (C) 2021 SliTaz - GNU General Public License v3.
6 # Author : HGT
7 # modified by HGT on 2021-04-15
8 #
10 # === Initialisations ===
12 PKGS_DB="/var/lib/tazpkg" # packages database directory
13 PACKAGE="anydesk"
14 CATEGORY="non-free"
15 SHORT=DESC="remote access"
16 MAINTAINER="nobody@slitaz.org"
17 LICENSE="non-free"
18 WEB_SITE="https://anydesk.com/packagename/"
20 # Declare functions check_root, status, ...
21 . /lib/libtaz.sh
22 # and make commandline options (if any) available as variables
24 is_installed()
25 {
26 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
27 then #package is deemed to be installed
28 return 0
29 else
30 return 1
31 fi
32 }
34 # Show commandline options, if requested by --help
35 if [ "$help" == "yes" ]
36 then
37 echo "Commandline options:
38 $0
39 --version=<version>
40 --root=<path-to-root>
41 --install=yes|no
42 --keep=no|yes
43 --tmpdir=<directory-to-build-package>
44 --logfile=<logging-file>"
45 exit
46 fi
48 # Check for system administrator privileges
49 check_root
51 title "Package $PACKAGE will be build as SliTaz package and installed"
53 # Fetch latest version, unless version is set by option --version
54 [ -z "$version" ] && version="latest"
56 # Install SliTaz package, unless inhibited by option --install=no
57 [ -z "$install" ] && install="yes"
59 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
60 # unless option --keep=yes is given
61 [ -z "$keep" ] && keep="no"
63 # Directory for temporary files
64 TMP_DIR="$tmpdir"
65 [ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
67 # Logging file (unused by now)
68 LOG="$logfile"
69 [ -z "$logfile" ] && LOG=$TMP_DIR/get-$PACKAGE.log
71 cat <<EOT
72 Options in use:
73 root : $root/
74 version : $version
75 install package: $install
76 keep tazpkg : $keep
77 build directory: $TMP_DIR
78 logging file : $LOG
80 EOT
82 separator; newline
84 # === Remove package, if installed ===
85 if is_installed
86 then
87 echo "$PACKAGE is already installed."
88 echo -n "Would you like to remove and reinstall this package [y/n]? "
89 read answer
90 case "$answer" in
91 y|Y)
92 action "Removing installed version..."
93 tazpkg remove $PACKAGE --root="$root/"
94 [ ! is_installed ] &&
95 die "Can't remove installed version. Exiting."
96 ;;
97 *)
98 echo "Leaving $PACKAGE untouched."
99 exit 0
100 ;;
101 esac
102 fi
104 # === Fetch Debian package, if not existing ===
105 if [ "$version" == "latest" ]
106 then
107 VERSION="$(wget -q --no-check-certificate -O - https://anydesk.com/en/downloads/linux | \
108 sed -n '/i386.deb">.*Debian.*/p' | sed 's|.*_\(.*\)_.*|\1|' )"
109 if [ -z "$VERSION" ]
110 then
111 echo "Could not determine latest version. Call get-anydesk with version parameter."
112 exit 1
113 else
114 FILE="${PACKAGE}_${VERSION}_i386.deb"
115 WGET_URL="https://download.anydesk.com/linux/$FILE"
116 fi
117 else
118 # for available versions see https://download.anydesk.com/linux/
119 VERSION=$version
120 FILE="${PACKAGE}_${VERSION}_i386.deb"
121 WGET_URL="https://download.anydesk.com/linux/deb/$FILE"
122 fi
124 CUR_DIR=$(pwd)
125 mkdir -p $TMP_DIR
126 cd $TMP_DIR
127 if [ -f $FILE ]
128 then
129 echo "Using existing archive file $FILE"
130 else
131 action "Fetching the archive"
132 newline
133 wget --no-check-certificate $WGET_URL
134 if [ ! -f $FILE ]
135 then
136 cd $CUR_DIR
137 rm -rf $TMP_DIR
138 echo "Could not transfer $FILE from $WGET_URL. Exiting."
139 exit 1
140 fi
141 fi
143 # === Convert Debian package to SliTaz package ===
144 action "Converting the package"
145 newline
147 tazpkg convert $FILE
148 status
149 VERSION=${VERSION%-*}
151 # Remove archive file
152 rm -f $FILE
154 # === Install the SliTaz package ===
155 [ "$install" == "yes" ] &&
156 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
158 # === Cleanup ===
159 # Preserve package file, if requested
160 [ "$keep" == "yes" ] &&
161 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
162 echo "Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR" )
164 # Remove temporary build directory
165 cd $CUR_DIR
166 rm -rf $TMP_DIR