A lightweight, automated deployment watcher service that monitors trigger files and executes deployment scripts for multiple user accounts on a Linux server.
curl -fsSL https://raw.githubusercontent.com/imlolman/build-watcher/refs/heads/main/install.sh | sudo bash# Clone the repository
git clone https://github.com/imlolman/build-watcher.git
cd build-watcher
# Run the installer
sudo bash install.shBuild Watcher is a background service that:
-
Monitors Deployment Triggers: Continuously watches for deployment trigger files at
/home/*/public_html/deploy -
Automatic Execution: When a trigger file is detected:
- Validates that a
deploy.shscript exists in the user's project directory - Executes the deployment script with the real user's username as an argument
- Logs all deployment activities to
storage/logs/deploy.log
- Validates that a
-
Permission Management: Automatically fixes ownership permissions for the
publicdirectory after deployment -
Multi-User Support: Handles deployments for multiple user accounts simultaneously
-
Clean-Up: Removes trigger files after processing and maintains clean operation
┌─────────────────┐
│ Trigger File │
│ Created at: │
│ /home/user/ │
│ public_html/ │
│ deploy │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Build Watcher │
│ Detects File │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Execute │
│ deploy.sh │
│ (as real user) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Log Results & │
│ Fix Permissions │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Remove Trigger │
│ File │
└─────────────────┘
If you prefer to install components individually:
sudo curl -fsSL https://raw.githubusercontent.com/imlolman/build-watcher/refs/heads/main/build-watcher.sh \
-o /usr/local/bin/build-watcher.sh
sudo chmod +x /usr/local/bin/build-watcher.shsudo curl -fsSL https://raw.githubusercontent.com/imlolman/build-watcher/refs/heads/main/build-watcher.service \
-o /etc/systemd/system/build-watcher.servicesudo systemctl daemon-reload
sudo systemctl enable build-watcher
sudo systemctl start build-watcher# Check service status
sudo systemctl status build-watcher
# View live logs
sudo journalctl -u build-watcher -f
# Stop the service
sudo systemctl stop build-watcher
# Start the service
sudo systemctl start build-watcher
# Restart the service
sudo systemctl restart build-watcher
# Disable auto-start on boot
sudo systemctl disable build-watcherTo trigger a deployment for a specific user:
# Create a trigger file
touch /home/username/public_html/deployThe watcher will detect this file within 2 seconds and execute the deployment.
/usr/local/bin/build-watcher.sh # Main watcher script
/etc/systemd/system/build-watcher.service # Systemd service definition
/home/[user]/public_html/
├── deploy # Trigger file (created to start deployment)
├── deploy.sh # User's deployment script (must exist)
├── public/ # Directory with auto-fixed permissions
└── storage/logs/deploy.log # Deployment logs
Edit /usr/local/bin/build-watcher.sh to customize:
FILE_PATTERN_TO_WATCH="/home/*/public_html/deploy" # Where to watch for triggers
LOG_FILE_PATH="storage/logs/deploy.log" # Log location (relative)
PERMISSION_UPDATE_PATH="public" # Directory for permission fixesAfter making changes, restart the service:
sudo systemctl restart build-watcher- The service runs as
rootto manage multiple user directories - Each deployment script runs with the context of the real user
- Permissions are automatically corrected after deployment
- All activities are logged for audit purposes
# Check for errors
sudo journalctl -u build-watcher -n 50
# Verify the script is executable
ls -l /usr/local/bin/build-watcher.sh- Ensure
deploy.shexists in the user'spublic_htmldirectory - Check the trigger file is being created at the correct path
- Monitor logs:
sudo journalctl -u build-watcher -f
The script automatically fixes permissions for the public directory. If you need to change which directory gets permission fixes, edit the PERMISSION_UPDATE_PATH variable.
- Linux server with systemd
- Root access for installation
- User directories at
/home/[username]/public_html/ - Deployment scripts at
/home/[username]/public_html/deploy.sh
Open source - feel free to modify and distribute.
Contributions are welcome! Please feel free to submit pull requests or open issues.
Made with ❤️ for simplified deployments