/ programs / x86_64 / fastcompmgr
fastcompmgr
 1  #!/bin/sh
 2  
 3  # AM INSTALL SCRIPT VERSION 3.5
 4  set -u
 5  APP=fastcompmgr
 6  SITE="tycho-kirchner/fastcompmgr"
 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  chmod a+x ../remove || exit 1
12  
13  # DOWNLOAD AND PREPARE THE APP, $version is also used for updates
14  version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*fastcompmgr$' | head -1)
15  wget "$version" || exit 1
16  cd ..
17  mv ./tmp/"$APP" ./
18  rm -R -f ./tmp || exit 1
19  echo "$version" > ./version
20  chmod a+x ./"$APP" || exit 1
21  
22  # LINK TO PATH
23  ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP"
24  
25  # SCRIPT TO UPDATE THE PROGRAM
26  cat >> ./AM-updater << 'EOF'
27  #!/bin/sh
28  set -u
29  APP=fastcompmgr
30  SITE="tycho-kirchner/fastcompmgr"
31  version0=$(cat "/opt/$APP/version")
32  version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*fastcompmgr$' | head -1)
33  [ -n "$version" ] || { echo "Error getting link"; exit 1; }
34  if [ "$version" != "$version0" ]; then
35  	mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
36  	notify-send "A new version of $APP is available, please wait"
37  	wget "$version" || exit 1
38  	cd ..
39  	mv --backup=t ./tmp/"$APP" ./
40  	chmod a+x ./"$APP" || exit 1
41  	echo "$version" > ./version
42  	rm -R -f ./tmp ./*~
43  	notify-send "$APP is updated!"
44  	exit 0
45  fi
46  echo "Update not needed!"
47  EOF
48  chmod a+x ./AM-updater || exit 1