-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunpackimg
executable file
·42 lines (36 loc) · 920 Bytes
/
unpackimg
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
#!/bin/bash
source bin/funcs.sh
chkarch
banner
RPWD=`pwd`
if [ "$1" == "help" ]
then
usage
exit 0
elif [ -f "$1" ]
then
./cleanup
IMG=`realpath $1`
else
echo -e '[!]Input Error\n'
usage
exit 1
fi
mkdir -p $RPWD/split $RPWD/ramdisk
cat $IMG > $RPWD/split/source.img
cd $RPWD/split
$MAGISKBOOT unpack -h $IMG
RDTYPE=`chkrdtype $RPWD/split/ramdisk.cpio | tee $RPWD/split/ramdisk_compression`
if [[ "$RDTYPE" == 'zst' ]]; then
mv $RPWD/split/ramdisk.cpio $RPWD/split/ramdisk.cpio.zst
zstd -d $RPWD/split/ramdisk.cpio.zst
rm $RPWD/split/ramdisk.cpio.zst
elif [[ "$RDTYPE" == 'gzip' ]]; then
mv $RPWD/split/ramdisk.cpio $RPWD/split/ramdisk.cpio.gz
gzip -d $RPWD/split/ramdisk.cpio.gz
elif [[ "$RDTYPE" == 'xz' ]]; then
mv $RPWD/split/ramdisk.cpio $RPWD/split/ramdisk.cpio.xz
xz -d $RPWD/split/ramdisk.cpio.xz
fi
cd $RPWD/ramdisk
cpio -i < $RPWD/split/ramdisk.cpio