-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathandroid-mkshrc.sh
More file actions
59 lines (57 loc) · 1.1 KB
/
android-mkshrc.sh
File metadata and controls
59 lines (57 loc) · 1.1 KB
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
# put comments on their own line
# this file is in the same dir as everything
# it runs with root perms
# utility functions
prompt(){
# debug-friendly:
# echo 'i+&*!Vs0' >&2
echo -e '\0\c' >&2
}
prompt
remount(){
mount -o remount,"${1:-rw}" $(mount | grep -o '.* /system ')
}
# rpc
# install <relay> [--cache]
install(){
remount
if [ "$2" != "--cache" -o ! -d miredo ]
then
rm -rf miredo
mkdir miredo
cp "$FILES_DIR"/* miredo
chmod 755 miredo/{miredo{,-privproc},client-hook}
chgrp 3003 miredo/miredo-privproc
echo success
fi
relay="$1"
echo > miredo/miredo.conf '=====CONFIG====='
prompt
}
uninstall(){
remount
rm -rf miredo
remount ro
[ -d /system/miredo ] && echo failure || echo success
prompt
exit 0
}
# must be installed first
miredo(){
ps miredo | while read _ pid _
do
[ "$pid" = "PID" ] || kill "$pid"
done
cd miredo
# ignore race on $miredo pid reuse
trap 'kill "$miredo" "$read" 2>/dev/null; exit 143' TERM
# mksh doesn't use this fd
exec 3<&0
(read -u3; kill "$$" 2>/dev/null) & read="$!"
while :
do
./miredo -f & miredo="$!"
wait "$miredo"
echo status $?
done
}