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