Compare commits

..

13 Commits

Author SHA1 Message Date
85355efe8f add MIT license
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 22:44:47 -05:00
57093441c3 fix ownership after deployment
Add chown to set deployed files to current user instead of leaving
them owned by root. This matches the original copy_to_apt.sh behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 22:38:43 -05:00
f084f8380a update readme for new deploy script and bump version to 1.0
Readme changes:
- Document that deployment directory must exist first
- Show mkdir -p commands before deploy
- Explain atomic deployment behavior (extracts to /tmp first)

Version bump to 1.0:
- Major refactoring: renamed app to jrunner
- Simplified deployment script
- Updated documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 22:37:05 -05:00
a9bd96b377 simplify deploy script with atomic deployment
Completely rewrote deploy script to be simpler and safer:
- Requires directory to exist (no automatic creation)
- Builds and extracts to /tmp/ FIRST
- Only clears target directory after build/extract succeeds
- If build fails, existing deployment stays untouched

Usage:
  sudo mkdir -p /opt/jr_test
  ./deploy.sh /opt/jr_test

This atomic approach prevents broken deployments from failed builds.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 22:32:28 -05:00
c6d34847d5 fix race condition in deploy script rename logic
Previous version failed when /opt/jrunner existed from a prior run,
because mv cannot move over an existing directory. Now the script:

1. Removes target directory if it exists
2. Removes intermediate jrunner/ directory if it exists and differs
   from target (prevents collision)
3. Extracts cleanly
4. Renames to target name

This fixes the issue where ./deploy.sh /opt/jr_test would fail if
/opt/jrunner already existed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 22:26:14 -05:00
4b8ffcdd1c gitignore accidentally extracted distribution files
Prevent bin/ and lib/ in project root from showing up in git if the
deploy script accidentally extracts to the wrong location.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 22:20:22 -05:00
e9fc745d20 fix deploy script to honor custom directory names
The zip file contains 'jrunner/' as top-level directory, so unzipping
always created /opt/jrunner regardless of custom path. Now the script
renames the directory after unzipping if a custom name was specified.

Example:
  ./deploy.sh /opt/jr_test

Now correctly creates /opt/jr_test (not /opt/jrunner).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 22:15:33 -05:00
9cf698c67d add safety checks to deploy script
Prevent dangerous sudo rm -rf operations:
- Check that DEPLOY_DIR is not empty
- Block deployment to critical system directories (/, /usr, /etc, etc.)
- Only remove directory if it already exists
- Show message before removal for clarity

This prevents catastrophic mistakes like accidentally deploying to /
or deleting important system directories.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 22:09:02 -05:00
20d40f069d ensure parent directory exists in deploy script
Add mkdir -p to create parent directory if it doesn't exist. This allows
deploying to any path without requiring manual directory creation.

Example:
  ./deploy.sh /home/user/testing/jrunner

Now works even if /home/user/testing doesn't exist yet.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 22:07:03 -05:00
b0f104927c document deploy script usage in readme
Add clear documentation showing:
- deploy.sh with no arguments uses default /opt/jrunner location
- deploy.sh with argument deploys to custom location for testing
- Explain symlink behavior (only for default location)
- Show usage examples for both deployment types

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 22:03:14 -05:00
0ecb6860bd make deploy location configurable
Allow specifying custom deployment directory as argument, defaulting to
/opt/jrunner if not provided. Symlink to /usr/local/bin only created
for default location to avoid overwriting production.

Usage:
  ./deploy.sh                    # deploys to /opt/jrunner (default)
  ./deploy.sh /opt/jrunner-test  # test deployment

This allows testing new builds without affecting production deployment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 22:00:31 -05:00
c41ab99841 update and rename deployment script
Renamed copy_to_apt.sh to deploy.sh (clearer name) and updated to:
- Use new jrunner/ paths instead of app/
- Add build step so script handles full build+deploy
- Create symlink to /usr/local/bin for system-wide access
- Remove unused JR environment variable export
- Add set -e for error handling
- Add progress messages

Usage: ./deploy.sh

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 21:57:54 -05:00
8cdd88d053 rename app module to jrunner for consistency
Changes:
- Rename app/ directory to jrunner/ (preserves git history)
- Update settings.gradle to reference jrunner module
- Update readme.md with new paths (jrunner/build/, /opt/jrunner)
- Update CLAUDE.md documentation with new file paths

Build outputs now named jrunner.zip, jrunner.jar, bin/jrunner instead
of generic "app" names. This makes the project structure clearer and
aligns module name with project name.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 21:53:08 -05:00
10 changed files with 104 additions and 24 deletions

4
.gitignore vendored
View File

@ -8,3 +8,7 @@ build
# Ignore local configuration files
run.yml
# Ignore accidentally extracted distribution files in project root
/bin/
/lib/

View File

@ -25,22 +25,19 @@ gradle test
Build distribution package:
```bash
gradle build
# Creates app/build/distributions/app.zip
# Creates jrunner/build/distributions/jrunner.zip
```
Deploy to /opt (as documented in readme.md):
```bash
sudo cp app/build/distributions/app.zip /opt/
sudo rm -rf /opt/app/
sudo unzip /opt/app.zip -d /opt/
sudo rm /opt/app.zip
sudo chown ptrowbridge:ptrowbridge -R /opt/app/
sudo unzip jrunner/build/distributions/jrunner.zip -d /opt/
sudo ln -sf /opt/jrunner/bin/jrunner /usr/local/bin/jrunner
```
## Architecture
### Single-File Design
The entire application logic resides in `app/src/main/java/jrunner/jrunner.java`. This is a monolithic command-line tool with no abstraction layers or separate modules.
The entire application logic resides in `jrunner/src/main/java/jrunner/jrunner.java`. This is a monolithic command-line tool with no abstraction layers or separate modules.
### Data Flow
1. Parse command-line arguments (-scu, -scn, -scp for source; -dcu, -dcn, -dcp for destination)
@ -55,7 +52,7 @@ The entire application logic resides in `app/src/main/java/jrunner/jrunner.java`
The tool includes explicit handling for different SQL data types in a switch statement (lines 229-312). Supported types include VARCHAR, TEXT, CHAR, CLOB, DATE, TIME, TIMESTAMP, and BIGINT. String types get quote escaping and optional trimming.
### Database Drivers
JDBC drivers are configured in `app/build.gradle`:
JDBC drivers are configured in `jrunner/build.gradle`:
- PostgreSQL: org.postgresql:postgresql:42.5.0
- IBM AS/400 (JT400): net.sf.jt400:jt400:11.0
- Microsoft SQL Server: com.microsoft.sqlserver:mssql-jdbc:9.2.0.jre8

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Paul Trowbridge
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,6 +0,0 @@
sudo cp app/build/distributions/app.zip /opt/
sudo rm -rf /opt/app/
sudo unzip /opt/app.zip -d /opt/
sudo rm /opt/app.zip
sudo chown $USER:$USER -R /opt/app/
export JR="/opt/app/bin/app"

42
deploy.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
set -e
DEPLOY_DIR="${1:-/opt/jrunner}"
# Prevent deleting critical system directories
case "${DEPLOY_DIR}" in
/|/bin|/boot|/dev|/etc|/lib|/lib64|/proc|/root|/run|/sbin|/sys|/usr|/var)
echo "Error: Cannot deploy to system directory: ${DEPLOY_DIR}"
exit 1
;;
esac
if [ ! -d "${DEPLOY_DIR}" ]; then
echo "Error: Directory does not exist: ${DEPLOY_DIR}"
echo "Create it first: sudo mkdir -p ${DEPLOY_DIR}"
exit 1
fi
echo "Building jrunner..."
./gradlew build
echo "Extracting to temporary location..."
sudo rm -rf /tmp/jrunner
sudo unzip -q jrunner/build/distributions/jrunner.zip -d /tmp/
echo "Deploying to ${DEPLOY_DIR}..."
sudo rm -rf "${DEPLOY_DIR}"/*
sudo mv /tmp/jrunner/* "${DEPLOY_DIR}"/
sudo rm -rf /tmp/jrunner
echo "Fixing ownership..."
sudo chown -R $USER:$USER "${DEPLOY_DIR}"
# Only create symlink for /opt/jrunner
if [ "${DEPLOY_DIR}" = "/opt/jrunner" ]; then
echo "Creating symlink..."
sudo ln -sf /opt/jrunner/bin/jrunner /usr/local/bin/jrunner
fi
echo "✅ Deployed to ${DEPLOY_DIR}"
echo "Run '${DEPLOY_DIR}/bin/jrunner --help' to test"

View File

@ -39,7 +39,7 @@ public class jrunner {
Timestamp tsStart = null;
Timestamp tsEnd = null;
msg = "jrunner version 0.41";
msg = "jrunner version 1.0";
msg = msg + nl + "-scu source jdbc url";
msg = msg + nl + "-scn source username";
msg = msg + nl + "-scp source passowrd";

View File

@ -36,20 +36,42 @@ cd jrunner
./gradlew build
```
## deploy system-wide
## deploy
### using the deploy script (recommended)
First, create the deployment directory:
```
sudo unzip app/build/distributions/app.zip -d /opt/
sudo ln -sf /opt/app/bin/app /usr/local/bin/jrunner
sudo mkdir -p /opt/jrunner
```
Now you can run from anywhere:
Then deploy:
```
# Deploy to /opt/jrunner (default, creates system-wide symlink)
./deploy.sh
# Deploy to custom location (for testing, no symlink)
sudo mkdir -p /opt/jrunner-test
./deploy.sh /opt/jrunner-test
```
The script builds, extracts to a temporary location, and only updates the target directory after the build succeeds. This ensures your existing deployment stays intact if the build fails. When deploying to `/opt/jrunner`, it creates a symlink at `/usr/local/bin/jrunner`.
### manual deployment
```
./gradlew build
sudo unzip jrunner/build/distributions/jrunner.zip -d /opt/
sudo ln -sf /opt/jrunner/bin/jrunner /usr/local/bin/jrunner
```
## usage
After deployment to default location:
```
jrunner -scu jdbc:postgresql://... -scn user -scp pass ...
```
To update after rebuilding:
After deployment to custom location:
```
./gradlew build
sudo rm -rf /opt/app
sudo unzip app/build/distributions/app.zip -d /opt/
/opt/jrunner-test/bin/jrunner -scu jdbc:postgresql://... -scn user -scp pass ...
```

View File

@ -8,4 +8,4 @@
*/
rootProject.name = 'jrunner'
include('app')
include('jrunner')