-
Notifications
You must be signed in to change notification settings - Fork 2
/
syncFlipper
executable file
·177 lines (137 loc) · 6.05 KB
/
syncFlipper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/sh
### Set variables - start
## defaults
giturl=""
module=""
target=""
sdcard=/media/$USER/BENNIE
#sdcard=/mnt/tmp
gitroot=~/git
## Overwrite defaults by conf file
conffile=./conf/syncFlipper.conf
[ -f $conffile ] && . $conffile
### Set variables - stop
### This script works in two steps
### 1.a. if not exist, clone repository
### 1.b. keep git repositorys up to date
### 2. if SD card is mounted -> sync local git repository to SD
### On the bottom is a own function for the complex structure of UberGuidoz.
checkRequirement() {
[ ! -x "$(command -v $1)" ] && { echo "$1 is not installed"; exit 1 ; }
}
checkRequirement rsync
checkRequirement git
[ ! -d $gitroot ] && { echo "Target directory $gitroot does not exist.\nPlease create directory or change variable gitroot in config" ; exit 1; }
gitSync () {
## Overwrite defaults and conf file by arguments
while getopts g:m:t:s:r: flag
do
case "${flag}" in
g) giturl=${OPTARG};;
m) module=${OPTARG};;
t) target=${OPTARG};;
s) sdcard=${OPTARG};;
r) gitroot=${OPTARG};;
esac
done
gitpath=$gitroot/$(basename $giturl)
if [ $# -lt 2 ]; then
echo "Usage: $(basename $0) -g <gitURL> -m <module> [-t target]"
echo "<module>: badusb infrared nfc subghz ibutton music_player"
exit 1
fi
# check if subpath on SD is okay
case $module in
badusb|infrared|nfc|subghz|ibutton|music_player) ;;
*) echo "Allowed <module>: badusb infrared nfc subghz ibutton music_player" ; exit 1;;
esac
# If no SD subpath target is given, copy to subpath
[ -z $target ] && { target=$(basename $giturl) ; }
# If local git repo doesn't exist, clone first.
[ ! -d "$gitpath" ] && { cd $gitroot && git clone --recursive $giturl; }
cd $gitpath && git pull
# If SD Card is mounted (mointpoint exist)
# Some repository are often moving files around. --delete will take care of that.
if [ -d "$sdcard" ]; then
rsync -rv --checksum --delete $gitpath/ $sdcard/$module/$target/
echo "Size on SD: " $(du -hs $sdcard/$module/$target)
fi
echo "Local size: " $(du -hs $gitpath)
}
#####################################################################
### The UberGuidoZ is a large collection of 3,5 GB valuable files.
### Some ressources are redundant to other repositorys.
### It is harder to navigate on the flipper, so I replaced some dirs.
### Feel free to comment any path, to reduce the size on SD
guidoSync () {
gitpath=$gitroot/$(basename $1)
# If local git repo doesn't exist, clone first.
[ ! -d "$gitpath" ] && { cd $gitroot && git clone --recursive $1; }
cd $gitpath && git pull
# If SD Card is mounted (mointpoint exist)
# Some repository are often moving files around. --delete will take care of that.
if [ -d "$sdcard" ]; then
rsync -rv --checksum --delete $gitpath/NFC/ $sdcard/nfc/guidoz/
rsync -rv --checksum --delete $gitpath/Sub-GHz/ $sdcard/subghz/guidoz/
rsync -rv --checksum --delete $gitpath/subplaylist/ $sdcard/subplaylist/
rsync -rv --checksum --delete $gitpath/unirf/ $sdcard/unirf/
rsync -rv --checksum --delete $gitpath/BadUSB/ $sdcard/badusb/guidoz/
rsync -rv --checksum --delete $gitpath/picopass/ $sdcard/picopass/
rsync -rv --checksum --delete $gitpath/Wav_Player/ $sdcard/wav_player/
rsync -rv --checksum --delete $gitpath/Music_Player/ $sdcard/music_player/guidoz/
echo "Size of dumps on SD: " $(du -hs --total $sdcard/nfc/guidoz/ $sdcard/subghz/guidoz/ $sdcard/subplaylist/ $sdcard/unirf/ $sdcard/badusb/guidoz/ $sdcard/picopass/)
echo "Size of music on SD: " $(du -hs --total $sdcard/wav_player/ $sdcard/music_player/)
fi
echo "Local size: " $(du -hs $gitpath)
}
starnewSync () {
gitpath=$gitroot/$(basename $1)
# If local git repo doesn't exist, clone first.
[ ! -d "$gitpath" ] && { cd $gitroot && git clone --recursive $1; }
cd $gitpath && git pull
# If SD Card is mounted (mointpoint exist)
# Some repository are often moving files around. --delete will take care of that.
if [ -d "$sdcard" ]; then
rsync -rv --checksum --delete $gitpath/StarButton/ $sdcard/ibutton/StarButton/
rsync -rv --checksum --delete $gitpath/StarRFID/ $sdcard/rfid/StarRFID/
echo "Size of dumps on SD: " $(du -hs --total $sdcard/ibutton/StarButton/ $sdcard/rfid/StarRFID/)
fi
echo "Local size: " $(du -hs $gitpath)
}
## List git repos to sync
## for Information, see https://github.com/djsime1/awesome-flipperzero
gitSync -g https://github.com/logickworkshop/Flipper-IRDB -m infrared
gitSync -g https://github.com/Gioman101/FlipperAmiibo -m nfc
gitSync -g https://github.com/tobiabocchi/flipperzero-bruteforce -m subghz
gitSync -g https://github.com/UNC0V3R3D/Flipper_Zero-BadUsb -m badusb -t UNC0V3R3D
gitSync -g https://github.com/I-Am-Jakoby/Flipper-Zero-BadUSB -m badusb -t I-Am-Jakoby
gitSync -g https://github.com/FalsePhilosopher/badusb -m badusb -t FalsePhilosopher
gitSync -g https://github.com/nocomp/Flipper_Zero_Badusb_hack5_payloads -m badusb -t hack5_payloads
gitSync -g https://github.com/jimilinuxguy/flipperzero-touchtunes -m subghz -t touchtunes
gitSync -g https://github.com/neverfa11ing/FlipperMusicRTTTL -m music_player -t rtttl
gitSync -g https://github.com/Tonsil/flipper-music-files -m music_player -t fmf
gitSync -g https://github.com/wetox-team/flipperzero-goodies -m ibutton -t wetox
gitSync -g https://github.com/xb8/t119bruteforcer -m subghz -t t119pager
starnewSync https://github.com/GlUTEN-BASH/Flipper-Starnew
guidoSync https://github.com/UberGuidoZ/Flipper
## syncFlipperApps - Allowed <firmware>: official dev unleashed roughmaster xtreme
## Not working!
## Copy apps from GuidoZ to SD Card
fwApps () {
case $1 in
official) fwPath=Official/STABLE_FW;;
dev) fwPath=Official/DEV_FW;;
unleashed) fwPath=Custom*/Unleashed*;;
roguemaster) fwPath=Custom*/RogueMaster;;
xtreme) fwPath=Custom*/Xtreme*;;
*) echo "Allowed <firmware>: official dev unleashed roughmaster xtreme" ; exit 1;;
esac
fwAppDir=$gitroot/Flipper/Applications/$fwPath
for appDir in $(ls $fwAppDir) ; do
appTarget=$sdcard/apps/$1/$appDir
#echo "from $fwAppDir/$appDir/*.fap to $appTarget/"
rsync -rv --checksum --delete $fwAppDir/$appDir/ $appTarget/
done
}
#fwApps unleashed
cd ~