diff --git a/tools/install_ubuntu_dependencies.sh b/tools/install_ubuntu_dependencies.sh index 67b28fa28..a7cf0e75c 100755 --- a/tools/install_ubuntu_dependencies.sh +++ b/tools/install_ubuntu_dependencies.sh @@ -12,6 +12,11 @@ if [[ ! $(id -u) -eq 0 ]]; then SUDO="sudo" fi +# Check if stdin is open +if [ -t 0 ]; then + INTERACTIVE=1 +fi + # Install common packages function install_ubuntu_common_requirements() { $SUDO apt-get update @@ -133,7 +138,7 @@ if [ -f "/etc/os-release" ]; then esac # Install extra packages - if [[ -z "$INSTALL_EXTRA_PACKAGES" ]]; then + if [[ -z "$INSTALL_EXTRA_PACKAGES" && -n "$INTERACTIVE" ]]; then read -p "Base setup done. Do you want to install extra development packages? [Y/n]: " -n 1 -r echo "" if [[ $REPLY =~ ^[Yy]$ ]]; then diff --git a/tools/setup.sh b/tools/setup.sh index e770ba48a..b2b9563d3 100755 --- a/tools/setup.sh +++ b/tools/setup.sh @@ -73,9 +73,14 @@ function check_dir() { return 1 fi + # already a "valid" openpilot clone, skip cloning again + if [[ ! -z "$(ls -A $OPENPILOT_ROOT)" ]]; then + SKIP_GIT_CLONE=1 + fi + # by default, don't try installing in already existing directory if [[ -z $INTERACTIVE ]]; then - return 1 + return 0 fi read -p " Would you like to attempt installation anyway? [Y/n] " -n 1 -r @@ -84,11 +89,6 @@ function check_dir() { return 1 fi - # already a "valid" openpilot clone, skip cloning again - if [[ ! -z "$(ls -A $OPENPILOT_ROOT)" ]]; then - SKIP_GIT_CLONE=1 - fi - return 0 fi @@ -123,10 +123,10 @@ function git_clone() { function install_with_op() { cd $OPENPILOT_ROOT $OPENPILOT_ROOT/tools/op.sh install - $OPENPILOT_ROOT/tools/op.sh setup + $OPENPILOT_ROOT/tools/op.sh setup || (echo -e "\n[${RED}✗${NC}] failed to install openpilot!" && return 1) echo -e "\n----------------------------------------------------------------------" - echo -e "openpilot was successfully installed into ${BOLD}$OPENPILOT_ROOT${NC}" + echo -e "[${GREEN}✔${NC}] openpilot was successfully installed into ${BOLD}$OPENPILOT_ROOT${NC}" echo -e "Checkout the docs at https://docs.comma.ai" echo -e "Checkout how to contribute at https://github.com/commaai/openpilot/blob/master/docs/CONTRIBUTING.md" }