Skip to content

Commit 6264410

Browse files
feat(experimental): run-script: change logic
1 parent f0364a8 commit 6264410

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

udroid/src/udroid.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -426,21 +426,7 @@ login() {
426426
for i in "$@"; do
427427
shell_command_args+=("'$i'")
428428
done
429-
430-
# run_script
431-
if [ -n "$run_script" ]; then
432-
if [ -f "$run_script" ]; then
433-
LOG "login() => run-script defined: ignoring command line arguments"
434-
chmod +x "$run_script"
435-
cp "$run_script" "${root_fs_path}/tmp/"
436-
run_script="/tmp/$(basename "$run_script")"
437-
shell_command_args=("/tmp/$run_script")
438-
else
439-
ELOG "ERROR: run-script '$run_script' not found!"
440-
exit 1
441-
fi
442-
fi
443-
429+
444430
if stat "${root_fs_path}/bin/su" >/dev/null 2>&1; then
445431
set -- "/bin/su" "-l" "$login_user" "-c" "${shell_command_args[*]}"
446432
else
@@ -455,7 +441,21 @@ login() {
455441
fi
456442
else
457443
if stat "${root_fs_path}/bin/su" >/dev/null 2>&1; then
458-
set -- "/bin/su" "-l" "$login_user"
444+
# run_script
445+
if [ -n "$run_script" ]; then
446+
if [ -f "$run_script" ]; then
447+
LOG "login() => run-script defined.."
448+
chmod +x "$run_script"
449+
cp "$run_script" "${root_fs_path}/tmp/"
450+
run_script="/tmp/$(basename "$run_script")"
451+
set -- "/bin/su" "-l" "$login_user" "-c" "$run_script"
452+
else
453+
ELOG "ERROR: run-script '$run_script' not found!"
454+
exit 1
455+
fi
456+
else
457+
set -- "/bin/su" "-l" "$login_user"
458+
fi
459459
else
460460
GWARN "Warning: no /bin/su available in rootfs! You may need to install package 'util-linux' or 'shadow' (shadow-utils) or equivalent, depending on distribution."
461461
if [ -x "${root_fs_path}/bin/bash" ]; then

0 commit comments

Comments
 (0)