mirror of
https://github.com/balena-io/open-balena.git
synced 2024-12-18 21:27:52 +00:00
bd638ac409
Vagrant machine is based on Ubuntu 18.04 including: - docker - docker-compose Provisions some helper functions to the CLI: - dc (shortcut to ./scripts/compose) - enter {service} (opens a terminal in the service's container) - logs {service} (access the journal of the service) Change-type: patch Signed-off-by: Rich Bayliss <rich@balena.io>
51 lines
1.2 KiB
Bash
51 lines
1.2 KiB
Bash
#!/bin/bash
|
|
|
|
alias dc="/home/vagrant/openbalena/scripts/compose"
|
|
|
|
function enter () {
|
|
if [[ $# -lt 1 ]]; then
|
|
echo "Usage: enter <service name> [command]"
|
|
echo " "
|
|
echo " Runs a [command] in the service specified."
|
|
echo " "
|
|
echo " command:"
|
|
echo " (default) /bin/bash"
|
|
echo " "
|
|
echo " example:"
|
|
echo " enter api # this will run the command '/bin/bash' in the API service, providing a shell prompt"
|
|
echo " enter api uptime # this will run the command 'uptime' in the API service, and return"
|
|
return 1
|
|
fi
|
|
|
|
|
|
service="$1"
|
|
shift
|
|
COMMAND=/bin/bash
|
|
if [[ $# -gt 0 ]]; then
|
|
COMMAND="$@"
|
|
fi
|
|
dc exec ${service} /bin/bash -c "${COMMAND}"
|
|
}
|
|
|
|
function logs () {
|
|
if [[ $# -lt 1 ]]; then
|
|
echo "Usage: logs <service name> [options]"
|
|
echo " "
|
|
echo " Shows the logs from journalctl in the service specified."
|
|
echo " "
|
|
echo " options:"
|
|
echo " -f tail the log stream"
|
|
echo " -n number of lines to take"
|
|
echo " "
|
|
echo " example:"
|
|
echo " logs api -fn100 # this will tail the API log, starting with the last 100 lines"
|
|
return 1
|
|
fi
|
|
|
|
service="$1"
|
|
shift
|
|
enter ${service} journalctl "$@"
|
|
}
|
|
|
|
cd /home/vagrant/openbalena
|