From d239c111703864bc2108d0a983626a774fa38c83 Mon Sep 17 00:00:00 2001 From: CyberL1 Date: Sat, 30 Nov 2024 21:04:48 +0100 Subject: [PATCH] feat: flag -u to exec as user --- dlinux | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dlinux b/dlinux index 8910404..bd6fbc6 100755 --- a/dlinux +++ b/dlinux @@ -21,8 +21,8 @@ $0 stats - Get your container memory usage statistics $0 time - Get your container expiration time $0 rootpass - Reset root user password $0 key-time - Get your api key expiration time -$0 exec - Execute a command in your container -$0 notify - Send a message DM to your discord +$0 exec [--user user] [--pwd directory] --cmd command - Execute a command in your container +$0 notify - Send a message DM to your discord " } @@ -97,14 +97,20 @@ command_key-time() { command_exec() { while test $# -gt 0; do case $1 in + --user|-u) user=$2; shift ;; --pwd|-p) pwd=$2; shift ;; --cmd|-c) cmd=$2; shift ;; esac shift done + user=${user:-"root"} pwd=${pwd:-"/"} + if ! test $user == "root"; then + cmd="runuser -u $user -- $cmd" + fi + call_api POST exec "{\"pwd\":\"$pwd\",\"cmd\":\"$cmd\"}" | jq -r .stdout }