mirror of
https://github.com/itzg/docker-minecraft-server
synced 2024-11-10 14:24:28 +00:00
102 lines
No EOL
1.6 KiB
Bash
102 lines
No EOL
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
function isURL {
|
|
local value=$1
|
|
|
|
if [[ ${value:0:8} == "https://" || ${value:0:7} == "http://" ]]; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
function isTrue {
|
|
local value=${1,,}
|
|
|
|
result=
|
|
|
|
case ${value} in
|
|
true|on)
|
|
result=0
|
|
;;
|
|
*)
|
|
result=1
|
|
;;
|
|
esac
|
|
|
|
return ${result}
|
|
}
|
|
|
|
function isDebugging {
|
|
if [[ -v DEBUG ]] && [[ ${DEBUG^^} = TRUE ]]; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
function debug {
|
|
if isDebugging; then
|
|
log "DEBUG: $*"
|
|
fi
|
|
}
|
|
|
|
function logn {
|
|
echo -n "[init] $*"
|
|
}
|
|
|
|
function log {
|
|
echo "[init] $*"
|
|
}
|
|
|
|
function logAutopause {
|
|
echo "[Autopause loop] $*"
|
|
}
|
|
|
|
function logAutopauseAction {
|
|
echo "[$(date -Iseconds)] [Autopause] $*"
|
|
}
|
|
|
|
function normalizeMemSize {
|
|
local scale=1
|
|
case ${1,,} in
|
|
*k)
|
|
scale=1024;;
|
|
*m)
|
|
scale=1048576;;
|
|
*g)
|
|
scale=1073741824;;
|
|
esac
|
|
|
|
val=${1:0: -1}
|
|
echo $(( val * scale ))
|
|
}
|
|
|
|
function versionLessThan {
|
|
local activeParts
|
|
IFS=. read -ra activeParts <<< "${VANILLA_VERSION}"
|
|
|
|
local givenParts
|
|
IFS=. read -ra givenParts <<< "$1"
|
|
|
|
if (( ${#activeParts[@]} < 2 )); then
|
|
return 1
|
|
fi
|
|
|
|
if (( ${#activeParts[@]} == 2 )); then
|
|
if (( activeParts[0] < givenParts[0] )) || \
|
|
(( activeParts[0] == givenParts[0] && activeParts[1] < givenParts[1] )); then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
else
|
|
if (( activeParts[0] < givenParts[0] )) || \
|
|
(( activeParts[0] == givenParts[0] && activeParts[1] < givenParts[1] )) || \
|
|
(( activeParts[0] == givenParts[0] && activeParts[1] == givenParts[1] && activeParts[2] < givenParts[2] )); then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
fi
|
|
} |