Guest User

Untitled

a guest
Feb 5th, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.93 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. main_url='https://raw.github.com/psi-plus/contentdownloader/master/content.list'
  4. main_path='/usr/share/psi-plus'
  5. list_path='/tmp/content.list'
  6.  
  7. if ! wget -qO $list_path  $main_url --no-check-certificate ; then echo "Can't get file list"; exit 1; fi
  8. if ! cd $main_path  ; then echo "Can't change directory to $main_path"; exit 2; fi
  9. if ! [ -w . ] ; then echo "$main_path is read only"; exit 3; fi
  10.  
  11. cat $list_path|grep -n '\['|while read line; do
  12.  path="$(echo $line|cut -d ':' -f 2|sed 's/\[//;s/\]//')"
  13.  current_line="$(echo $line|cut -d ':' -f 1)";
  14.  url_line=$(($current_line+2))
  15.  name_line=$(($current_line+1))
  16.  type=$(echo $path|cut -d '/' -f 2)
  17.  name="$(cat $list_path|sed -n ${name_line}p|cut -d '=' -f 2)"
  18.  url="$(cat $list_path|sed -n ${url_line}p|cut -d '=' -f 2)"
  19.  file=$(basename $url)
  20.  echo "Saving $name ($type) to $path/$file..."
  21.  mkdir -p $path
  22.  wget -qO $path/$file $url --no-check-certificate
  23. done
Advertisement
Add Comment
Please, Sign In to add comment