From ee7506664c1721ef30b2283f4cf6ad5672e7404b Mon Sep 17 00:00:00 2001 From: Alireza Ghaderi Date: Mon, 26 Aug 2024 02:40:34 +0000 Subject: [PATCH] unisntall order --- setup/setup_px4_sitl.sh | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/setup/setup_px4_sitl.sh b/setup/setup_px4_sitl.sh index d1b73c0..0fe1b2f 100644 --- a/setup/setup_px4_sitl.sh +++ b/setup/setup_px4_sitl.sh @@ -93,29 +93,31 @@ MAVLINK_ROUTER_COMMAND="mavlink-routerd -e IP_PLACEHOLDER:14540 -e IP_PLACEHOLDE # === Repair Mode (Configurable) === REPAIR_MODE=false # Set to true if you always want full repair mode +# === Flags and Arguments === +REPAIR_MODE_FLAG="--repair" +UNINSTALL_FLAG="--uninstall" +if [[ "$1" == "$REPAIR_MODE_FLAG" ]]; then + REPAIR_MODE=true # Override repair mode from command line + shift +elif [[ "$1" == "$UNINSTALL_FLAG" ]]; then + UNINSTALL=true + shift +else + UNINSTALL=false +fi # === Check for Custom Installation Directory Parameter === if [ -n "$1" ]; then INSTALL_PATH="$1" - CLONE_PATH="$INSTALL_PATH/PX4-Autopilot-Me" - CONFIG_FILE="$INSTALL_PATH/.px4sitl_config" else INSTALL_PATH="$DEFAULT_CLONE_PATH" - CLONE_PATH="$INSTALL_PATH/PX4-Autopilot-Me" - CONFIG_FILE="$DEFAULT_CONFIG_FILE" fi +CLONE_PATH="$INSTALL_PATH/PX4-Autopilot-Me" +CONFIG_FILE="$INSTALL_PATH/.px4sitl_config" - -# === Flags and Arguments === -REPAIR_MODE_FLAG="--repair" -UNINSTALL_FLAG="--uninstall" -if [[ "$1" == "$REPAIR_MODE_FLAG" ]]; then - REPAIR_MODE=true # Override repair mode from command line - shift -elif [[ "$1" == "$UNINSTALL_FLAG" ]]; then - # Uninstall the global access command - echo "Uninstalling global access for px4xplane..." +if [ "$UNINSTALL" == true ]; then + echo "Uninstalling global access for px4xplane..." if [ -L "$HOME/bin/px4xplane" ]; then rm "$HOME/bin/px4xplane" echo "Removed global command from $HOME/bin." @@ -125,26 +127,23 @@ elif [[ "$1" == "$UNINSTALL_FLAG" ]]; then else echo "Global command not found." fi - if [ -d "$CLONE_PATH" ]; then - sudo rm -rf "$CLONE_PATH" 2>&1 | tee -a delete_log.txt + if [ -d "$CLONE_PATH" ]; then + sudo rm -rf "$CLONE_PATH" echo "Removed PX4-Autopilot-Me Cloned Repository at $CLONE_PATH." else echo "PX4-Autopilot-Me Cloned Repository not found at $CLONE_PATH." fi if [ -e "$CONFIG_FILE" ]; then - rm "$CONFIG_FILE" 2>&1 | tee -a delete_log.txt + rm "$CONFIG_FILE" echo "Removed px4sitl_config file." else echo "px4sitl_config file not found at $CONFIG_FILE." fi -fi - - - echo "Uninstallation complete." exit 0 fi + # === Create Parent Directory if Needed === if [ ! -d "$INSTALL_PATH" ]; then echo "Directory $INSTALL_PATH does not exist. Creating it..."