Added runtipictl out-of-jlmkr helper script
The script will be used to manage runtipi from outside the jailmaker created systemd-nspawn namespace container. TODO: Will need to modify the script to work within the runtipi instance in cases where not working with jailmaker
This commit is contained in:
parent
eb523152a4
commit
900c27c4a0
|
@ -0,0 +1,89 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
jlmkr () {
|
||||||
|
sudo VISUAL="${VISUAL:-}" EDITOR="${EDITOR:-}" $SCALE_POOL_ROOT/jailmaker/jlmkr.py "${@:---help}"
|
||||||
|
}
|
||||||
|
|
||||||
|
JAIL_UID=${JAIL_UID:-${UID}}
|
||||||
|
|
||||||
|
jlmkr-exec () {
|
||||||
|
local cli='cd /srv/runtipi; '"${1:?Must supply command} "${2:+"$(
|
||||||
|
printf '\"%s\" ' "${@:2}"
|
||||||
|
)"}
|
||||||
|
|
||||||
|
if jlmkr exec runtipi true; then
|
||||||
|
[ -n "$QUIET" ] || printf 'jlmkr UID:\t%s\ncli:\t\t%s\n' "${JAIL_UID}" "$cli"
|
||||||
|
jlmkr shell --uid "${JAIL_UID}" runtipi /bin/bash -c "$cli"
|
||||||
|
else
|
||||||
|
echo "ERROR: ${_ERROR_MGS:-"Please check if runtipi jail has started! Have you tried 'full-start'?"}" >&2
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
runtipi-cli() {
|
||||||
|
jlmkr-exec ./runtipi-cli "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
runtipi-app-docker-compose() {
|
||||||
|
local APP="${1:-Must supply app name}"
|
||||||
|
local LOCAL_YML="user-config/${APP}/docker-compose.yml"
|
||||||
|
|
||||||
|
jlmkr exec runtipi test -e "/srv/runtipi/${LOCAL_YML}" || LOCAL_YML=""
|
||||||
|
[ -z "$LOCAL_YML" ] || LOCAL_YML="--file ${LOCAL_YML}"
|
||||||
|
|
||||||
|
jlmkr-exec docker compose \
|
||||||
|
--env-file user-config/.env.local \
|
||||||
|
--env-file app-data/${APP}/app.env \
|
||||||
|
--env-file user-config/${APP}/app.env \
|
||||||
|
--project-name ${APP} \
|
||||||
|
--file apps/${APP}/docker-compose.yml \
|
||||||
|
--file repos/29ca930bfdaffa1dfabf5726336380ede7066bc53297e3c0c868b27c97282903/apps/docker-compose.common.yml \
|
||||||
|
${LOCAL_YML} ${@:2}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "${1}" in
|
||||||
|
cli)
|
||||||
|
runtipi-cli "${@:2}"
|
||||||
|
;;
|
||||||
|
log)
|
||||||
|
jlmkr-exec docker compose --env-file user-config/.env.local logs --tail=${TAIL:-40} "${2:-runtipi}" ${3:+"${@:3}"}
|
||||||
|
;;
|
||||||
|
start)
|
||||||
|
runtipi-cli start --env-file user-config/.env.local --no-permissions
|
||||||
|
;;
|
||||||
|
full-start)
|
||||||
|
if ! jlmkr exec runtipi true; then
|
||||||
|
jlmkr start runtipi
|
||||||
|
sleep 1s
|
||||||
|
fi
|
||||||
|
_ERROR_MSG="ERROR: failed to invoke a command inside the runtipi jail and can't start the jail." \
|
||||||
|
runtipi-cli start --env-file user-config/.env.local --no-permissions
|
||||||
|
;;
|
||||||
|
exec)
|
||||||
|
jlmkr-exec "${@:2}"
|
||||||
|
;;
|
||||||
|
docker)
|
||||||
|
jlmkr-exec docker "${@:2}"
|
||||||
|
;;
|
||||||
|
dcoapp)
|
||||||
|
runtipi-app-docker-compose "${@:2}"
|
||||||
|
;;
|
||||||
|
setup)
|
||||||
|
ln -s "${BASH_SOURCE[0]}" "$HOME/.local/bin/"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
printf '%s\n' \
|
||||||
|
"Usage:" \
|
||||||
|
"" \
|
||||||
|
"cli" \
|
||||||
|
"log" \
|
||||||
|
"start" \
|
||||||
|
"full-start" \
|
||||||
|
"exec" \
|
||||||
|
"docker" \
|
||||||
|
"dcoapp" \
|
||||||
|
"setup"
|
||||||
|
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
Loading…
Reference in New Issue