-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-tarball.sh
84 lines (71 loc) · 1.93 KB
/
install-tarball.sh
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
#!/system/bin/sh
# ${1:-$id}[-_]*.tar.gz Installer
# Copyright (c) 2019-2020, VR25 (xda-developers.com)
# License: GPLv3+
id=acc
umask 0077
# log
mkdir -p /data/adb/${1:-$id}-data/logs
exec 2>/data/adb/${1:-$id}-data/logs/install-tarball.sh.log
set -x
# set up busybox
#BB#
if [ -d /sbin/.magisk/busybox ]; then
case $PATH in
/sbin/.magisk/busybox:*) :;;
*) PATH=/sbin/.magisk/busybox:$PATH;;
esac
else
mkdir -p /dev/.busybox
chmod 0700 /dev/.busybox
case $PATH in
/dev/.busybox:*) :;;
*) PATH=/dev/.busybox:$PATH;;
esac
[ -x /dev/.busybox/busybox ] || {
if [ -f /data/adb/magisk/busybox ]; then
[ -x /data/adb/magisk/busybox ] || chmod 0700 /data/adb/magisk/busybox
/data/adb/magisk/busybox --install -s /dev/.busybox
elif which busybox > /dev/null; then
busybox --install -s /dev/.busybox
elif [ -f /data/adb/busybox ]; then
[ -x /data/adb/busybox ] || chmod 0700 /data/adb/busybox
/data/adb/busybox --install -s /dev/.busybox
else
echo "(!) Install busybox or simply place it in /data/adb/"
exit 3
fi
}
fi
#/BB#
# root check
[ $(id -u) -ne 0 ] && {
echo "(!) $0 must run as root (su)"
exit 4
}
umask 0000
set -e
# get into the target directory
[ -f $PWD/${0##*/} ] || cd $(readlink -f ${0%/*})
# this runs on exit if the installer is launched by a front-end app
copy_log() {
[[ $PWD != /data/data/* ]] || {
umask 077
mkdir -p logs
cp -af /data/adb/${1:-$id}-data/logs/install.log logs/${1:-$id}-install.log 2>/dev/null || return 0
pkg=$(cd ..; pwd)
pkg=${pkg##/data*/}
owner=$(grep $pkg /data/system/packages.list | cut -d ' ' -f 2)
chown -R $owner:$owner logs
}
}
trap copy_log EXIT
# extract tarball
rm -rf ${1:-$id}[-_]*/ 2>/dev/null
tar -xf ${1:-$id}[-_]*.tar.gz
# install ${1:-$id}
test -f ${1:-$id}[-_]*/install.sh || i=-current
export installDir="$2"
ash ${1:-$id}[-_]*/install${i}.sh "$2"
rm -rf ${1-$id}[-_]*/
exit 0