@@ -154,43 +154,23 @@ echo -e "e.g. \033[33m/bin/bash -c '\$(curl -fsSL https://raw. ...install.sh)\"\
154154echo -e " \033[0m"
155155echo -e " Source code at: "
156156echo -e " https://github.com/IOES-Lab/ROS2_Jazzy_MacOS_Native_AppleSilicon/install.sh\n"
157- echo -e " \033[33m⚠️ WARNING: The FAN WILL BURST out and make macbook to take off. Be warned!\033[0m"
157+ echo -e " \033[33m⚠️ WARNING: The FAN WILL BURST out and make macbook to take off. Be warned!\033[0m"
158158echo -e " \033[33m To terminate at any process, press Ctrl+C.\033[0m"
159159
160+ # Trap SIGINT (Ctrl+C) and exit cleanly
161+ trap ' echo -e "\033[31m\nInstallation aborted.\033[0m"; exit' SIGINT
162+
160163# Check if the script is running in a GitHub Actions workflow
161164if [[ -z " $GITHUB_ACTIONS " ]]; then
162- # Type yes to continue if not auto type
163- echo -e ' \033[96m\n💡 Do you want to continue? [y/n]: \033[0m'
164- # Start a background process for the countdown and automatic response
165- (
166- # Show a countdown for 10 seconds
167- for i in {10..1}
168- do
169- # shellcheck disable=SC2059
170- printf " \r Continuing in $i seconds..."
171- sleep 1
172- done
173-
174- # Clear the line
175- printf " \r"
176-
177- # Send 'y'
178- echo ' y'
179- ) &
180-
181- # Save the PID of the background process and disown it
182- bg_pid=$!
183- disown $bg_pid
184-
185- # Read the user's response in the foreground
186- read -n 1 -r response
187-
188- # If the user responded, kill the background process
189- if [[ -n " $response " ]]; then
190- kill " $bg_pid " > /dev/null 2>&1
191- fi
165+ # Prompt the user and wait for a response with a timeout of 10 seconds
166+ echo -e ' \033[96m\n💡 The installation will continue automatically in 10 seconds unless you respond. \033[0m'
167+ read -p $' \033 [96m Do you want to proceed now? [y/n]: \033 [0m' -n 1 -r -t 10 response
168+ echo # Move to a new line after the user input
169+
170+ # Default to 'y' if no response is given within the timeout
171+ response=${response:- y}
192172else
193- # If running in a GitHub Actions workflow, automatically set the response to 'y'
173+ # Automatically set the response to 'y' in a GitHub Actions workflow
194174 response=' y'
195175fi
196176
@@ -200,7 +180,6 @@ if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
200180 exit 1
201181fi
202182
203-
204183# ------------------------------------------------------------------------------
205184# Check System
206185printf ' \n\n\033[34m' ; printf ' =%.0s' {1..75}; printf ' \033[0m\n'
@@ -225,7 +204,7 @@ if [ "$(xcode-select -p)" != "/Applications/Xcode.app/Contents/Developer" ]; the
225204 ACCEPTED_LICENSE_VERSION=$( defaults read /Library/Preferences/com.apple.dt.Xcode 2> /dev/null | grep IDEXcodeVersionForAgreedToGMLicense | cut -d ' "' -f 2)
226205 # Check if the Xcode license has been accepted
227206 if [ " $XCODE_VERSION " != " $ACCEPTED_LICENSE_VERSION " ]; then
228- echo -e " \033[33m⚠️ WARNING: Xcode license needs to be accepted. Please follow the prompts to accept the license.\033[0m"
207+ echo -e " \033[33m⚠️ WARNING: Xcode license needs to be accepted. Please follow the prompts to accept the license.\033[0m"
229208 sudo xcodebuild -license
230209 # shellcheck disable=SC2181
231210 if [ $? -ne 0 ]; then
272251# Check if Installation dir already exists and warn user
273252echo -e " \033[34m> Check Installation Directory\033[0m"
274253if [ -d " $HOME /$ROS_INSTALL_ROOT " ]; then
275- echo -e " \033[33m⚠️ WARNING: The directory $ROS_INSTALL_ROOT already exists at home ($HOME )."
254+ echo -e " \033[33m⚠️ WARNING: The directory $ROS_INSTALL_ROOT already exists at home ($HOME )."
276255 echo -e " \033[33m This script will merge and overwrite the existing directory.\033[0m"
277256 echo -e " \033[96mDo you want to continue? [y/n/r/c]\033[0m"
278- read -p " (y) Merge (n) Cancel (r) Change directory, (c) Force reinstall : " -n 1 -r
257+ read -p " (y) Merge (n) Cancel (r) Change directory, (c) Clean re-install : " -n 1 -r
279258 echo
280259 if [[ $REPLY =~ ^[Yy]$ ]]; then
281260 echo -e " \033[33mMerging and overwriting existing directory...\033[0m"
@@ -324,41 +303,6 @@ brew install asio assimp bison bullet cmake console_bridge cppcheck \
324303 cunit eigen freetype graphviz opencv openssl orocos-kdl pcre poco \
325304 pyqt@5 python@3.11 qt@5 sip spdlog tinyxml tinyxml2
326305
327- # Remove unnecessary packages
328- echo -e " \033[36m\n> Removing unnecessary packages...ones that causes error, python@3.12, qt6\033[0m"
329- if brew list --formula | grep -q " python@3.12" ; then
330- echo -e " \033[31m⚠️ WARNING: Python@3.12 installation is found. Currently this does not work with ros2 jazzy."
331- if [[ -z " $GITHUB_ACTIONS " ]]; then
332- echo -e " 💡 Do you want to remove it? (y/n)\033[0m"
333- read -r response
334- if [[ " $response " =~ ^([yY][eE][sS]| [yY])$ ]]; then
335- echo -e " \033[36m> Removing python@3.12 (with ignore-dependencies)...\033[0m"
336- brew uninstall --ignore-dependencies python@3.12
337- else
338- echo -e " \033[31m> Aborting. Please manually correct your Python configuration.\033[0m"
339- exit 1
340- fi
341- else
342- brew uninstall --ignore-dependencies python@3.12
343- fi
344- fi
345- if brew list --formula | grep -q " qt6" ; then
346- echo -e " \033[31m⚠️ WARNING: qt6 installation is found. Currently this does not work with ros2 jazzy."
347- if [[ -z " $GITHUB_ACTIONS " ]]; then
348- echo -e " 💡 Do you want to remove it? (y/n)\033[0m"
349- read -r response
350- if [[ " $response " =~ ^([yY][eE][sS]| [yY])$ ]]; then
351- echo -e " \033[36m> Removing qt6 (with ignore-dependencies)...\033[0m"
352- brew uninstall --ignore-dependencies qt6
353- else
354- echo -e " \033[31m> Aborting. Please manually correct your Python configuration.\033[0m"
355- exit 1
356- fi
357- else
358- brew uninstall --ignore-dependencies qt6
359- fi
360- fi
361-
362306# Set Environment Variables of Brew packages
363307echo -e " \033[36m> Setting Environment Variables of Brew packages...(OPENSSL_ROOT_DIR, CMAKE_PREFIX_PATH, PATH)\033[0m"
364308# shellcheck disable=SC2155
@@ -608,39 +552,21 @@ echo -e "\033[33mdeactivate\033[0m"
608552
609553# Ask if user wants to install Gazebo Harmonic too (gz_install.sh)
610554echo -e " \n\n\033[32mGazebo Harmonic is simulator that is LTS pair with ROS2 Jazzy\033[0m"
611- # Type yes to continue or auto continue
555+
556+ # Trap SIGINT (Ctrl+C) and exit cleanly
557+ trap ' echo -e "\033[31m\nInstallation aborted.\033[0m"; exit' SIGINT
558+
559+ # Check if the script is running in a GitHub Actions workflow
612560if [[ -z " $GITHUB_ACTIONS " ]]; then
613- echo -e ' \033[96m\n💡 Do you want to install Gazebo Harmonic too? [y/n]: \033[0m'
614- # Start a background process for the countdown and automatic response
615- (
616- # Show a countdown for 10 seconds
617- for i in {10..1}
618- do
619- # shellcheck disable=SC2059
620- printf " \r Continuing in $i seconds..."
621- sleep 1
622- done
623-
624- # Clear the line
625- printf " \r"
626-
627- # Send 'y'
628- echo ' y'
629- ) &
630-
631- # Save the PID of the background process and disown it
632- bg_pid=$!
633- disown $bg_pid
634-
635- # Read the user's response in the foreground
636- read -n 1 -r response
637-
638- # If the user responded, kill the background process
639- if [[ -n " $response " ]]; then
640- kill " $bg_pid " > /dev/null 2>&1
641- fi
561+ # Prompt the user and wait for a response with a timeout of 10 seconds
562+ echo -e ' \033[96m\n💡 The installation will continue automatically in 10 seconds unless you respond. \033[0m'
563+ read -p $' \033 [96m Do you want to proceed now? [y/n]: \033 [0m' -n 1 -r -t 10 response
564+ echo # Move to a new line after the user input
565+
566+ # Default to 'y' if no response is given within the timeout
567+ response=${response:- y}
642568else
643- # If running in a GitHub Actions workflow, automatically set the response to 'y'
569+ # Automatically set the response to 'y' in a GitHub Actions workflow
644570 response=' y'
645571fi
646572
0 commit comments