|
|
@ -1,8 +1,7 @@ |
|
|
#!/usr/bin/env bash |
|
|
|
|
|
|
|
|
#!/usr/bin/env miaou-bash |
|
|
|
|
|
|
|
|
# CONSTANTS |
|
|
# CONSTANTS |
|
|
|
|
|
|
|
|
BASEDIR=$(dirname "$0") |
|
|
|
|
|
CONTAINER= |
|
|
CONTAINER= |
|
|
USER= |
|
|
USER= |
|
|
|
|
|
|
|
|
@ -38,24 +37,24 @@ function parse_options { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function incus_su { |
|
|
function incus_su { |
|
|
incus exec "$CONTAINER" -- su - $1 |
|
|
|
|
|
|
|
|
incus exec "$CONTAINER" -- su - "$1" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function incus_user_exists { |
|
|
function incus_user_exists { |
|
|
incus exec "$CONTAINER" -- id $1 &> /dev/null |
|
|
|
|
|
|
|
|
incus exec "$CONTAINER" -- id "$1" &>/dev/null |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function login { |
|
|
function login { |
|
|
if [[ -n $USER ]]; then |
|
|
if [[ -n $USER ]]; then |
|
|
incus_su $USER |
|
|
|
|
|
|
|
|
incus_su "$USER" |
|
|
else |
|
|
else |
|
|
local current=$(whoami) |
|
|
|
|
|
incus_user_exists $current && incus_su $current || incus_su root |
|
|
|
|
|
|
|
|
local current |
|
|
|
|
|
current=$(whoami) |
|
|
|
|
|
incus_user_exists "$current" && incus_su "$current" || incus_su root |
|
|
fi |
|
|
fi |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# MAIN |
|
|
# MAIN |
|
|
|
|
|
|
|
|
set -Eue |
|
|
|
|
|
parse_options $* |
|
|
|
|
|
|
|
|
parse_options "$@" |
|
|
login |
|
|
login |