Skip to content

Commit

Permalink
unisntall order
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza787b committed Aug 26, 2024
1 parent fa434bf commit ee75066
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions setup/setup_px4_sitl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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..."
Expand Down

0 comments on commit ee75066

Please sign in to comment.