Advertisement
Guest User

Bash Sileo, Cydia and Zebra source unifier

a guest
Jun 23rd, 2019
864
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.14 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. srcfiles=('/etc/apt/sources.list.d/sileo.sources' '/var/mobile/Documents/xyz.willy.Zebra/sources.list' '/var/mobile/Library/Caches/com.saurik.Cydia/sources.list' )
  4.  
  5. iteration=0
  6.  
  7. for item in ${srcfiles[*]}
  8. do
  9.  
  10.    if [[ "$iteration" -eq "0" ]]; then
  11.  
  12.      grep http $item | sed 's/http/\nhttp/g' | grep ^http | sed 's/\(^http[^ <]*\)\(.*\)/\1/g' > /tmp/srcf
  13.      wc -l /tmp/srcf
  14.  
  15.      elif  [[ "$iteration" -eq "1" ]];  then
  16.           grep http $item | sed 's/http/\nhttp/g' | grep ^http | sed 's/\(^http[^ <]*\)\(.*\)/\1/g' >> /tmp/srcf
  17.          wc -l /tmp/srcf
  18.  
  19.      elif [[ "$iteration" -eq "2" ]]; then
  20.          grep http $item | sed 's/http/\nhttp/g' | grep ^http | sed 's/\(^http[^ <]*\)\(.*\)/\1/g' >> /tmp/srcf
  21.        wc -l /tmp/srcf
  22.        rm /tmp/srtsrcf
  23.  
  24.        while read LINE
  25.            do echo ${LINE%/} >> /tmp/srtsrcf
  26.        done < /tmp/srcf
  27.  
  28.        rm /etc/apt/mergedsources2.txt
  29.        awk '!x[$0]++' /tmp/srtsrcf > /etc/apt/mergedsources2.txt
  30.        cat /etc/apt/mergedsources2.txt
  31.        wc -l /etc/apt/mergedsources2.txt
  32.  
  33.      else
  34.         echo "iteration $iteration"
  35.      fi
  36.   ((iteration++))
  37.  
  38. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement