-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-online.sh
139 lines (109 loc) · 3.21 KB
/
install-online.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
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
#!/system/bin/sh
#
# $id Online Installer
# https://raw.githubusercontent.com/VR-25/$id/$commit/install-online.sh
#
# Copyright 2019-2021, VR25
# License: GPLv3+
#
# Usage: sh install-online.sh [-c|--changelog] [-f|--force] [-k|--insecure] [-n|--non-interactive] [%parent install dir%] [commit]
set +x
echo
id=acc
domain=vr25
data_dir=/data/adb/$domain/${id}-data
# log
[ -z "${LINENO-}" ] || export PS4='$LINENO: '
mkdir -p $data_dir/logs
exec 2>$data_dir/logs/install-online.sh.log
set -x
trap 'e=$?; echo; exit $e' EXIT
# set up busybox
#BB#
bin_dir=/data/adb/vr25/bin
busybox_dir=/dev/.vr25/busybox
magisk_busybox=/data/adb/magisk/busybox
[ -x $busybox_dir/ls ] || {
mkdir -p $busybox_dir
chmod 0700 $busybox_dir
for f in $bin_dir/busybox $magisk_busybox /system/*bin/busybox*; do
[ -f $f ] && {
[ -x $f ] || chmod 0755 $f 2>/dev/null
$f --install -s $busybox_dir/
break
}
done
[ -x $busybox_dir/ls ] || {
echo "Install busybox or simply place it in $bin_dir/"
echo
exit 3
}
}
case $PATH in
$bin_dir:*) ;;
*) export PATH="$bin_dir:$busybox_dir:$PATH";;
esac
unset f bin_dir busybox_dir magisk_busybox
#/BB#
# root check
[ $(id -u) -ne 0 ] && {
echo "$0 must run as root (su)"
exit 4
}
set -eu
get_ver() { sed -n 's/^versionCode=//p' ${1:-}; }
! test -f /data/adb/vr25/bin/curl || {
test -x /data/adb/vr25/bin/curl \
|| chmod -R 0700 /data/adb/vr25/bin
}
which curl >/dev/null || {
curl() {
shift $(($# - 1))
PATH=${PATH#*/busybox:} /dev/.vr25/busybox/wget -O - --no-check-certificate $1
}
}
case "$@" in
*--insecure*|*-k*) insecure=--insecure;;
*) insecure=;;
esac
commit=$(echo "$*" | sed -E 's/%.*%|-c|--changelog|-f|--force|-k|--insecure|-n|--non-interactive| //g')
: ${commit:=master}
tarball=https://github.com/VR-25/$id/archive/${commit}.tar.gz
installedVersion=$(get_ver /data/adb/$domain/$id/module.prop 2>/dev/null || :)
onlineVersion=$(curl -L $insecure https://raw.githubusercontent.com/VR-25/$id/${commit}/module.prop | get_ver)
[ -f $PWD/${0##*/} ] || cd ${0%/*}
rm -rf "./${id}-${commit}/" 2>/dev/null || :
if [ ${installedVersion:-0} -lt ${onlineVersion:-0} ] \
|| case "$*" in *-f*|*--force*) true;; *) false;; esac
then
! echo "$@" | grep -Eq '\-\-changelog|\-c' || {
if echo "$@" | grep -Eq '\-\-non-interactive|\-n'; then
echo $onlineVersion
echo "https://github.com/VR-25/$id/blob/${commit}/README.md#latest-changes"
exit 5 # no update available
else
echo
print_available $id $onlineVersion 2>/dev/null \
|| echo "$id $onlineVersion is available"
echo "- https://github.com/VR-25/$id/blob/${commit}/README.md#latest-changes"
print_install_prompt 2>/dev/null \
|| echo -n "- Should I download and install it ([enter]: yes, CTRL-C: no)? "
read REPLY
fi
}
# download and install tarball
: ${installDir:=$(echo "$@" | sed -E "s/-c|--changelog|-f|--force|-k|--insecure|-n|--non-interactive|%|$commit| //g")}
export installDir
set +eu
trap - EXIT
echo
curl -L $insecure $tarball | tar -xz \
&& ash ${id}-${commit}/install.sh
else
echo
print_no_update 2>/dev/null || echo "No update available"
exit 6
fi
set -eu
rm -rf "./${id}-${commit}/" 2>/dev/null
exit 0