/ programs / x86_64 / es-de
es-de
 1  #!/bin/sh
 2  
 3  # AM INSTALL SCRIPT VERSION 3.5
 4  set -u
 5  APP=es-de
 6  SITE="https://es-de.org"
 7  
 8  # CREATE DIRECTORIES AND ADD REMOVER
 9  [ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 1
10  printf "#!/bin/sh\nset -e\nrm -f /usr/local/bin/$APP\nrm -R -f /opt/$APP" > ../remove
11  printf '\n%s' "rm -f /usr/local/share/applications/$APP-AM.desktop" >> ../remove
12  chmod a+x ../remove || exit 1
13  
14  # DOWNLOAD AND PREPARE THE APP, $version is also used for updates
15  version=$(curl -Ls https://gitlab.com/api/v4/projects/18817634/releases/ | tr '?,>< ' '\n' | grep -i "tag_name" | head -1 | tr '"' '\n' | grep [0-9])
16  wget "$(curl -Ls https://gitlab.com/api/v4/projects/18817634/releases/ | tr '?><{} ' '\n' | grep -i "appimage.*download" | head -1 | tr '"' '\n' | grep "^http.*download$" | head -1)" -O ES-DE.AppImage || exit 1
17  #wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync
18  # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded.
19  cd ..
20  mv ./tmp/*mage ./"$APP"
21  rm -R -f ./tmp || exit 1
22  echo "$version" > ./version
23  chmod a+x ./"$APP" || exit 1
24  
25  # LINK TO PATH
26  ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP"
27  
28  # SCRIPT TO UPDATE THE PROGRAM
29  cat >> ./AM-updater << 'EOF'
30  #!/bin/sh
31  set -u
32  APP=es-de
33  SITE="https://es-de.org"
34  version0=$(cat "/opt/$APP/version")
35  version=$(curl -Ls https://gitlab.com/api/v4/projects/18817634/releases/ | tr '?,>< ' '\n' | grep -i "tag_name" | head -1 | tr '"' '\n' | grep [0-9])
36  [ -n "$version" ] || { echo "Error getting link"; exit 1; }
37  if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then
38  	mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
39  	notify-send "A new version of $APP is available, please wait"
40  	wget "$(curl -Ls https://gitlab.com/api/v4/projects/18817634/releases/ | tr '?><{} ' '\n' | grep -i "appimage.*download" | head -1 | tr '"' '\n' | grep "^http.*download$" | head -1)" || exit 1
41  	# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded.
42  	cd ..
43  	mv --backup=t ./tmp/*mage ./"$APP"
44  	chmod a+x ./"$APP" || exit 1
45  	echo "$version" > ./version
46  	rm -R -f ./*zs-old ./*.part ./tmp ./*~
47  	notify-send "$APP is updated!"
48  else
49  	echo "Update not needed!"
50  fi
51  EOF
52  chmod a+x ./AM-updater || exit 1
53  
54  # LAUNCHER & ICON
55  ./"$APP" --appimage-extract *.desktop 1>/dev/null && mv ./squashfs-root/*.desktop ./"$APP".desktop
56  ./"$APP" --appimage-extract .DirIcon 1>/dev/null && mv ./squashfs-root/.DirIcon ./DirIcon
57  COUNT=0
58  while [ "$COUNT" -lt 10 ]; do # Tries to get the actual icon/desktop if it is a symlink to another symlink
59  	if [ -L ./"$APP".desktop ]; then
60  		LINKPATH="$(readlink ./"$APP".desktop | sed 's|^\./||' 2>/dev/null)"
61  		./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop
62  	fi
63  	if [ -L ./DirIcon ]; then
64  		LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)"
65  		./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./DirIcon
66  	fi
67  	[ ! -L ./"$APP".desktop ] && [ ! -L ./DirIcon ] && break
68  	COUNT=$((COUNT + 1))
69  done
70  sed -i "s#Exec=[^ ]*#Exec=$APP#g; s#Icon=.*#Icon=/opt/$APP/icons/$APP#g" ./"$APP".desktop
71  mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null
72  rm -R -f ./squashfs-root