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