Skip to content

Commit 999a5c2

Browse files
upgrade script
1 parent ee0e142 commit 999a5c2

File tree

1 file changed

+40
-33
lines changed

1 file changed

+40
-33
lines changed

scripts/udroid/udroid.sh

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@ _login() {
2323

2424
varient=$1; shift
2525
extra_args=$*
26-
default_suite="impish"
2726

2827
cd "$D_INSTALLED_ROOTFS" || die "$D_INSTALLED_ROOTFS Not Found.."
2928
avalible_distros=$(find $D_INSTALLED_ROOTFS -maxdepth 1 -type d | grep udroid)
3029
cd "$OLDPWD" || exit
3130

32-
if [ -z "$UDROID_SUITE" ]; then
31+
if [ -z "$UDROID_SUITE" ] || [ -z "$_SUITE" ] ; then
3332
suite="udroid-focal"
3433
else
3534
suite="$UDROID_SUITE"
36-
msg "udroid suite [\$UDROID_SUITE] is set to ${UDROID_SUITE}"
35+
msg "udroid suite is set to ${UDROID_SUITE}"
3736
fi
3837

3938
distro="$suite-$varient"
@@ -56,15 +55,15 @@ start() {
5655

5756
# start Pulse Audio tcp receiver
5857

59-
imsg "Starting pulseaudio"
58+
imsg "Starting pulseaudio at 127.0.0.1"
6059

6160
# TODO: CHECK IS Pulseaudio RUNNING BEFORE EXECUTING
6261
pulseaudio \
6362
--start \
6463
--load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" \
6564
--exit-idle-time=-1 >> /dev/null
6665

67-
imsg "Starting $distro.."
66+
imsg "Starting $distro.. with args\n--bind /dev/null:/proc/sys/kernel/cap_last_cap\n--shared-tmp "
6867
proot-distro login "$distro" --bind /dev/null:/proc/sys/kernel/cap_last_cap \
6968
--shared-tmp \
7069
$extra_args
@@ -138,7 +137,7 @@ _install() {
138137
final_suite="udroid-$suite-$varient"
139138
local_target="${D_SCRIPTS}/${final_suite}.sh"
140139
if is_installed $final_suite; then
141-
msg "$SUITE already installed."
140+
die "$SUITE already installed."
142141
exit 1
143142
fi
144143

@@ -150,35 +149,42 @@ _install() {
150149
proot-distro install $final_suite
151150
}
152151
_reset() {
153-
case $1 in
154-
mate) SUITE="mate";;
155-
xfce|xfce4) SUITE="xfce4" ;;
156-
kde) SUITE="kde";;
157-
esac
158152

159-
suite="udroid-impish-$SUITE"
153+
avalible_distros=$(find $D_INSTALLED_ROOTFS -maxdepth 1 -type d | grep udroid)
154+
varient=$1
160155

161-
if is_installed "$suite"; then
156+
if [ -z "$UDROID_SUITE" ] || [ -z "$_SUITE" ] ; then
157+
_suite="udroid-focal"
158+
else
159+
_suite="$UDROID_SUITE"
160+
msg "udroid suite is set to ${UDROID_SUITE}"
161+
fi
162+
suite="${_suite}-$varient"
163+
if is_installed "$suite" && [[ $avalible_distros =~ $distro ]]; then
164+
imsg "Executing $(which proot-distro) reset $suite"
162165
proot-distro reset $suite
163166
else
164167
lwarn "$SUITE is not installed."
165168
fi
166169
}
167170

168171
remove() {
169-
case $1 in
170-
mate) SUITE="mate";;
171-
xfce|xfce4) SUITE="xfce4" ;;
172-
kde) SUITE="kde";;
173-
esac
174-
175-
suite="udroid-impish-$SUITE"
176-
177-
if is_installed "$suite"; then
178-
proot-distro remove $suite
179-
else
180-
lwarn "$SUITE is not installed."
181-
fi
172+
avalible_distros=$(find $D_INSTALLED_ROOTFS -maxdepth 1 -type d | grep udroid)
173+
varient=$1
174+
175+
if [ -z "$UDROID_SUITE" ] || [ -z "$_SUITE" ] ; then
176+
_suite="udroid-focal"
177+
else
178+
_suite="$UDROID_SUITE"
179+
msg "udroid suite is set to ${UDROID_SUITE}"
180+
fi
181+
suite="${_suite}-$varient"
182+
183+
if is_installed "$suite"; then
184+
proot-distro remove $suite
185+
else
186+
lwarn "$SUITE is not installed."
187+
fi
182188
}
183189

184190
upgrade() {
@@ -211,7 +217,7 @@ is_installed() {
211217
return 1
212218
fi
213219

214-
if [ ! -d "${D_INSTALLED_ROOTFS}/${target_suite}.sh" ]; then
220+
if [ ! -d "${D_INSTALLED_ROOTFS}/${target_suite}" ]; then
215221
return 1
216222
fi
217223

@@ -231,14 +237,15 @@ if [ ! -d "$D_CACHCE" ]; then
231237
mkdir -p "$D_CACHCE"
232238
fi
233239

234-
if [ $# -ge 0 ]; then
240+
while [ $# -gt 0 ]; do
235241
case $1 in
242+
--suite) shift; _SUITE="$1" ;;
236243
-l) shift; _login $* ;;
237-
-i|--install) shift;_install $1 ;;
238-
-re|--reset) shift ; _reset $1 ;;
239-
-r|--remove) shift ; _remove $1 ;;
240-
-S|--sync|--upgrade) upgrade ;;
244+
-i|--install) shift;_install $1; exit 0 ;;
245+
-re|--reset) shift ; _reset $1; exit 0 ;;
246+
-r|--remove) shift ; _remove $1; exit 0 ;;
247+
-S|--sync|--upgrade) upgrade; exit 0 ;;
241248
*) l_login $*;;
242249
esac
243-
fi
250+
done
244251

0 commit comments

Comments
 (0)