/ programs / x86_64 / bottles
bottles
 1  #!/bin/sh
 2  
 3  # AM INSTALL SCRIPT VERSION 3.5
 4  set -u
 5  APP=bottles
 6  SITE="ivan-hc/Bottles-appimage"
 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 /usr/local/bin/$APP-cli\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://api.github.com/repos/ivan-hc/Bottles-appimage/releases/latest | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386\|i686\|aarch64\|arm64\|armv7l" | head -1)
16  wget "$version" || exit 1
17  # Keep this space in sync with other installation scripts
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  # Keep this space in sync with other installation scripts
22  rm -R -f ./tmp || exit 1
23  echo "$version" > ./version
24  chmod a+x ./"$APP" || exit 1
25  
26  # LINK TO PATH
27  ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP"
28  ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP-cli"
29  
30  # SCRIPT TO UPDATE THE PROGRAM
31  cat >> ./AM-updater << 'EOF'
32  #!/bin/sh
33  set -u
34  APP=bottles
35  SITE="ivan-hc/Bottles-appimage"
36  version0=$(cat "/opt/$APP/version")
37  version=$(curl -Ls https://api.github.com/repos/ivan-hc/Bottles-appimage/releases/latest | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386\|i686\|aarch64\|arm64\|armv7l" | head -1)
38  [ -n "$version" ] || { echo "Error getting link"; exit 1; }
39  if command -v appimageupdatetool >/dev/null 2>&1; then
40  	cd "/opt/$APP" || exit 1
41  	appimageupdatetool -Or ./"$APP" && chmod a+x ./"$APP" && echo "$version" > ./version && exit 0
42  fi
43  if [ "$version" != "$version0" ]; then
44  	mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
45  	notify-send "A new version of $APP is available, please wait"
46  	wget "$version" || exit 1
47  	# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded.
48  	cd ..
49  	mv --backup=t ./tmp/*mage ./"$APP"
50  	chmod a+x ./"$APP" || exit 1
51  	echo "$version" > ./version
52  	rm -R -f ./*zs-old ./*.part ./tmp ./*~
53  	notify-send "$APP is updated!"
54  else
55  	echo "Update not needed!"
56  fi
57  EOF
58  chmod a+x ./AM-updater || exit 1
59  
60  # LAUNCHER & ICON
61  ./"$APP" --appimage-extract *.desktop 1>/dev/null && mv ./squashfs-root/*.desktop ./"$APP".desktop
62  ./"$APP" --appimage-extract .DirIcon 1>/dev/null && mv ./squashfs-root/.DirIcon ./DirIcon
63  COUNT=0
64  while [ "$COUNT" -lt 10 ]; do # Tries to get the actual icon/desktop if it is a symlink to another symlink
65  	if [ -L ./"$APP".desktop ]; then
66  		LINKPATH="$(readlink ./"$APP".desktop | sed 's|^\./||' 2>/dev/null)"
67  		./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop
68  	fi
69  	if [ -L ./DirIcon ]; then
70  		LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)"
71  		./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./DirIcon
72  	fi
73  	[ ! -L ./"$APP".desktop ] && [ ! -L ./DirIcon ] && break
74  	COUNT=$((COUNT + 1))
75  done
76  sed -i "s#Exec=[^ ]*#Exec=$APP#g; s#Icon=.*#Icon=/opt/$APP/icons/$APP#g" ./"$APP".desktop
77  mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null
78  rm -R -f ./squashfs-root