|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -timestamp="`date +"%Y.%m.%d-%H.%M.%S"`" |
4 | | -versionNumber=`dpkg-query --showformat='${Version}\n' --show com.captinc.batchomatic` |
5 | | -rm -r /tmp/batchomatic |
6 | | -mkdir /tmp/batchomatic |
7 | | - |
8 | | -mkdir /tmp/batchomatic/create |
9 | | -mkdir /tmp/batchomatic/create/DEBIAN |
10 | | -cp /Library/batchomatic/directions /tmp/batchomatic/create/DEBIAN/postinst |
11 | | -mkdir /tmp/batchomatic/create/var |
12 | | -mkdir /tmp/batchomatic/create/var/mobile |
13 | | -mkdir /tmp/batchomatic/create/var/mobile/BatchInstall |
14 | | -mkdir /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences |
15 | | -mkdir /tmp/batchomatic/create/var/mobile/BatchInstall/SavedDebs |
16 | | - |
17 | | -echo "Package: com.you.batchinstall" >> /tmp/batchomatic/create/DEBIAN/control |
18 | | -echo "Name: BatchInstall" >> /tmp/batchomatic/create/DEBIAN/control |
19 | | -echo "Version: $timestamp" >> /tmp/batchomatic/create/DEBIAN/control |
20 | | -echo "Author: You" >> /tmp/batchomatic/create/DEBIAN/control |
21 | | -echo "Maintainer: You" >> /tmp/batchomatic/create/DEBIAN/control |
22 | | -echo "Architecture: iphoneos-arm" >> /tmp/batchomatic/create/DEBIAN/control |
23 | | -echo "Section: Tweaks" >> /tmp/batchomatic/create/DEBIAN/control |
24 | | -echo "Description: Batch-install all of your tweaks for your setup! Created using Batchomatic v$versionNumber" >> /tmp/batchomatic/create/DEBIAN/control |
25 | | - |
26 | | -apt-cache depends com.you.batchinstall | awk -F "Depends: " '/Depends: /{print $2}' > /tmp/batchomatic/alltweaks.txt |
27 | | -awk 'NR==FNR{a[$0];next} !($0 in a)' /Library/batchomatic/ignoredtweaks.txt /tmp/batchomatic/alltweaks.txt > /tmp/batchomatic/tweaksUnformatted.txt |
28 | | -sed -i 's|[<>,]||g' /tmp/batchomatic/tweaksUnformatted.txt |
29 | | -printf %s "$(< /tmp/batchomatic/tweaksUnformatted.txt)" > /tmp/batchomatic/create/var/mobile/BatchInstall/tweaks.txt |
30 | | - |
31 | | -cat /etc/apt/sources.list.d/cydia.list >> /tmp/batchomatic/reposRaw.txt || true |
32 | | -cat /etc/apt/cydiasources.d/cydia.list >> /tmp/batchomatic/reposRaw.txt || true |
33 | | -cat "/var/mobile/Library/Application Support/xyz.willy.Zebra/sources.list" >> /tmp/batchomatic/reposRaw.txt || true |
34 | | -cat /etc/apt/sources.list.d/*.sources >> /tmp/batchomatic/reposRaw.txt || true |
35 | | -ls "/var/mobile/Library/Application Support/Installer/SourcesFiles" | sed 's:_:/:g' | sed 's:\(.*\)-Packages:\1:' >> /tmp/batchomatic/reposFormatted.txt || true |
36 | | -egrep -o 'https?://[^ ]+' /tmp/batchomatic/reposRaw.txt >> /tmp/batchomatic/reposExtracted.txt |
37 | | -while read aLine; do |
38 | | - case "$aLine" in |
39 | | - */) |
40 | | - echo $aLine >> /tmp/batchomatic/reposFormatted.txt |
41 | | - ;; |
42 | | - *) |
43 | | - echo "$aLine/" >> /tmp/batchomatic/reposFormatted.txt |
44 | | - ;; |
45 | | - esac |
46 | | -done < /tmp/batchomatic/reposExtracted.txt |
47 | | -sed 's#https://repounclutter.coolstar.org/#http://apt.thebigboss.org/repofiles/cydia/#g' /tmp/batchomatic/reposFormatted.txt > /tmp/batchomatic/reposRepoUnclutterConverted.txt |
48 | | -sort -u /tmp/batchomatic/reposRepoUnclutterConverted.txt >> /tmp/batchomatic/reposSorted.txt |
49 | | -awk 'NR==FNR{a[$0];next} !($0 in a)' /Library/batchomatic/ignoredrepos.txt /tmp/batchomatic/reposSorted.txt > /tmp/batchomatic/reposWithoutIgnores.txt |
50 | | -sort -u /tmp/batchomatic/reposWithoutIgnores.txt >> /tmp/batchomatic/reposReSorted.txt |
51 | | -printf %s "$(< /tmp/batchomatic/reposReSorted.txt)" > /tmp/batchomatic/create/var/mobile/BatchInstall/repos.txt |
52 | | - |
53 | | -find /var/mobile/BatchInstall -type f -exec chmod 777 {} \; |
54 | | -find /var/mobile/BatchInstall -type d -exec chmod 777 {} \; |
55 | | -hostsFile=/var/mobile/BatchInstall/hosts |
56 | | -if test -f "$hostsFile"; then |
| 3 | +step1 () { |
| 4 | + rm -r /tmp/batchomatic 2>/dev/null |
| 5 | + mkdir /tmp/batchomatic |
| 6 | + timestamp="`date +"%Y.%m.%d-%H.%M.%S"`" |
| 7 | + echo $timestamp >> /tmp/batchomatic/timestampWithNewline.txt |
| 8 | + printf %s "$(< /tmp/batchomatic/timestampWithNewline.txt)" > /tmp/batchomatic/timestamp.txt |
| 9 | + echo "LOG: completed initial setup" |
| 10 | +} |
| 11 | +step2 () { |
| 12 | + mkdir /tmp/batchomatic/create |
| 13 | + mkdir /tmp/batchomatic/create/DEBIAN |
| 14 | + cp /Library/batchomatic/directions /tmp/batchomatic/create/DEBIAN/postinst |
| 15 | + mkdir /tmp/batchomatic/create/var |
| 16 | + mkdir /tmp/batchomatic/create/var/mobile |
| 17 | + mkdir /tmp/batchomatic/create/var/mobile/BatchInstall |
| 18 | + mkdir /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences |
| 19 | + mkdir /tmp/batchomatic/create/var/mobile/BatchInstall/SavedDebs |
| 20 | + echo "LOG: completed filesystem setup" |
| 21 | +} |
| 22 | +step3 () { |
| 23 | + timestamp="`cat /tmp/batchomatic/timestamp.txt`" |
| 24 | + versionNumber=`dpkg-query --showformat='${Version}\n' --show com.captinc.batchomatic` |
| 25 | + echo "Package: com.you.batchinstall" >> /tmp/batchomatic/create/DEBIAN/control |
| 26 | + echo "Name: BatchInstall - Online" >> /tmp/batchomatic/create/DEBIAN/control |
| 27 | + echo "Version: $timestamp" >> /tmp/batchomatic/create/DEBIAN/control |
| 28 | + echo "Author: You" >> /tmp/batchomatic/create/DEBIAN/control |
| 29 | + echo "Maintainer: You" >> /tmp/batchomatic/create/DEBIAN/control |
| 30 | + echo "Architecture: iphoneos-arm" >> /tmp/batchomatic/create/DEBIAN/control |
| 31 | + echo "Section: Tweaks" >> /tmp/batchomatic/create/DEBIAN/control |
| 32 | + echo "Description: Batch-install all of your tweaks for your setup! Created using Batchomatic v$versionNumber" >> /tmp/batchomatic/create/DEBIAN/control |
| 33 | + echo "LOG: created control file" |
| 34 | +} |
| 35 | +step4 () { |
| 36 | + apt-cache depends com.you.batchinstall | awk -F "Depends: " '/Depends: /{print $2}' > /tmp/batchomatic/alltweaks.txt |
| 37 | + awk 'NR==FNR{a[$0];next} !($0 in a)' /Library/batchomatic/ignoredtweaks.txt /tmp/batchomatic/alltweaks.txt > /tmp/batchomatic/tweaksWithoutIgnores.txt |
| 38 | + sed -i 's|[<>,]||g' /tmp/batchomatic/tweaksWithoutIgnores.txt |
| 39 | + printf %s "$(< /tmp/batchomatic/tweaksWithoutIgnores.txt)" > /tmp/batchomatic/create/var/mobile/BatchInstall/tweaks.txt |
| 40 | + echo "LOG: gathered tweaks" |
| 41 | +} |
| 42 | +step5 () { |
| 43 | + cat /etc/apt/sources.list.d/*.list /etc/apt/cydiasources.d/*.list /var/mobile/Library/Application\ Support/xyz.willy.Zebra/*.list /etc/apt/sources.list.d/*.sources 2>/dev/null >> /tmp/batchomatic/reposRaw.txt |
| 44 | + ls "/var/mobile/Library/Application Support/Installer/SourcesFiles" 2>/dev/null | sed 's:_:/:g' | sed 's:\(.*\)-Packages:\1:' >> /tmp/batchomatic/reposWithSlash.txt |
| 45 | + egrep -o 'https?://[^ ]+' /tmp/batchomatic/reposRaw.txt >> /tmp/batchomatic/reposExtracted.txt |
| 46 | + sed 's:/\?$:/:g' /tmp/batchomatic/reposExtracted.txt >> /tmp/batchomatic/reposWithSlash.txt |
| 47 | + sed 's#https://repounclutter.coolstar.org/#http://apt.thebigboss.org/repofiles/cydia/#g' /tmp/batchomatic/reposWithSlash.txt > /tmp/batchomatic/reposRepoUnclutterConverted.txt |
| 48 | + sort -u /tmp/batchomatic/reposRepoUnclutterConverted.txt >> /tmp/batchomatic/reposSorted.txt |
| 49 | + awk 'NR==FNR{a[$0];next} !($0 in a)' /Library/batchomatic/ignoredrepos.txt /tmp/batchomatic/reposSorted.txt > /tmp/batchomatic/reposWithoutIgnores.txt |
| 50 | + sort -u /tmp/batchomatic/reposWithoutIgnores.txt >> /tmp/batchomatic/reposReSorted.txt |
| 51 | + printf %s "$(< /tmp/batchomatic/reposReSorted.txt)" > /tmp/batchomatic/create/var/mobile/BatchInstall/repos.txt |
| 52 | + echo "LOG: gathered repos" |
| 53 | +} |
| 54 | +step6 () { |
| 55 | + find /var/mobile/BatchInstall -type f -exec chmod 777 {} \; |
| 56 | + find /var/mobile/BatchInstall -type d -exec chmod 777 {} \; |
| 57 | + hostsFile=/var/mobile/BatchInstall/hosts |
| 58 | + if test -f "$hostsFile"; then |
57 | 59 | cp -r /var/mobile/BatchInstall/TweakPreferences/* /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences |
58 | 60 | cp /var/mobile/BatchInstall/hosts /tmp/batchomatic/create/var/mobile/BatchInstall |
59 | | - batchomaticd 2 |
60 | | -else |
| 61 | + else |
61 | 62 | cp -r /var/mobile/BatchInstall/* /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences |
62 | 63 | batchomaticd 1 |
| 64 | + fi |
| 65 | + cp /var/mobile/Library/Caches/libactivator.plist /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences/libactivator.exported.plist 2>/dev/null |
| 66 | + rm /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences/.Global* 2>/dev/null |
| 67 | + rm /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences/com.google* 2>/dev/null |
| 68 | + rm /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences/group.com.apple* 2>/dev/null |
| 69 | + rm /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences/com.saurik.Cydia.plist 2>/dev/null |
| 70 | + rm /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences/nfcd.plist 2>/dev/null |
| 71 | + rm /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences/TVRemoteConnectionService.plist 2>/dev/null |
| 72 | + rm /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences/UITextInputContextIdentifiers.plist 2>/dev/null |
| 73 | + find /tmp/batchomatic/create/var/mobile/BatchInstall/Preferences -maxdepth 1 -name "*groups.com.apple*" -delete 2>/dev/null |
| 74 | + echo "LOG: gathered tweak preferences" |
| 75 | +} |
| 76 | +step7 () { |
63 | 77 | batchomaticd 2 |
64 | | -fi |
| 78 | + echo "LOG: gathered hosts file" |
| 79 | +} |
| 80 | +step8 () { |
| 81 | + cp /var/mobile/BatchomaticDebs/UserSavedDebs/* /tmp/batchomatic/create/var/mobile/BatchInstall/SavedDebs 2>/dev/null |
| 82 | + echo "LOG: gathered saved debs" |
| 83 | +} |
| 84 | +step9 () { |
| 85 | + timestamp="`cat /tmp/batchomatic/timestamp.txt`" |
| 86 | + find /tmp/batchomatic/create -name ".DS_Store" -type f -delete 2>/dev/null |
| 87 | + echo "LOG: building final deb" |
| 88 | + dpkg -b /tmp/batchomatic/create /var/mobile/BatchomaticDebs/batchinstall-online-$timestamp.deb |
| 89 | +} |
| 90 | +step10 () { |
| 91 | + timestamp="`cat /tmp/batchomatic/timestamp.txt`" |
| 92 | + echo "batchinstall-online-$timestamp.deb" > /tmp/batchomatic/nameOfDeb.txt |
| 93 | + echo "LOG: complete" |
| 94 | +} |
65 | 95 |
|
66 | | -cp /var/mobile/BatchomaticDebs/UserSavedDebs/* /tmp/batchomatic/create/var/mobile/BatchInstall/SavedDebs |
67 | | - |
68 | | -dpkg-deb -b /tmp/batchomatic/create /var/mobile/BatchomaticDebs/batchinstall-$timestamp.deb |
69 | | -rm -r /tmp/batchomatic |
| 96 | +if [ "$1" = 1 ]; then |
| 97 | + step1 |
| 98 | +elif [ "$1" = 2 ]; then |
| 99 | + step2 |
| 100 | +elif [ "$1" = 3 ]; then |
| 101 | + step3 |
| 102 | +elif [ "$1" = 4 ]; then |
| 103 | + step4 |
| 104 | +elif [ "$1" = 5 ]; then |
| 105 | + step5 |
| 106 | +elif [ "$1" = 6 ]; then |
| 107 | + step6 |
| 108 | +elif [ "$1" = 7 ]; then |
| 109 | + step7 |
| 110 | +elif [ "$1" = 8 ]; then |
| 111 | + step8 |
| 112 | +elif [ "$1" = 9 ]; then |
| 113 | + step9 |
| 114 | +elif [ "$1" = 10 ]; then |
| 115 | + step10 |
| 116 | +elif [ "$1" = 0 ]; then |
| 117 | + step1 |
| 118 | + step2 |
| 119 | + step3 |
| 120 | + step4 |
| 121 | + step5 |
| 122 | + step6 |
| 123 | + step7 |
| 124 | + step8 |
| 125 | + step9 |
| 126 | + step10 |
| 127 | +fi |
0 commit comments