From ba24b874fc6f32034b43f97366cbb723c9e23864 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Fri, 16 Jan 2026 11:01:26 -0500 Subject: [PATCH] Add automated setup script for new installations Create setup.sh that checks for and installs dependencies: - Detects Java 11+ or offers to install via package manager - Verifies Gradle wrapper presence - Checks for unzip (needed for deployment) - Runs test build to verify everything works - Provides clear next steps after successful setup Update readme with Quick Start section featuring setup script as the recommended approach for new systems. Co-Authored-By: Claude Sonnet 4.5 --- readme.md | 63 ++++++++++++-------- setup.sh | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 214 insertions(+), 23 deletions(-) create mode 100755 setup.sh diff --git a/readme.md b/readme.md index 9b40efb..47b5eae 100644 --- a/readme.md +++ b/readme.md @@ -1,35 +1,52 @@ -## install java jdk. -find downloads page and get latest tarball. -https://www.oracle.com/java/technologies/downloads/ +## Quick Start +The easiest way to get started on a new system: + +```bash +git clone https://gitea.hptrow.me/pt/jrunner.git +cd jrunner +./setup.sh ``` + +The setup script will: +- Check for Java 11+ (offers to install if missing) +- Verify Gradle wrapper is present +- Run a test build to ensure everything works +- Show you next steps + +## Manual Installation + +If you prefer to install dependencies manually: + +### Install Java JDK + +**Option 1: Package manager (recommended)** +```bash +# Ubuntu/Debian +sudo apt update && sudo apt install openjdk-17-jdk + +# Fedora/RHEL +sudo dnf install java-17-openjdk-devel + +# Arch +sudo pacman -S jdk-openjdk +``` + +**Option 2: Manual download** +Download from https://www.oracle.com/java/technologies/downloads/ + +```bash wget https://download.oracle.com/java/19/latest/jdk-19_linux-x64_bin.tar.gz -tar -xvf downloaded_file -``` -move the extracted folder to /opt -put the extracted location in your path variable -``` +tar -xvf jdk-19_linux-x64_bin.tar.gz +sudo mv jdk-19.0.1 /opt/ export JAVA_HOME=/opt/jdk-19.0.1 export PATH=$PATH:$JAVA_HOME/bin ``` -`java --version` to test +Test: `java --version` -## install gradle (optional) +### Install Gradle (optional) Gradle wrapper (`gradlew`) is included in the repo, so manual Gradle installation is not required. -If you prefer to install Gradle system-wide: -``` -wget https://services.gradle.org/distributions/gradle-8.5-bin.zip -unzip -d /opt/gradle gradle-8.5-bin.zip -export PATH=$PATH:/opt/gradle/gradle-8.5/bin -gradle -v -``` - -## clone this repo -``` -git clone https://gitea.hptrow.me/pt/jrunner.git -cd jrunner -``` ## build ``` diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..6ffb402 --- /dev/null +++ b/setup.sh @@ -0,0 +1,174 @@ +#!/bin/bash +set -e + +echo "jrunner Development Environment Setup" +echo "=====================================" +echo "" + +# Color codes for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Check if running on Linux +if [[ "$OSTYPE" != "linux-gnu"* ]]; then + echo -e "${YELLOW}Warning: This script is designed for Linux. You may need to manually install dependencies.${NC}" + echo "" +fi + +# Function to check if command exists +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +# Function to get Java version +get_java_version() { + if command_exists java; then + java -version 2>&1 | head -n 1 | awk -F '"' '{print $2}' | awk -F '.' '{print $1}' + else + echo "0" + fi +} + +echo "Checking dependencies..." +echo "" + +# Check Java +JAVA_VERSION=$(get_java_version) +if [ "$JAVA_VERSION" -ge 11 ]; then + echo -e "${GREEN}✓${NC} Java $JAVA_VERSION detected" + java -version 2>&1 | head -n 1 + JAVA_OK=true +else + echo -e "${RED}✗${NC} Java 11+ not found" + JAVA_OK=false +fi + +# Check Git +if command_exists git; then + echo -e "${GREEN}✓${NC} Git detected" + DEPENDENCIES_OK=true +else + echo -e "${RED}✗${NC} Git not found" + DEPENDENCIES_OK=false +fi + +# Check if gradlew exists +if [ -f "./gradlew" ]; then + echo -e "${GREEN}✓${NC} Gradle wrapper found (no need to install Gradle)" + GRADLE_OK=true +else + echo -e "${YELLOW}!${NC} Gradle wrapper not found in current directory" + GRADLE_OK=false +fi + +echo "" + +# If Java is missing, offer installation help +if [ "$JAVA_OK" = false ]; then + echo -e "${YELLOW}Java 11+ is required to build and run jrunner${NC}" + echo "" + echo "Installation options:" + echo "" + echo "1. Install OpenJDK via package manager (recommended):" + echo " Ubuntu/Debian: sudo apt update && sudo apt install openjdk-17-jdk" + echo " Fedora/RHEL: sudo dnf install java-17-openjdk-devel" + echo " Arch: sudo pacman -S jdk-openjdk" + echo "" + echo "2. Download Oracle JDK manually:" + echo " Visit: https://www.oracle.com/java/technologies/downloads/" + echo " Download JDK 17+ tarball and extract to /opt" + echo " Add to PATH: export JAVA_HOME=/opt/jdk-17 && export PATH=\$PATH:\$JAVA_HOME/bin" + echo "" + + read -p "Would you like to install OpenJDK via package manager? (requires sudo) [y/N]: " install_java + + if [[ "$install_java" =~ ^[Yy]$ ]]; then + if command_exists apt; then + echo "Installing OpenJDK 17 via apt..." + sudo apt update + sudo apt install -y openjdk-17-jdk + elif command_exists dnf; then + echo "Installing OpenJDK 17 via dnf..." + sudo dnf install -y java-17-openjdk-devel + elif command_exists pacman; then + echo "Installing OpenJDK via pacman..." + sudo pacman -S --noconfirm jdk-openjdk + else + echo -e "${RED}Could not detect package manager. Please install Java manually.${NC}" + exit 1 + fi + + # Verify installation + JAVA_VERSION=$(get_java_version) + if [ "$JAVA_VERSION" -ge 11 ]; then + echo -e "${GREEN}✓ Java installed successfully${NC}" + JAVA_OK=true + else + echo -e "${RED}✗ Java installation failed${NC}" + exit 1 + fi + else + echo "" + echo "Please install Java manually and re-run this script." + exit 1 + fi +fi + +# Check for unzip (needed for deployment) +if ! command_exists unzip; then + echo -e "${YELLOW}Note: 'unzip' is recommended for deployment${NC}" + read -p "Install unzip? [y/N]: " install_unzip + if [[ "$install_unzip" =~ ^[Yy]$ ]]; then + if command_exists apt; then + sudo apt install -y unzip + elif command_exists dnf; then + sudo dnf install -y unzip + elif command_exists pacman; then + sudo pacman -S --noconfirm unzip + fi + fi +fi + +echo "" +echo -e "${GREEN}All required dependencies are installed!${NC}" +echo "" + +# Verify we're in the right directory +if [ ! -f "./gradlew" ]; then + echo -e "${RED}Error: gradlew not found. Are you in the jrunner project directory?${NC}" + exit 1 +fi + +# Make gradlew executable +chmod +x ./gradlew + +echo "Testing build system..." +if ./gradlew --version > /dev/null 2>&1; then + echo -e "${GREEN}✓${NC} Gradle wrapper working" +else + echo -e "${RED}✗${NC} Gradle wrapper failed" + exit 1 +fi + +echo "" +echo "Running test build..." +if ./gradlew build; then + echo "" + echo -e "${GREEN}✓ Build successful!${NC}" + echo "" + echo "Next steps:" + echo " 1. Install locally for testing:" + echo " ./gradlew installDist" + echo " ./jrunner/build/install/jrunner/bin/jrunner --help" + echo "" + echo " 2. Or run the interactive deploy script:" + echo " ./deploy.sh" + echo "" + echo " 3. See readme.md for usage examples" +else + echo -e "${RED}✗ Build failed${NC}" + echo "Check the error messages above and try again." + exit 1 +fi