update script added

pull/18/head
accius 3 days ago
parent 73e3fce32e
commit 8d23c9ca49

@ -9,6 +9,8 @@ All notable changes to OpenHamClock will be documented in this file.
- `.env` is auto-created from `.env.example` on first run - `.env` is auto-created from `.env.example` on first run
- Settings won't be overwritten by git updates - Settings won't be overwritten by git updates
- Supports: CALLSIGN, LOCATOR, PORT, HOST, UNITS, TIME_FORMAT, THEME, LAYOUT - Supports: CALLSIGN, LOCATOR, PORT, HOST, UNITS, TIME_FORMAT, THEME, LAYOUT
- **Update script** - Easy updates for local/Pi installations (`./scripts/update.sh`)
- Backs up config, pulls latest, rebuilds, preserves settings
- **Network access configuration** - Set `HOST=0.0.0.0` to access from other devices - **Network access configuration** - Set `HOST=0.0.0.0` to access from other devices
- **Grid locator auto-conversion** - Automatically calculates lat/lon from LOCATOR - **Grid locator auto-conversion** - Automatically calculates lat/lon from LOCATOR
- **Setup wizard** - Settings panel auto-opens if CALLSIGN or LOCATOR is missing - **Setup wizard** - Settings panel auto-opens if CALLSIGN or LOCATOR is missing

@ -224,6 +224,25 @@ The backend server provides:
## 🚀 Deployment ## 🚀 Deployment
### Raspberry Pi
One-line install for Raspberry Pi:
```bash
curl -sSL https://raw.githubusercontent.com/k0cjh/openhamclock/main/scripts/setup-pi.sh | bash
```
Or with kiosk mode (auto-starts fullscreen on boot):
```bash
curl -sSL https://raw.githubusercontent.com/k0cjh/openhamclock/main/scripts/setup-pi.sh | bash -s -- --kiosk
```
After installation:
```bash
cd ~/openhamclock
nano .env # Edit your callsign and locator
./restart.sh
```
### Railway ### Railway
```bash ```bash
# railway.toml and railway.json are included # railway.toml and railway.json are included
@ -241,6 +260,34 @@ npm run build
NODE_ENV=production node server.js NODE_ENV=production node server.js
``` ```
## 🔄 Updating
For local/Pi installations, use the update script:
```bash
cd ~/openhamclock
./scripts/update.sh
```
The update script will:
1. ✅ Back up your `.env` configuration
2. ✅ Pull the latest code from GitHub
3. ✅ Install any new dependencies
4. ✅ Rebuild the frontend
5. ✅ Preserve your settings
Then restart the server:
```bash
sudo systemctl restart openhamclock
# or
./restart.sh
```
**Note:** If you installed from a zip file (not git clone), you'll need to:
1. Back up your `.env` file
2. Download the new zip
3. Extract and restore your `.env`
## 🤝 Contributing ## 🤝 Contributing
1. Fork the repository 1. Fork the repository

@ -140,12 +140,18 @@ setup_repository() {
git pull git pull
else else
echo "Cloning repository..." echo "Cloning repository..."
git clone https://github.com/accius/openhamclock.git "$INSTALL_DIR" git clone https://github.com/k0cjh/openhamclock.git "$INSTALL_DIR"
cd "$INSTALL_DIR" cd "$INSTALL_DIR"
fi fi
# Install npm dependencies # Install npm dependencies
npm install --production npm install
# Build frontend for production
npm run build
# Make update script executable
chmod +x scripts/update.sh 2>/dev/null || true
echo -e "${GREEN}✓ OpenHamClock installed to $INSTALL_DIR${NC}" echo -e "${GREEN}✓ OpenHamClock installed to $INSTALL_DIR${NC}"
} }
@ -317,6 +323,7 @@ print_summary() {
echo -e " ${BLUE}Web Interface:${NC} http://localhost:3000" echo -e " ${BLUE}Web Interface:${NC} http://localhost:3000"
echo "" echo ""
echo -e " ${YELLOW}Helper Commands:${NC}" echo -e " ${YELLOW}Helper Commands:${NC}"
echo " $INSTALL_DIR/scripts/update.sh - Update to latest version"
echo " $INSTALL_DIR/start.sh - Start server manually" echo " $INSTALL_DIR/start.sh - Start server manually"
echo " $INSTALL_DIR/stop.sh - Stop everything" echo " $INSTALL_DIR/stop.sh - Stop everything"
echo " $INSTALL_DIR/restart.sh - Restart server" echo " $INSTALL_DIR/restart.sh - Restart server"

@ -0,0 +1,138 @@
#!/bin/bash
# OpenHamClock Update Script
# Updates to the latest version while preserving your configuration
set -e
echo "╔═══════════════════════════════════════════════════════╗"
echo "║ OpenHamClock Update Script ║"
echo "╚═══════════════════════════════════════════════════════╝"
echo ""
# Check if we're in the right directory
if [ ! -f "server.js" ] || [ ! -f "package.json" ]; then
echo "❌ Error: Please run this script from the openhamclock directory"
echo " cd /path/to/openhamclock"
echo " ./scripts/update.sh"
exit 1
fi
# Check if git is available
if ! command -v git &> /dev/null; then
echo "❌ Error: git is not installed"
echo " sudo apt install git"
exit 1
fi
# Check if this is a git repository
if [ ! -d ".git" ]; then
echo "❌ Error: This doesn't appear to be a git repository"
echo " If you installed from a zip file, you'll need to:"
echo " 1. Back up your .env file"
echo " 2. Download the new version"
echo " 3. Extract and copy your .env back"
exit 1
fi
echo "📋 Current version:"
grep '"version"' package.json | head -1
echo ""
echo "🔍 Checking for updates..."
# Fetch latest changes
git fetch origin
# Check if there are updates
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse origin/main 2>/dev/null || git rev-parse origin/master)
if [ "$LOCAL" = "$REMOTE" ]; then
echo "✅ Already up to date!"
exit 0
fi
echo "📦 Updates available!"
echo ""
# Show what's new
echo "📝 Changes since your version:"
git log --oneline HEAD..origin/main 2>/dev/null || git log --oneline HEAD..origin/master
echo ""
# Confirm update
read -p "🔄 Do you want to update? (y/N) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "❌ Update cancelled"
exit 0
fi
echo ""
echo "🛡️ Backing up configuration..."
# Backup .env if it exists
if [ -f ".env" ]; then
cp .env .env.backup
echo " ✓ .env → .env.backup"
fi
# Backup any other local config
if [ -f "config.json" ]; then
cp config.json config.json.backup
echo " ✓ config.json → config.json.backup"
fi
echo ""
echo "⬇️ Pulling latest changes..."
git pull origin main 2>/dev/null || git pull origin master
echo ""
echo "📦 Installing dependencies..."
npm install
echo ""
echo "🔨 Building frontend..."
npm run build
echo ""
echo "🔄 Restoring configuration..."
# Restore .env (should still be there since it's gitignored, but just in case)
if [ -f ".env.backup" ] && [ ! -f ".env" ]; then
cp .env.backup .env
echo " ✓ .env restored from backup"
fi
# Restore config.json if needed
if [ -f "config.json.backup" ] && [ ! -f "config.json" ]; then
cp config.json.backup config.json
echo " ✓ config.json restored from backup"
fi
echo ""
echo "📋 New version:"
grep '"version"' package.json | head -1
echo ""
echo "╔═══════════════════════════════════════════════════════╗"
echo "║ ✅ Update Complete! ║"
echo "╚═══════════════════════════════════════════════════════╝"
echo ""
echo "🔄 Restart the server to apply changes:"
echo ""
# Check if running as systemd service
if systemctl is-active --quiet openhamclock 2>/dev/null; then
echo " sudo systemctl restart openhamclock"
else
echo " # If running in terminal, press Ctrl+C and run:"
echo " npm start"
echo ""
echo " # If running as a service:"
echo " sudo systemctl restart openhamclock"
fi
echo ""
echo "📖 See CHANGELOG.md for what's new"
echo ""
Loading…
Cancel
Save

Powered by TurnKey Linux.