Skip to content

Commit fc83f1e

Browse files
feat(experimental): option to run script with login arguments
1 parent 1e7efcb commit fc83f1e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

udroid/src/udroid.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ login() {
286286
local make_host_tmp_shared=true # its better to run with shared tmp
287287
local root_fs_path=""
288288
local login_user="root"
289+
local run_script=""
289290
local -a custom_fs_bindings
290291
local path=$DEFAULT_FS_INSTALL_DIR
291292

@@ -376,6 +377,9 @@ login() {
376377
--no-kill-on-exit)
377378
no_kill_on_exit=true; shift
378379
;;
380+
--run-script)
381+
run_script=$2; shift 2
382+
;;
379383
-*)
380384
echo "Unknown option: $1"
381385
exit 1
@@ -422,6 +426,20 @@ login() {
422426
for i in "$@"; do
423427
shell_command_args+=("'$i'")
424428
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
425443

426444
if stat "${root_fs_path}/bin/su" >/dev/null 2>&1; then
427445
set -- "/bin/su" "-l" "$login_user" "-c" "${shell_command_args[*]}"

0 commit comments

Comments
 (0)