#!/bin/sh

# Set the directory path
DIR="/opt/PokeMMO"

# Change ownership to allow the current user access (requires root privileges)
sudo chown -R $(whoami):$(whoami) "$DIR"

# Set read and write permissions for all users
sudo chmod -R 777 "$DIR"

# Verify ownership and permissions (debugging)
echo "Ownership and permissions after changes:"
ls -ld "$DIR"
ls -l "$DIR"

# Change to the directory
cd "$DIR" || { echo "Failed to change directory to $DIR"; exit 1; }

# Execute the application
exec "$DIR/PokeMMO.sh" "$@"
