initial commit

This commit is contained in:
klein panic
2024-09-29 01:38:09 -04:00
commit fea111b0a8
3070 changed files with 991044 additions and 0 deletions

35
build/camera-command.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# Step 1: Determine if the program is installed system-wide or locally
if [ -f "/usr/local/bin/translate" ]; then
echo "System-wide installation detected."
VENV_DIR="/lib/python-venvs/camera-op-env"
SRC_FILE="/usr/local/share/camera-op/src/camera-command.py"
else
echo "Local installation detected."
# Determine the directory the script is being run from
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_DIR="$DIR/../venv"
SRC_FILE="$DIR/../src/camera-command.py"
fi
# Step 2: Double check that the virtual environments exist
if [ ! -d "$VENV_DIR" ]; then
echo "Virtual environment not found at: $VENV_DIR"
echo "Please run the install script to set up the necessary environment."
exit 1
fi
# Print debugging information
echo "Using virtual environment at: $VENV_DIR"
echo "Using source file at: $SRC_FILE"
# Step 3: Use the virtual environment's python3 to run the main.py script
"$VENV_DIR/bin/python3" "$SRC_FILE" "$@"
# Check for errors in running the script
if [ $? -ne 0 ]; then
echo "An error occurred while running the camera-op"
exit 1
fi

109
build/install.sh Executable file
View File

@@ -0,0 +1,109 @@
#!/usr/bin/env bash
# Function to check for required dependencies
check_dependencies() {
echo "Checking for required dependencies..."
# Check if Python is installed
if ! command -v python3 &> /dev/null; then
echo "Python3 is not installed. Please install it and try again."
exit 1
fi
# Check if venv is installed
if ! python3 -m venv --help &> /dev/null; then
echo "Python venv is not installed. Please install it and try again."
exit 1
fi
echo "All dependencies are satisfied."
}
# Function to choose installation type
choose_install_type() {
echo "Do you want to install the program locally or system-wide?"
echo "0) Cancel"
echo "1) Locally (current user)"
echo "2) System-wide (requires sudo)"
read -p "Choose an option [0/1/2]: " install_option
# Check if the input is valid
if [[ -z "$install_option" || ! "$install_option" =~ ^[012]$ ]]; then
echo "Invalid option. Exiting."
exit 1
fi
# If the user chooses to cancel
if [ "$install_option" -eq 0 ]; then
echo "Installation canceled."
exit 0
fi
return $install_option
}
# Function for local installation
local_install() {
echo "Starting local installation..."
VENV_DIR="$DIR/../venv"
SRC_FILE="$DIR/../src/camera-command.py"
# Check if the virtual environment exists, if not, create it
if [ ! -d "$VENV_DIR" ]; then
echo "Creating virtual environment..."
python3 -m venv "$VENV_DIR"
fi
# Install the required packages
echo "Installing dependencies..."
"$VENV_DIR/bin/pip" install -r "$DIR/requirements.txt"
# Make the wrapper script executable
chmod +x "$DIR/camera-command.sh"
echo "Local install complete. Manually run the startup script using ./camera-command.sh"
}
# Function for system-wide installation
system_wide_install() {
echo "Starting system-wide installation..."
VENV_DIR="/lib/python-venvs/camera-op-env"
SRC_DIR="/usr/local/share/camera-op/src"
# Create a directory for system-wide Python virtual environments if it doesn't exist
if [ ! -d "/lib/python-venvs" ]; then
sudo mkdir -p /lib/python-venvs
sudo chmod 755 /lib/python-venvs
fi
# Check if the virtual environment exists, if not, create it
if [ ! -d "$VENV_DIR" ]; then
echo "Creating system-wide virtual environment..."
sudo python3 -m venv "$VENV_DIR"
fi
# Install the required packages
echo "Installing dependencies system-wide..."
sudo "$VENV_DIR/bin/pip" install -r "$DIR/requirements.txt"
# Create the necessary directories and copy the source code
sudo mkdir -p "$SRC_DIR"
sudo cp "$DIR/../src/"* "$SRC_DIR/"
sudo cp "$DIR/camera-command.sh" "/usr/local/bin/camera-op"
sudo chmod +x "/usr/local/bin/camera-op"
echo "Global install complete. Run 'camera-op' from /usr/local/bin or in the shell."
}
# Main installation logic
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
check_dependencies
choose_install_type
install_option=$?
if [ "$install_option" -eq 1 ]; then
local_install
elif [ "$install_option" -eq 2 ]; then
system_wide_install
fi

2
build/requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
numpy==2.1.0
opencv-python==4.10.0.84

67
build/uninstall.sh Executable file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# Function to confirm uninstallation
confirm_uninstall() {
echo "Are you sure you want to uninstall the camera program?"
echo "This will remove the virtual environment and all installed files."
read -p "Type 'yes' to proceed: " confirmation
if [ "$confirmation" != "yes" ]; then
echo "Uninstallation canceled."
exit 0
fi
}
# Function for local uninstallation
local_uninstall() {
VENV_DIR="$DIR/../venv"
echo "Starting local uninstallation..."
# Remove the virtual environment directory
if [ -d "$VENV_DIR" ]; then
echo "Removing virtual environment..."
rm -rf "$VENV_DIR"
fi
# echo "Removing source code..."
# rm -rf "$DIR/../src/camera-command.py"
echo "Local uninstallation complete."
}
# Function for system-wide uninstallation
system_wide_uninstall() {
echo "Starting system-wide uninstallation..."
VENV_DIR="/lib/python-venvs/camera-op"
SRC_DIR="/usr/local/share/camera-op/src"
# Remove the system-wide virtual environment
if [ -d "$VENV_DIR" ]; then
echo "Removing system-wide virtual environment..."
sudo rm -rf "$VENV_DIR"
fi
# Remove the source code directory
if [ -d "$SRC_DIR" ]; then
echo "Removing source code..."
sudo rm -rf "$SRC_DIR"
fi
if [ -f "/usr/local/bin/camera-op" ]; then
echo "Removing camera-op executable..."
sudo rm /usr/local/bin/camera-op
fi
echo "System-wide uninstallation complete."
}
# Main uninstallation logic
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
confirm_uninstall
if [ -f "/usr/local/bin/camera-op" ]; then
system_wide_uninstall
else
local_uninstall
fi