-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoh-my-proot.sh
70 lines (50 loc) · 1.2 KB
/
oh-my-proot.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
function oh-my-proot-main {
unset LD_PRELOAD
mkdir -p ${TREE}/home/workspace
exec proot -S $TREE \
--link2symlink \
-b /dev/ -b /sdcard -b /proc/ \
-w /home/workspace \
/usr/bin/env -i HOME=/root \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin \
TERM=xterm-256color \
${loginshell}
}
function show_usage {
echo "--------oh-my-proot----------"
echo "| example & action |"
echo "| omp debian |"
echo "| 启动目录'debian'内的发行版|"
echo "-----------------------------"
exit 0
}
function command-line-interface {
[ $# -eq 1 ] || show_usage
[ -d "$@" ] || show_usage
case "$@" in
*/)
show_usage
;;
esac
#增加变量:TREE
export TREE=$(realpath -- $@)
rm $TREE/etc/resolv.conf 2> /dev/null
{
echo "nameserver 8.8.8.8"
echo "nameserver 1.1.1.1"
} >> $TREE/etc/resolv.conf || exit 1
if [ -x $TREE/bin/bash ]; then
loginshell="$TREE/bin/bash -l"
elif [ -x $TREE/usr/bin/bash ]; then
loginshell="$TREE/usr/bin/bash -l"
elif [ -x $TREE/bin/busybox ]; then
loginshell="$TREE/bin/busybox sh --login"
else
echo "未找到可用loginshell :("
exit 1
fi
#增加变量:loginshell
export loginshell
oh-my-proot-main
}
command-line-interface $@