feat: flag -u to exec as user
This commit is contained in:
parent
f4892f14cf
commit
d239c11170
10
dlinux
10
dlinux
@ -21,8 +21,8 @@ $0 stats - Get your container memory usage statistics
|
|||||||
$0 time - Get your container expiration time
|
$0 time - Get your container expiration time
|
||||||
$0 rootpass - Reset root user password
|
$0 rootpass - Reset root user password
|
||||||
$0 key-time - Get your api key expiration time
|
$0 key-time - Get your api key expiration time
|
||||||
$0 exec - Execute a command in your container
|
$0 exec [--user user] [--pwd directory] --cmd command - Execute a command in your container
|
||||||
$0 notify - Send a message DM to your discord
|
$0 notify <message> - Send a message DM to your discord
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,14 +97,20 @@ command_key-time() {
|
|||||||
command_exec() {
|
command_exec() {
|
||||||
while test $# -gt 0; do
|
while test $# -gt 0; do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
--user|-u) user=$2; shift ;;
|
||||||
--pwd|-p) pwd=$2; shift ;;
|
--pwd|-p) pwd=$2; shift ;;
|
||||||
--cmd|-c) cmd=$2; shift ;;
|
--cmd|-c) cmd=$2; shift ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
user=${user:-"root"}
|
||||||
pwd=${pwd:-"/"}
|
pwd=${pwd:-"/"}
|
||||||
|
|
||||||
|
if ! test $user == "root"; then
|
||||||
|
cmd="runuser -u $user -- $cmd"
|
||||||
|
fi
|
||||||
|
|
||||||
call_api POST exec "{\"pwd\":\"$pwd\",\"cmd\":\"$cmd\"}" | jq -r .stdout
|
call_api POST exec "{\"pwd\":\"$pwd\",\"cmd\":\"$cmd\"}" | jq -r .stdout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user