/ programs / x86_64 / clifm
clifm
 1  #!/bin/sh
 2  
 3  # AM INSTALL SCRIPT VERSION 3.5
 4  set -u
 5  APP=clifm
 6  SITE="leo-arch/clifm"
 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 /usr/local/share/$APP /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/leo-arch/clifm/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*" | grep -vi "i386\|i686\|aarch64\|arm64\|armv7l" | grep -i "linux-x86_64.tar.gz" | 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 ./bin/"$APP" || exit 1
25  
26  # LINK TO PATH
27  ln -s "/opt/$APP/bin/$APP" "/usr/local/bin/$APP"
28  
29  # LINK DATA FILES
30  mkdir -p /usr/local/share
31  ln -s "/opt/$APP/files" "/usr/local/share/$APP"
32  
33  # SCRIPT TO UPDATE THE PROGRAM
34  cat >> ./AM-updater << 'EOF'
35  #!/bin/sh
36  set -u
37  APP=clifm
38  SITE="leo-arch/clifm"
39  version0=$(cat "/opt/$APP/version")
40  version=$(curl -Ls https://api.github.com/repos/leo-arch/clifm/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*" | grep -vi "i386\|i686\|aarch64\|arm64\|armv7l" | grep -i "linux-x86_64.tar.gz" | head -1)
41  [ -n "$version" ] || { echo "Error getting link"; exit 1; }
42  if [ "$version" != "$version0" ]; then
43  	mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
44  	notify-send "A new version of $APP is available, please wait"
45  	wget "$version" || exit 1
46  	[ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
47  	[ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
48  	[ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
49  	cd ..
50  	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
51  	chmod a+x ./bin/"$APP" || exit 1
52  	echo "$version" > ./version
53  	rm -R -f ./tmp ./*~
54  	notify-send "$APP is updated!"
55  else
56  	echo "Update not needed!"
57  fi
58  EOF
59  chmod a+x ./AM-updater || exit 1
60  
61  # ICON
62  mkdir -p icons
63  wget https://raw.githubusercontent.com/leo-arch/clifm/master/misc/logo/clifm.svg -O ./icons/"$APP" 2> /dev/null
64  
65  # LAUNCHER
66  echo "[Desktop Entry]
67  Name=CliFM
68  Exec=$APP
69  Icon=/opt/$APP/icons/$APP
70  Comment=The command line file manager
71  Type=Application
72  Terminal=true
73  Categories=System;" > /usr/local/share/applications/"$APP"-AM.desktop