Saving the day for jslave on Alpine (asgard) #1

Open
pcaseiro wants to merge 4 commits from develop into master
1 changed files with 66 additions and 0 deletions
Showing only changes of commit 4024b6f889 - Show all commits

66
init.d/dc Normal file
View File

@ -0,0 +1,66 @@
#!/sbin/openrc-run
# From https://github.com/0x17de/dockerservice-openrc
: ${SUBCFGDIR:=/srv/docker}
DOCKER_COMPOSE_UP_ARGS=${DOCKER_COMPOSE_UP_ARGS-"--no-build --no-recreate --no-deps"}
SUBSVC="${SVCNAME#*.}"
[ -z "${SUBSVC}" ] && exit 1
: ${SUBCFG:="${SUBCFGDIR}/${SUBSVC}/docker-compose.yml"}
DOCOCMD="/usr/bin/docker"
export COMPOSE_HTTP_TIMEOUT=300
description="Manage Docker services defined in ${SUBCFG}"
extra_commands="configtest build"
description_configtest="Check configuration via \"docker compose -f ${SUBCFG} config\""
description_build="Run \"docker compose -f ${SUBCFG} build\""
depend() {
need localmount net docker
use dns
after docker
}
configtest() {
if ! [ -f "${SUBCFG}" ]; then
eerror "The config file ${SUBCFG} does not exist!"
return 1
fi
"${DOCOCMD}" -f "${SUBCFG}" config >&/dev/null
if [ ${?} -ne 0 ]; then
einfo "config: ok"
else
eerror "config: error"
return 1
fi
}
build() {
configtest || return 1
ebegin "Building dockerservice ${SUBSVC}"
"${DOCOCMD}" compose -f "${SUBCFG}" build
eend $?
}
start() {
configtest || return 1
ebegin "Starting dockerservice ${SUBSVC}"
"${DOCOCMD}" compose -f "${SUBCFG}" up -d ${DOCKER_COMPOSE_UP_ARGS}
eend $?
}
stop() {
ebegin "Stopping dockerservice ${SUBSVC}"
"${DOCOCMD}" compose -f "${SUBCFG}" stop --timeout=300
eend $?
}
status() {
if [ "$("${DOCOCMD}" compose -f "${SUBCFG}" top | wc -l)" -gt "0" ]; then
einfo "status: started"
else
einfo "status: stopped"
return 3
fi
}