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