setup.sh: work in non interactive mode (#33162)

* work without terminal

* failure message

* no if
old-commit-hash: 3e66827a85
This commit is contained in:
Maxime Desroches 2024-07-31 20:32:41 -07:00 committed by GitHub
parent 0d9b5627f2
commit ea71f07ea7
2 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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"
}