6.9 KiB
Executable File
6.9 KiB
Executable File
Example Installation with init.sh
DEV Mode Installation
$ sudo ./init.sh --town mydev --nation test
============================================
apXtri Installation Configuration
============================================
Mode: dev
Town: mydev
Nation: test
Domain: admin.mydev.test
API Port: 3000
Data Path: /var/lib/apxtowns/mydev.test
Node Path: /opt/apxtowns/mydev.test
Project Dir: /opt/apxtowns/mydev.test/apxtri
Tribe Data: /var/lib/apxtowns/mydev.test/mydev
============================================
Continue? [Y/n]: y
[STEP 1/11] Installing system dependencies...
[STEP 2/11] Installing Caddy...
[STEP 3/11] Configuring /etc/hosts...
[INFO] Added admin.mydev.test to /etc/hosts
[STEP 4/11] Creating system user...
[STEP 5/11] Creating directories...
[STEP 6/11] Cloning apxtri repository...
[STEP 7/11] Setting up tribe skeleton...
[STEP 8/11] Creating environment configuration...
[STEP 9/11] Installing Node.js...
[STEP 10/11] Creating systemd service...
[STEP 11] Configuring systemd service...
[INFO] Cron file created: /etc/cron.d/apxtri-mydev.test
[INFO] Backup cron entry added to /etc/cron.d/apxtri-mydev.test
============================================
INSTALLATION COMPLETE
============================================
Configuration:
Instance: mydev.test
Mode: dev
API Port: 3000
Directories:
Code: /opt/apxtowns/mydev.test/apxtri
Data: /var/lib/apxtowns/mydev.test
Tribe Data: /var/lib/apxtowns/mydev.test/mydev
Tribe Code: /opt/apxtowns/mydev.test/mydev
Service Management:
Start: sudo systemctl start apxtri@mydev.test
Stop: sudo systemctl stop apxtri@mydev.test
Status: sudo systemctl status apxtri@mydev.test
Logs: journalctl -f -u apxtri@mydev.test
Access: http://admin.mydev.test
============================================
Post-Installation in Dev Mode
# Start the server in foreground
cd /opt/apxtowns/mydev.test/apxtri && node apxtri.js
# View logs
journalctl -f -u apxtri@mydev.test
# Open admin interface
# http://admin.mydev.test
PROD Mode Installation (Direct)
$ sudo ./init.sh --town production --nation ants --domain prod-ants.example.com
============================================
apXtri Installation Configuration
============================================
Mode: prod
Town: production
Nation: ants
Domain: prod-ants.example.com
API Port: 3000
Data Path: /var/lib/apxtowns/production.ants
Node Path: /opt/apxtowns/production.ants
Project Dir: /opt/apxtowns/production.ants/apxtri
Tribe Data: /var/lib/apxtowns/production.ants/production
============================================
Continue? [Y/n]: y
[STEP 1/11] Installing system dependencies...
[STEP 2/11] Installing Caddy...
[STEP 3/11] Creating system user...
[STEP 4/11] Creating directories...
[STEP 5/11] Cloning apxtri repository...
[STEP 6/11] Setting up tribe skeleton...
[STEP 7/11] Creating environment configuration...
[STEP 8/11] Installing Node.js...
[STEP 9/11] Creating systemd service...
[STEP 10] Configuring automatic updates (cron)...
[STEP 11] Configuring automatic backups (cron)...
============================================
INSTALLATION COMPLETE
============================================
Configuration:
Instance: production.ants
Mode: prod
API Port: 3000
Directories:
Code: /opt/apxtowns/production.ants/apxtri
Data: /var/lib/apxtowns/production.ants
Tribe Data: /var/lib/apxtowns/production.ants/production
Tribe Code: /opt/apxtowns/production.ants/production
Service Management:
Start: sudo systemctl start apxtri@production.ants
Stop: sudo systemctl stop apxtri@production.ants
Status: sudo systemctl status apxtri@production.ants
Logs: sudo journalctl -fu apxtri@production.ants
============================================
Post-Installation in Prod Mode
# Check service status
sudo systemctl status apxtri@production.ants
# View logs
sudo journalctl -fu apxtri@production.ants
PROD Mode Installation (behind HAProxy)
sudo ./init.sh \
--town nova \
--nation libera \
--domain nova.libera.maildigit.fr \
--trusted-proxy-ips 192.168.1.3
See documents/02-LXC.md for HAProxy configuration details.
First connection: open http://nova.libera.maildigit.fr/setup directly. The root URL (/) redirects to /com/ (landing page), but the setup wizard is at /setup.
Non-Interactive Installation
# Dev mode
sudo ./init.sh --town mydev --nation test
# Prod mode with domain
sudo ./init.sh --town production --nation ants --domain mytown.example.com
# Prod mode behind HAProxy
sudo ./init.sh --town nova --nation libera --domain nova.libera.maildigit.fr --trusted-proxy-ips 192.168.1.3
# Clean reinstall
sudo ./init.sh --clean --town mydev --nation test
Post-Installation Verification
1. Check Service
sudo systemctl status apxtri@town.nation
2. Check Crontabs
cat /etc/cron.d/apxtri-town.nation
Expected output:
# apxtri town.nation - automatic updates
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# Update check daily at 3:00 AM
0 3 * * * root /opt/apxtowns/town.nation/apxtri/setup/update.sh >> /var/lib/apxtowns/town.nation/town/logs/update.log 2>&1
# Backup: daily at 4:00 AM
0 4 * * * root /opt/apxtowns/town.nation/apxtri/setup/backup.sh dayname >> /var/lib/apxtowns/town.nation/town/logs/backup.log 2>&1
3. Check Logs
# Both dev and prod
journalctl -fu apxtri@town.nation
4. Test Scripts Manually
# Test backup
sudo -u apxtri /opt/apxtowns/town.nation/apxtri/setup/backup.sh town dayname nations,towns,pagans
# Test update
sudo -u apxtri /opt/apxtowns/town.nation/apxtri/setup/update.sh
5. Check Backups
ls -lh /var/lib/apxtowns/town.nation/town/backups/
6. First Connection
Open http://{domain}/setup in your browser. The root URL (/) redirects to /com/ (landing page), but the setup wizard for initial configuration (mayor identity, HTTPS activation) is at /setup.
Expected output (after a few days):
-rw-r--r-- 1 apxtri apxtri 1.2M Mon.apxtri.objects.tar.gz
-rw-r--r-- 1 apxtri apxtri 1.3M Tue.apxtri.objects.tar.gz
Daily Usage
Dev Mode
# Quick start
cd /opt/apxtowns/town.nation/apxtri && node apxtri.js
# View logs
journalctl -fu apxtri@town.nation
# Restart
sudo systemctl restart apxtri@town.nation
# Stop
sudo systemctl stop apxtri@town.nation
# Status
sudo systemctl status apxtri@town.nation
Prod Mode
# View logs
sudo journalctl -fu apxtri@town.nation
# Service management
sudo systemctl start apxtri@town.nation
sudo systemctl stop apxtri@town.nation
sudo systemctl restart apxtri@town.nation
sudo systemctl status apxtri@town.nation