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