/ programs / x86_64 / testdisk
testdisk
 1  #!/bin/sh
 2  
 3  # AM INSTALL SCRIPT VERSION 3.5
 4  set -u
 5  APP=testdisk
 6  SITE="https://www.cgsecurity.org/wiki/TestDisk_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  printf '\n%s' "rm -f /usr/local/bin/photorec" >> ../remove
12  printf '\n%s' "rm -f /usr/local/bin/fidentify" >> ../remove
13  chmod a+x ../remove || exit 1
14  
15  # DOWNLOAD AND PREPARE THE APP, $version is also used for updates
16  version=$(wget -q https://www.cgsecurity.org/wiki/TestDisk_Download -O - | tr '"' '\n' | grep -oi "https.*testdisk.*linux.*x86_64.*bz2$" | grep -v donate | head -1)
17  wget "$version" || exit 1
18  [ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
19  [ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
20  [ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
21  cd ..
22  if [ -d ./tmp/* 2>/dev/null ]; then mv ./tmp/*/* ./; else mv ./tmp/* ./"$APP" 2>/dev/null || mv ./tmp/* ./; fi
23  rm -R -f ./tmp || exit 1
24  echo "$version" > ./version
25  chmod a+x /opt/"$APP"/*static || exit 1
26  
27  # LINK TO PATH
28  ln -s "/opt/$APP/testdisk_static" "/usr/local/bin/$APP"
29  ln -s "/opt/$APP/photorec_static" "/usr/local/bin/photorec"
30  ln -s "/opt/$APP/fidentify_static" "/usr/local/bin/fidentify"
31  
32  # SCRIPT TO UPDATE THE PROGRAM
33  cat >> ./AM-updater << 'EOF'
34  #!/bin/sh
35  set -u
36  APP=testdisk
37  SITE="https://www.cgsecurity.org/wiki/TestDisk_Download"
38  version0=$(cat "/opt/$APP/version")
39  version=$(wget -q https://www.cgsecurity.org/wiki/TestDisk_Download -O - | tr '"' '\n' | grep -oi "https.*testdisk.*linux.*x86_64.*bz2$" | grep -v donate | head -1)
40  [ -n "$version" ] || { echo "Error getting link"; exit 1; }
41  if [ "$version" != "$version0" ]; then
42  	mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
43  	notify-send "A new version of $APP is available, please wait"
44  	wget "$version" || exit 1
45  	[ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
46  	[ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
47  	[ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
48  	cd ..
49  	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
50  	chmod a+x /opt/"$APP"/*static || exit 1
51  	echo "$version" > ./version
52  	rm -R -f ./tmp ./*~
53  	notify-send "$APP is updated!"
54  else
55  	echo "Update not needed!"
56  fi
57  EOF
58  chmod a+x ./AM-updater || exit 1