-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-emuroot-shell.sh
187 lines (162 loc) · 5.94 KB
/
start-emuroot-shell.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
host_bits=$(getconf LONG_BIT)
# -------------------------------------
# Menu
# -------------------------------------
function checkifinstalled {
if [ -f /emuroot/arm-linux-gnueabi/var/lib/dpkg/status ]; then
emurootfs_exists_arm_linux_gnueabi=1
else
emurootfs_exists_arm_linux_gnueabi=0
fi
if [ -f /emuroot/arm-linux-gnueabihf/var/lib/dpkg/status ]; then
emurootfs_exists_arm_linux_gnueabihf=1
else
emurootfs_exists_arm_linux_gnueabihf=0
fi
if [ -f /emuroot/aarch64-linux-gnu/var/lib/dpkg/status ]; then
emurootfs_exists_aarch64_linux_gnu=1
else
emurootfs_exists_aarch64_linux_gnu=0
fi
if [ -f /emuroot/i386-linux-gnu/var/lib/dpkg/status ]; then
emurootfs_exists_i386_linux_gnu=1
else
emurootfs_exists_i386_linux_gnu=0
fi
if [ -f /emuroot/x86_64-linux-gnu/var/lib/dpkg/status ]; then
emurootfs_exists_x86_64_linux_gnu=1
else
emurootfs_exists_x86_64_linux_gnu=0
fi
if [ -f /emuroot/mips-linux-gnu/var/lib/dpkg/status ]; then
emurootfs_exists_mips_linux_gnu=1
else
emurootfs_exists_mips_linux_gnu=0
fi
if [ -f /emuroot/mips64el-linux-gnuabi64/var/lib/dpkg/status ]; then
emurootfs_exists_mips64el_linux_gnuabi64=1
else
emurootfs_exists_mips64el_linux_gnuabi64=0
fi
if [ -f /emuroot/mipsel-linux-gnu/var/lib/dpkg/status ]; then
emurootfs_exists_mipsel_linux_gnu=1
else
emurootfs_exists_mipsel_linux_gnu=0
fi
if [ -f /emuroot/powerpc-linux-gnu/var/db/xbps/pkgdb-0.38.plist ]; then
emurootfs_exists_powerpc_linux_gnu=1
else
emurootfs_exists_powerpc_linux_gnu=0
fi
if [ -f /emuroot/powerpc64-linux-gnu/var/db/xbps/pkgdb-0.38.plist ]; then
emurootfs_exists_powerpc64_linux_gnu=1
else
emurootfs_exists_powerpc64_linux_gnu=0
fi
if [ -f /emuroot/powerpc64le-linux-gnu/var/lib/dpkg/status ]; then
emurootfs_exists_powerpc64le_linux_gnu=1
else
emurootfs_exists_powerpc64le_linux_gnu=0
fi
if [ -f /emuroot/s390x-linux-gnu/var/lib/dpkg/status ]; then
emurootfs_exists_s390x_linux_gnu=1
else
emurootfs_exists_s390x_linux_gnu=0
fi
}
function existingstatetoreadable {
if [ $1 = 1 ]; then
echo Installed
else
echo NotInstalled
fi
}
function archmenu32 {
SelectedArch=$(whiptail --menu "Select Arch" 20 70 10 "linux-armel" $(existingstatetoreadable $emurootfs_exists_arm_linux_gnueabi) "linux-armhf" $(existingstatetoreadable $emurootfs_exists_arm_linux_gnueabihf) "linux-i386" $(existingstatetoreadable $emurootfs_exists_i386_linux_gnu) "linux-mips" $(existingstatetoreadable $emurootfs_exists_mips_linux_gnu) "linux-mipsel" $(existingstatetoreadable $emurootfs_exists_mipsel_linux_gnu) "linux-powerpc" $(existingstatetoreadable $emurootfs_exists_powerpc_linux_gnu) "linux-s390x" $(existingstatetoreadable $emurootfs_exists_s390x_linux_gnu) 3>&1 1>&2 2>&3)
selectedarchoptions
}
function archmenu64 {
SelectedArch=$(whiptail --menu "Select Arch" 20 70 10 "linux-armel" $(existingstatetoreadable $emurootfs_exists_arm_linux_gnueabi) "linux-armhf" $(existingstatetoreadable $emurootfs_exists_arm_linux_gnueabihf) "linux-arm64" "$(existingstatetoreadable $emurootfs_exists_aarch64_linux_gnu)" "linux-i386" $(existingstatetoreadable $emurootfs_exists_i386_linux_gnu) "linux-x86_64" $(existingstatetoreadable $emurootfs_exists_x86_64_linux_gnu) "linux-mips" $(existingstatetoreadable $emurootfs_exists_mips_linux_gnu) "linux-mipsel" $(existingstatetoreadable $emurootfs_exists_mipsel_linux_gnu) "linux-mips64el" $(existingstatetoreadable $emurootfs_exists_mips64el_linux_gnuabi64) "linux-powerpc" $(existingstatetoreadable $emurootfs_exists_powerpc_linux_gnu) "linux-powerpc64" $(existingstatetoreadable $emurootfs_exists_powerpc64_linux_gnu) "linux-powerpc64le" $(existingstatetoreadable $emurootfs_exists_powerpc64le_linux_gnu) "linux-s390x" $(existingstatetoreadable $emurootfs_exists_s390x_linux_gnu) 3>&1 1>&2 2>&3)
selectedarchoptions
}
function selectedarchoptions {
if [ -z "$SelectedArch" ]
then
exit
else
optionselect
fi
}
function startarchmenu {
if [ $host_bits = 64 ]; then
archmenu64
else
archmenu32
fi
}
function optionselect {
setup-vars-for-emuroot-shell
}
# -------------------------------------
# emuroot
# -------------------------------------
start-emuroot-shell () {
if [ -f /usr/bin/groot ]; then
cd $StartEmuRootShell_RootPath
groot
else
chroot $StartEmuRootShell_RootPath
fi
}
setup-vars-for-emuroot-shell () {
if [[ $SelectedArch == "linux-arm64" ]]; then
StartEmuRootShell_RootPath="/emuroot/aarch64-linux-gnu"
start-emuroot-shell
fi
if [[ $SelectedArch == "linux-armel" ]]; then
StartEmuRootShell_RootPath="/emuroot/arm-linux-gnueabi"
start-emuroot-shell
fi
if [[ $SelectedArch == "linux-armhf" ]]; then
StartEmuRootShell_RootPath="/emuroot/arm-linux-gnueabihf"
start-emuroot-shell
fi
if [[ $SelectedArch == "linux-i386" ]]; then
StartEmuRootShell_RootPath="/emuroot/i386-linux-gnu"
start-emuroot-shell
fi
if [[ $SelectedArch == "linux-mips" ]]; then
StartEmuRootShell_RootPath="/emuroot/mips-linux-gnu"
start-emuroot-shell
fi
if [[ $SelectedArch == "linux-mips64el" ]]; then
StartEmuRootShell_RootPath="/emuroot/mips64el-linux-gnuabi64"
start-emuroot-shell
fi
if [[ $SelectedArch == "linux-mipsel" ]]; then
StartEmuRootShell_RootPath="/emuroot/mipsel-linux-gnu"
start-emuroot-shell
fi
if [[ $SelectedArch == "linux-powerpc" ]]; then
StartEmuRootShell_RootPath="/emuroot/powerpc-linux-gnu/"
start-emuroot-shell
fi
if [[ $SelectedArch == "linux-powerpc64" ]]; then
StartEmuRootShell_RootPath="/emuroot/powerpc64-linux-gnu/"
start-emuroot-shell
fi
if [[ $SelectedArch == "linux-powerpc64le" ]]; then
StartEmuRootShell_RootPath="/emuroot/powerpc64le-linux-gnu"
start-emuroot-shell
fi
if [[ $SelectedArch == "linux-s390x" ]]; then
StartEmuRootShell_RootPath="/emuroot/s390x-linux-gnu"
start-emuroot-shell
fi
if [[ $SelectedArch == "linux-x86_64" ]]; then
StartEmuRootShell_RootPath="/emuroot/x86_64-linux-gnu"
start-emuroot-shell
fi
}
checkifinstalled
startarchmenu