A simple, secure, and configurable web-based program upgrade system that supports automatic deployment and service management for multiple file formats.
English | 中文
- 🌐 Web Interface: User-friendly interface with drag-and-drop upload support
- 📦 Multi-format Support:
.tar.gz
,.zip
,.gz
, executable files - 🔧 Service Management: Automatic stop/start of systemd services
- 💾 Smart Backup: Automatic backup of existing programs with rollback support
- 🔐 Permission Management: Automatic file and executable permission setup
- ⚙️ Highly Configurable: Support for configuration files, environment variables, and command-line parameters
- 🧹 Auto Cleanup: Scheduled cleanup of temporary files
- 📊 Real-time Logging: Detailed upgrade process logs display
- 🛡️ Security Checks: File type validation and size limits
- Industrial Control System Upgrades: Remote upgrade of industrial control programs
- Edge Device Deployment: Automatic updates for IoT device programs
- Server Application Upgrades: Hot updates for production environment applications
- CI/CD Deployment: Continuous integration/continuous deployment pipelines
- Embedded Systems: Embedded device program upgrades
- Operating System: Linux (Ubuntu 18.04+, CentOS 7+, other distributions)
- Go Version: 1.18 or higher
- System Permissions: Recommended to run with root privileges (for service management)
- System Tools:
tar
,unzip
,systemctl
(optional)
# Clone repository
git clone https://github.com/linker-bot/linker-upgrader.git
cd linker-upgrader
# Compile program
go build -o linker-upgrader main.go
# TBD
# Or download pre-compiled binary
wget https://github.com/linker-bot/linker-upgrader/releases/latest/download/linker-upgrader-linux-amd64
chmod +x linker-upgrader-linux-amd64
# Generate default configuration file
./linker-upgrader -gen-config
# Configuration file will be saved to config.json
# Start with default configuration
./linker-upgrader
# Start with specified port
./linker-upgrader -port 8080
# Start with specified configuration file
./linker-upgrader -config /path/to/config.json
Open browser and visit: http://localhost:8080
{
"upload_dir": "./uploads", // Upload temporary directory
"target_dir": "/opt/myapp", // Target program directory
"backup_dir": "/opt/myapp/backup", // Backup directory
"service_name": "myapp", // systemd service name
"port": ":8080", // Service port
"max_file_size": 100, // Maximum file size (MB)
"enable_backup": true, // Enable backup functionality
"enable_service": true, // Enable service management
"enable_cleanup": true, // Enable file cleanup
"cleanup_interval": 1, // Cleanup interval (hours)
"file_max_age": 24, // File retention time (hours)
"dir_permission": "0755", // Directory permissions
"file_permission": "0644", // File permissions
"exec_permission": "0755", // Executable file permissions
"title": "🚀 Linker - Program Upgrade System", // Page title
"description": "Multi-format program upgrade system", // Page description
"accept_types": [ // Supported file types
".tar.gz", ".zip", ".gz",
"application/x-executable",
"application/octet-stream"
]
}
# Basic configuration
export TARGET_DIR="/opt/production"
export SERVICE_NAME="prod-service"
export PORT="9090"
export MAX_FILE_SIZE="200"
# Feature switches
export ENABLE_BACKUP="true"
export ENABLE_SERVICE="true"
export ENABLE_CLEANUP="false"
# Interface customization
export TITLE="Production Upgrade System"
./linker-upgrader -h
-config string
Configuration file path (default "./config.json")
-gen-config
Generate default configuration file and exit
-port string
Service port (overrides configuration file)
-service string
Service name (overrides configuration file)
-target string
Target directory (overrides configuration file)
The system automatically executes the following steps based on configuration:
- 📤 File Upload: Validate file type and size
- ⏹️ Stop Service: Gracefully stop the currently running service (optional)
- 💾 Backup Program: Backup existing program to backup directory (optional)
- 📦 Extract and Deploy: Automatically extract or copy based on file type
- 🔐 Set Permissions: Automatically set directory and file permissions
▶️ Start Service: Start service and verify status (optional)- 📊 Status Report: Display detailed upgrade logs
Create systemd service file /etc/systemd/system/linker-upgrader.service
:
[Unit]
Description=Program Upgrade System
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/linker-upgrader
ExecStart=/opt/linker-upgrader/linker-upgrader -config /etc/linker-upgrader/config.json
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Enable service:
sudo systemctl enable linker-upgrader
sudo systemctl start linker-upgrader
# Pull the latest version
docker pull ghcr.io/linker-bot/linker-upgrader:latest
# Run container
docker run -d -p 6110:6110 \
--name linker-upgrader \
-v /opt/myapp:/opt/myapp \
-v /etc/linker-upgrader:/etc/linker-upgrader \
-v ./config.json:/etc/linker-upgrader/config.json \
ghcr.io/linker-bot/linker-upgrader:latest \
-config /etc/linker-upgrader/config.json
services:
linker-upgrader:
image: ghcr.io/linker-bot/linker-upgrader:latest
container_name: linker-upgrader
ports:
- "6110:6110"
volumes:
- /opt/myapp:/opt/myapp
- ./config.json:/etc/linker-upgrader/config.json
command: ["-config", "/etc/linker-upgrader/config.json"]
restart: unless-stopped
server {
listen 80;
server_name upgrade.example.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Support large file uploads
client_max_body_size 200M;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
}
}
- Permission Management: Recommended to run with minimal privilege principle
- Network Security: Use HTTPS and authentication in production environments
- File Validation: Verify file integrity and source before upload
- Backup Strategy: Regularly clean backup files to avoid disk space shortage
- Log Monitoring: Monitor upgrade logs to detect anomalies promptly
GET /
- Main page displaying upload formPOST /upload
- Handle file upload and program upgrade
Successful response displays a page containing:
- Upgrade status (success/failure)
- Detailed operation logs
- Current configuration information
Q: Service startup failed?
# Check if port is occupied
netstat -tlnp | grep :8080
# Check permissions
ls -la linker-upgrader
Q: File upload failed?
# Check disk space
df -h
# Check upload directory permissions
ls -la uploads/
Q: Service management failed?
# Check systemd service status
systemctl status myapp
# Check user permissions
id
# View program logs
tail -f /var/log/linker-upgrader.log
# View systemd logs
journalctl -u linker-upgrader -f
We welcome all forms of contributions!
# Clone repository
git clone https://github.com/yourusername/linker-upgrader.git
cd linker-upgrader
# Install dependencies
go mod tidy
# Run tests
go test ./...
# Run program
go run main.go
- Follow Go official code conventions
- Add appropriate comments and documentation
- Write unit tests
- Use
gofmt
to format code
This project is licensed under the Apache v2 License - see the LICENSE file for details.
⭐ If this project helps you, please give us a Star!