This commit is contained in:
Björn Ellensohn 2023-09-13 10:48:45 +02:00
parent 8ac3c46136
commit d42093e992
2 changed files with 36 additions and 3 deletions

19
install.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# Specify the name of your Python script
SCRIPT_NAME="robot_config.py"
# Check if the script exists in the current directory
if [ -f "$SCRIPT_NAME" ]; then
# Check if /usr/local/bin is writable
if [ -w "/usr/local/bin" ]; then
# Copy the script to /usr/local/bin
sudo cp "$SCRIPT_NAME" "/usr/local/bin"
sudo chmod +x "/usr/local/bin/$SCRIPT_NAME"
echo "Script '$SCRIPT_NAME' has been installed in /usr/local/bin."
else
echo "Error: /usr/local/bin is not writable. You may need to use 'sudo' to install the script."
fi
else
echo "Error: Script '$SCRIPT_NAME' not found in the current directory."
fi

View File

@ -1,5 +1,16 @@
#!/usr/bin/env python3
import os
import subprocess
# Function to get the path to the docker-compose.yaml file
def get_compose_file_path():
path = input("Enter the path to the docker-compose.yaml file (press Enter for current directory): ").strip()
return path if path else "docker-compose.yaml"
# Initialize the path to the docker-compose.yaml file
compose_file_path = get_compose_file_path()
# Define a list to keep track of running services
running_services = []
@ -11,7 +22,7 @@ def is_service_running(service_name):
def start_service(service_name):
if not is_service_running(service_name):
print(f"Starting {service_name}...")
subprocess.run(["docker", "compose", "up", "-d", service_name])
subprocess.run(["docker", "compose", "-f", compose_file_path, "up", "-d", service_name])
running_services.append(service_name)
else:
print(f"{service_name} is already running.")
@ -20,7 +31,7 @@ def start_service(service_name):
def stop_service(service_name):
if is_service_running(service_name):
print(f"Stopping {service_name}...")
subprocess.run(["docker", "compose", "down", "-v", "--remove-orphans", service_name])
subprocess.run(["docker", "compose", "-f", compose_file_path, "down", "-v", "--remove-orphans", service_name])
running_services.remove(service_name)
else:
print(f"{service_name} is not running.")
@ -33,7 +44,8 @@ if __name__ == "__main__":
print("2. Start AMCL and Navigation")
print("3. Start Mapping and Navigation")
print("4. Stop AMCL and Mapping")
print("5. Quit")
print("5. Change docker-compose.yaml file path")
print("6. Quit")
choice = input("Enter your choice: ")
@ -52,6 +64,8 @@ if __name__ == "__main__":
stop_service("amcl")
stop_service("mapping")
elif choice == "5":
compose_file_path = get_compose_file_path()
elif choice == "6":
break
else:
print("Invalid choice. Please try again.")