Add datapack & attach commands
This commit is contained in:
parent
e5f09fe7fc
commit
2efd8adeed
3 changed files with 57 additions and 25 deletions
16
pms-cli
16
pms-cli
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# CONSTANTS
|
# CONSTANTS
|
||||||
readonly PKGVER="0.0.4"
|
readonly PKGVER="0.1.0"
|
||||||
readonly LICENSE="GNU AGPLv3"
|
readonly LICENSE="GNU AGPLv3"
|
||||||
readonly ROOTPATH="$(dirname $(readlink -f $(which $0)))"
|
readonly ROOTPATH="$(dirname $(readlink -f $(which $0)))"
|
||||||
readonly TEMPLATEDIR="${ROOTPATH}/.template"
|
readonly TEMPLATEDIR="${ROOTPATH}/.template"
|
||||||
|
@ -22,9 +22,11 @@ operations:
|
||||||
$(basename ${0}) {-V --version}
|
$(basename ${0}) {-V --version}
|
||||||
$(basename ${0}) {-v --verbose}
|
$(basename ${0}) {-v --verbose}
|
||||||
$(basename ${0}) {--init} [servername]
|
$(basename ${0}) {--init} [servername]
|
||||||
|
$(basename ${0}) {--datapack} [servername] [datapack dl url]
|
||||||
$(basename ${0}) {--start} [servername] [port]
|
$(basename ${0}) {--start} [servername] [port]
|
||||||
$(basename ${0}) {--stop} [servername]
|
$(basename ${0}) {--stop} [servername]
|
||||||
$(basename ${0}) {--restart} [servername] [port]"
|
$(basename ${0}) {--restart} [servername] [port]
|
||||||
|
$(basename ${0}) {--attach} [servername]"
|
||||||
}
|
}
|
||||||
|
|
||||||
function version() {
|
function version() {
|
||||||
|
@ -40,7 +42,7 @@ the terms of the ${LICENSE}"
|
||||||
###
|
###
|
||||||
|
|
||||||
OPT_SHORT="hVv"
|
OPT_SHORT="hVv"
|
||||||
OPT_LONG="help,version,verbose,init:,start:,stop:,restart:"
|
OPT_LONG="help,version,verbose,init:,datapack:,start:,stop:,restart:,attach:"
|
||||||
|
|
||||||
TEMP=$(getopt -o ${OPT_SHORT} --long ${OPT_LONG} -n $(basename ${0}) -- "$@")
|
TEMP=$(getopt -o ${OPT_SHORT} --long ${OPT_LONG} -n $(basename ${0}) -- "$@")
|
||||||
if [ "$?" != 0 ]; then
|
if [ "$?" != 0 ]; then
|
||||||
|
@ -67,6 +69,10 @@ while true; do
|
||||||
shift
|
shift
|
||||||
init "$1"
|
init "$1"
|
||||||
;;
|
;;
|
||||||
|
--datapack)
|
||||||
|
shift
|
||||||
|
datapack "$1" "$3"
|
||||||
|
;;
|
||||||
--start)
|
--start)
|
||||||
shift
|
shift
|
||||||
start "$1" "$3"
|
start "$1" "$3"
|
||||||
|
@ -80,6 +86,10 @@ while true; do
|
||||||
stop "$1"
|
stop "$1"
|
||||||
start "$1" "$3"
|
start "$1" "$3"
|
||||||
;;
|
;;
|
||||||
|
--attach)
|
||||||
|
shift
|
||||||
|
attach "$1"
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
|
|
10
utils/attach
Normal file
10
utils/attach
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function attach() {
|
||||||
|
if [[ -z $(podman container ps | grep "$1") ]]; then
|
||||||
|
log e "Container '$1' is not running!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
log i "Attaching to container '$1'"
|
||||||
|
podman container attach "$1"
|
||||||
|
}
|
12
utils/datapack
Normal file
12
utils/datapack
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function datapack() {
|
||||||
|
if [[ ! -d "$(getValueByKey 'PODMAN_DIRECTORY')/${1}" ]]; then
|
||||||
|
log e "Directory '${1}' does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local dir="$(getValueByKey 'PODMAN_DIRECTORY')/${1}"
|
||||||
|
|
||||||
|
curl "${2}" -o "$dir"
|
||||||
|
}
|
Loading…
Reference in a new issue