/ programs / x86_64 / multimc
multimc
 1  #!/bin/sh
 2  
 3  # AM INSTALL SCRIPT VERSION 3.5
 4  set -u
 5  APP=multimc
 6  SITE="https://multimc.org/#Download"
 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=$(wget -q "$SITE" -O - | sed 's/[()",{} ]/\n/g' | grep -oi 'https.*mmc.*lin64.*gz$' | head -1)
15  wget "$version" || exit 1
16  tar fx ./*tar*
17  cd ..
18  mv ./tmp/*/* ./
19  rm -R -f ./tmp || exit 1
20  echo "$version" > ./version
21  chmod a+x ./MultiMC || exit 1
22  
23  # LINK TO PATH
24  ln -s "/opt/$APP/MultiMC" "/usr/local/bin/$APP"
25  
26  # SCRIPT TO UPDATE THE PROGRAM
27  cat >> ./AM-updater << 'EOF'
28  #!/bin/sh
29  set -u
30  APP=multimc
31  SITE="https://multimc.org/#Download"
32  # This will always update the app because the download link is a fixed url
33  #version0=$(cat "/opt/$APP/version")
34  version=$(wget -q "$SITE" -O - | sed 's/[()",{} ]/\n/g' | grep -oi 'https.*mmc.*lin64.*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 ./*tar*
41  	cd ..
42  	mv --backup=t ./tmp/*/* ./
43  	chmod a+x "/opt/$APP/MultiMC" || exit 1
44  	echo "$version" > ./version
45  	rm -R -f ./tmp ./*~
46  #	notify-send "$APP is updated!"
47  	exit 0
48  #fi
49  echo "Update not needed!"
50  EOF
51  chmod a+x ./AM-updater || exit 1