add --attach option to 'server start'

This commit is contained in:
LinuxSquare 2025-04-10 22:12:28 +02:00
parent 5b867a9599
commit d9bad54393

View file

@ -4,7 +4,7 @@ function server_help() {
usage_general
cat<<EOF
commands:
create [servername] [network name]
create [servername] [network name] (--attach)
start [servername] [port] (ip)
stop [servername]
restart [servername] [port] (ip)
@ -28,6 +28,7 @@ function server_create() {
}
function server_start() {
local DIRECTLY_ATTACH=0
if [[ ! -d "$(getValueByKey 'PODMAN_DIRECTORY')/${1}" ]]; then
log e "Directory '${1}' does not exist!"
exit 1
@ -38,6 +39,12 @@ function server_start() {
exit 1
fi
if [[ -n "${3}" ]]; then
if [[ "${3}" == "--attach" ]]; then
DIRECTLY_ATTACH=1
fi
fi
local dir="$(getValueByKey 'PODMAN_DIRECTORY')/${1}"
local software="$(getLocalConfValue ${dir} 'software')"
@ -74,6 +81,9 @@ function server_start() {
log i "Starting container '${1}' with image '${version}/${software}:${build}' on port '$([[ -n "${3}" ]] && echo ${3}:)${2}'"
startContainer "${1}" "${version}/${software}:${build}" "${2}" "${3}" "${podman_network}"
if (( DIRECTLY_ATTACH )); then
server_attach "${1}"
fi
}
function server_stop() {