Browse Source

Check we're in an umbrel-dev environment before running commands

umbrel-beta
Luke Childs 5 years ago
parent
commit
46743a2aa7
  1. 22
      umbrel-dev

22
umbrel-dev

@ -59,6 +59,18 @@ get_script_location() {
echo $dir echo $dir
} }
check_umbrel_dev_environment() {
filename=".umbrel-dev"
dir=$PWD
while [ ! -e "$dir/$filename" ]; do
dir=${dir%/*}
if [[ "$dir" = "" ]]; then
echo "Error: This doesn't seem to be an umbrel-dev environment."
exit 1
fi
done
}
# Check deps before running any commands # Check deps before running any commands
check_dependencies check_dependencies
@ -99,6 +111,8 @@ if [[ "$command" = "init" ]]; then
fi fi
done done
touch .umbrel-dev
echo echo
echo "Your development environment is now setup" echo "Your development environment is now setup"
echo "You can boot your development VM with:" echo "You can boot your development VM with:"
@ -109,30 +123,35 @@ fi
# Boot the development VM # Boot the development VM
if [[ "$command" = "boot" ]]; then if [[ "$command" = "boot" ]]; then
check_umbrel_dev_environment
vagrant up vagrant up
exit exit
fi fi
# Halt the development VM # Halt the development VM
if [[ "$command" = "halt" ]]; then if [[ "$command" = "halt" ]]; then
check_umbrel_dev_environment
vagrant halt vagrant halt
exit exit
fi fi
# Destroy the development VM # Destroy the development VM
if [[ "$command" = "destroy" ]]; then if [[ "$command" = "destroy" ]]; then
check_umbrel_dev_environment
vagrant destroy vagrant destroy
exit exit
fi fi
# List container services # List container services
if [[ "$command" = "containers" ]]; then if [[ "$command" = "containers" ]]; then
check_umbrel_dev_environment
run_in_vm "docker-compose config --services" run_in_vm "docker-compose config --services"
exit exit
fi fi
# Rebuild a container service # Rebuild a container service
if [[ "$command" = "rebuild" ]]; then if [[ "$command" = "rebuild" ]]; then
check_umbrel_dev_environment
if [ -z ${2+x} ]; then if [ -z ${2+x} ]; then
echo "A second argument is required!" echo "A second argument is required!"
exit 1 exit 1
@ -148,12 +167,14 @@ fi
# Stream Umbrel logs # Stream Umbrel logs
if [[ "$command" = "logs" ]]; then if [[ "$command" = "logs" ]]; then
check_umbrel_dev_environment
run_in_vm "docker-compose logs -f" run_in_vm "docker-compose logs -f"
exit exit
fi fi
# Run a command inside the development VM # Run a command inside the development VM
if [[ "$command" = "run" ]]; then if [[ "$command" = "run" ]]; then
check_umbrel_dev_environment
if [ -z ${2+x} ]; then if [ -z ${2+x} ]; then
echo "A second argument is required!" echo "A second argument is required!"
exit 1 exit 1
@ -164,6 +185,7 @@ fi
# Get an SSH session inside the development VM # Get an SSH session inside the development VM
if [[ "$command" = "ssh" ]]; then if [[ "$command" = "ssh" ]]; then
check_umbrel_dev_environment
run_in_vm bash run_in_vm bash
exit exit
fi fi

Loading…
Cancel
Save