Refactor code for improved readability and performance
This commit is contained in:
187
docs/12-quick-reference/QUICK_REFERENCE.md
Normal file
187
docs/12-quick-reference/QUICK_REFERENCE.md
Normal file
@@ -0,0 +1,187 @@
|
||||
# ProxmoxVE Scripts - Quick Reference
|
||||
|
||||
## Repository Setup
|
||||
|
||||
```bash
|
||||
# Clone as submodule (already done)
|
||||
git submodule add https://github.com/community-scripts/ProxmoxVE.git ProxmoxVE
|
||||
|
||||
# Update submodule
|
||||
git submodule update --init --recursive
|
||||
|
||||
# Update to latest
|
||||
cd ProxmoxVE && git pull origin main && cd ..
|
||||
```
|
||||
|
||||
## Script Locations
|
||||
|
||||
- **Container Scripts**: `ProxmoxVE/ct/AppName.sh`
|
||||
- **Install Scripts**: `ProxmoxVE/install/AppName-install.sh`
|
||||
- **Function Libraries**: `ProxmoxVE/misc/*.func`
|
||||
- **Documentation**: `ProxmoxVE/docs/`
|
||||
|
||||
## Quick Script Template
|
||||
|
||||
### Container Script (`ct/AppName.sh`)
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
||||
# Copyright (c) 2021-2025 community-scripts ORG
|
||||
# Author: YourUsername
|
||||
# License: MIT
|
||||
|
||||
APP="AppName"
|
||||
var_tags="tag1;tag2"
|
||||
var_cpu="2"
|
||||
var_ram="2048"
|
||||
var_disk="10"
|
||||
var_os="debian"
|
||||
var_version="12"
|
||||
var_unprivileged="1"
|
||||
|
||||
header_info "$APP"
|
||||
variables
|
||||
color
|
||||
catch_errors
|
||||
|
||||
function update_script() {
|
||||
header_info
|
||||
check_container_storage
|
||||
check_container_resources
|
||||
if [[ ! -f /path/to/installation ]]; then
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
# Update logic
|
||||
exit
|
||||
}
|
||||
|
||||
start
|
||||
build_container
|
||||
description
|
||||
msg_ok "Completed Successfully!\n"
|
||||
```
|
||||
|
||||
### Install Script (`install/AppName-install.sh`)
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
# Copyright (c) 2021-2025 community-scripts ORG
|
||||
|
||||
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
||||
color
|
||||
verb_ip6
|
||||
catch_errors
|
||||
setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_info "Installing Dependencies"
|
||||
$STD apt-get install -y curl sudo mc package1 package2
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
msg_info "Setting up ${APP}"
|
||||
# Installation steps here
|
||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||
msg_ok "Setup ${APP}"
|
||||
|
||||
motd_ssh
|
||||
customize
|
||||
```
|
||||
|
||||
## Key Functions
|
||||
|
||||
### Message Functions
|
||||
- `msg_info "message"` - Info message
|
||||
- `msg_ok "message"` - Success message
|
||||
- `msg_error "message"` - Error message
|
||||
- `msg_warn "message"` - Warning message
|
||||
|
||||
### Execution
|
||||
- `$STD command` - Silent execution (respects VERBOSE)
|
||||
- `silent command` - Execute with error handling
|
||||
|
||||
### Container Functions
|
||||
- `build_container` - Create and setup container
|
||||
- `description` - Set container description
|
||||
- `check_container_storage` - Verify storage
|
||||
- `check_container_resources` - Verify resources
|
||||
|
||||
## Variable Precedence
|
||||
|
||||
1. Environment variables (highest)
|
||||
2. App-specific defaults (`/defaults/<app>.vars`)
|
||||
3. User global defaults (`/default.vars`)
|
||||
4. Built-in defaults (lowest)
|
||||
|
||||
## Installation Modes
|
||||
|
||||
- **Mode 0**: Default (built-in defaults)
|
||||
- **Mode 1**: Advanced (19-step wizard)
|
||||
- **Mode 2**: User defaults
|
||||
- **Mode 3**: App defaults
|
||||
- **Mode 4**: Settings menu
|
||||
|
||||
## Common Patterns
|
||||
|
||||
### Version Detection
|
||||
```bash
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/user/repo/releases/latest | \
|
||||
grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')
|
||||
```
|
||||
|
||||
### Database Setup
|
||||
```bash
|
||||
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
|
||||
$STD mysql -u root -e "CREATE DATABASE $DB_NAME;"
|
||||
```
|
||||
|
||||
### Systemd Service
|
||||
```bash
|
||||
cat <<EOF >/etc/systemd/system/${APP}.service
|
||||
[Unit]
|
||||
Description=${APP} Service
|
||||
After=network.target
|
||||
[Service]
|
||||
ExecStart=/path/to/command
|
||||
Restart=always
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl enable -q --now ${APP}.service
|
||||
```
|
||||
|
||||
## Documentation Links
|
||||
|
||||
- **Main Docs**: `ProxmoxVE/docs/README.md`
|
||||
- **Container Guide**: `ProxmoxVE/docs/ct/DETAILED_GUIDE.md`
|
||||
- **Install Guide**: `ProxmoxVE/docs/install/DETAILED_GUIDE.md`
|
||||
- **Contribution**: `ProxmoxVE/docs/contribution/README.md`
|
||||
- **Technical Ref**: `ProxmoxVE/docs/TECHNICAL_REFERENCE.md`
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
# Test container script
|
||||
bash ProxmoxVE/ct/AppName.sh
|
||||
|
||||
# Test with verbose mode
|
||||
VERBOSE=yes bash ProxmoxVE/ct/AppName.sh
|
||||
|
||||
# Test update function
|
||||
bash ProxmoxVE/ct/AppName.sh -u
|
||||
```
|
||||
|
||||
## Contribution Checklist
|
||||
|
||||
- [ ] Use template from `docs/contribution/templates_*/`
|
||||
- [ ] Follow naming: `AppName.sh` and `AppName-install.sh`
|
||||
- [ ] Include copyright header
|
||||
- [ ] Use `msg_*` functions for messages
|
||||
- [ ] Use `$STD` for command execution
|
||||
- [ ] Quote all variables
|
||||
- [ ] Test on Proxmox VE 8.4+ or 9.0+
|
||||
- [ ] Implement update function (if applicable)
|
||||
- [ ] Update documentation (if needed)
|
||||
|
||||
102
docs/12-quick-reference/QUICK_START_TEMPLATE.md
Normal file
102
docs/12-quick-reference/QUICK_START_TEMPLATE.md
Normal file
@@ -0,0 +1,102 @@
|
||||
# Quick Start: Using Template as Base for All LXCs
|
||||
|
||||
## Step 1: Choose Your Base Template
|
||||
|
||||
Run the template script to see available options:
|
||||
|
||||
```bash
|
||||
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/addon/all-templates.sh)"
|
||||
```
|
||||
|
||||
Or list available templates directly:
|
||||
|
||||
```bash
|
||||
pveam available | grep -E "debian|ubuntu|alpine"
|
||||
```
|
||||
|
||||
## Step 2: Download the Template (Once)
|
||||
|
||||
For example, Debian 12:
|
||||
|
||||
```bash
|
||||
pveam download local debian-12-standard_12.2-1_amd64.tar.zst
|
||||
```
|
||||
|
||||
This downloads the template to your local storage. You only need to do this once.
|
||||
|
||||
## Step 3: Set Template Variable
|
||||
|
||||
Create or update your configuration file with:
|
||||
|
||||
```bash
|
||||
# In your deployment config file or .env
|
||||
export CONTAINER_OS_TEMPLATE="local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst"
|
||||
```
|
||||
|
||||
## Step 4: Deploy Multiple Containers
|
||||
|
||||
Now you can deploy as many containers as needed from this single template:
|
||||
|
||||
```bash
|
||||
# Container 1 - Web Server
|
||||
pct create 100 "$CONTAINER_OS_TEMPLATE" \
|
||||
--hostname web1 \
|
||||
--memory 2048 \
|
||||
--cores 2 \
|
||||
--rootfs local-lvm:20 \
|
||||
--net0 name=eth0,bridge=vmbr0,ip=dhcp \
|
||||
--unprivileged 1
|
||||
|
||||
# Container 2 - Database
|
||||
pct create 101 "$CONTAINER_OS_TEMPLATE" \
|
||||
--hostname db1 \
|
||||
--memory 4096 \
|
||||
--cores 4 \
|
||||
--rootfs local-lvm:50 \
|
||||
--net0 name=eth0,bridge=vmbr0,ip=dhcp \
|
||||
--unprivileged 1
|
||||
|
||||
# Container 3 - App Server
|
||||
pct create 102 "$CONTAINER_OS_TEMPLATE" \
|
||||
--hostname app1 \
|
||||
--memory 2048 \
|
||||
--cores 2 \
|
||||
--rootfs local-lvm:30 \
|
||||
--net0 name=eth0,bridge=vmbr0,ip=dhcp \
|
||||
--unprivileged 1
|
||||
```
|
||||
|
||||
## Step 5: Start Containers
|
||||
|
||||
```bash
|
||||
pct start 100
|
||||
pct start 101
|
||||
pct start 102
|
||||
```
|
||||
|
||||
## Benefits
|
||||
|
||||
✅ **One template, unlimited containers** - Download once, deploy many times
|
||||
✅ **Storage efficient** - Template is reused, only differences are stored
|
||||
✅ **Consistent base** - All containers start from the same clean OS
|
||||
✅ **Easy updates** - Update template, all new containers get updates
|
||||
✅ **Fast deployment** - No need to download template for each container
|
||||
|
||||
## Your Current Setup
|
||||
|
||||
Your deployment scripts already use this pattern! Check:
|
||||
- `smom-dbis-138-proxmox/scripts/deployment/deploy-services.sh`
|
||||
- `smom-dbis-138-proxmox/config/proxmox.conf.example`
|
||||
|
||||
They use: `CONTAINER_OS_TEMPLATE="${CONTAINER_OS_TEMPLATE:-local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst}"`
|
||||
|
||||
This means:
|
||||
- If `CONTAINER_OS_TEMPLATE` is set, use it
|
||||
- Otherwise, default to Debian 12 standard template
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. **Set your template** in your config file
|
||||
2. **Download it once**: `pveam download local debian-12-standard_12.2-1_amd64.tar.zst`
|
||||
3. **Deploy containers** using your deployment scripts - they'll automatically use the template!
|
||||
|
||||
23
docs/12-quick-reference/README.md
Normal file
23
docs/12-quick-reference/README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Quick Reference
|
||||
|
||||
This directory contains quick reference guides for common tasks.
|
||||
|
||||
## Documents
|
||||
|
||||
- **[QUICK_REFERENCE.md](QUICK_REFERENCE.md)** ⭐⭐ - Quick reference for ProxmoxVE scripts
|
||||
- **[VALIDATED_SET_QUICK_REFERENCE.md](VALIDATED_SET_QUICK_REFERENCE.md)** ⭐⭐ - Quick reference for validated set
|
||||
- **[QUICK_START_TEMPLATE.md](QUICK_START_TEMPLATE.md)** ⭐ - Quick start template guide
|
||||
|
||||
## Quick Reference
|
||||
|
||||
**Common Tasks:**
|
||||
- ProxmoxVE script quick reference
|
||||
- Validated set deployment quick reference
|
||||
- Quick start templates
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- **[../01-getting-started/](../01-getting-started/)** - Getting started guides
|
||||
- **[../03-deployment/](../03-deployment/)** - Deployment guides
|
||||
- **[../11-references/](../11-references/)** - Technical references
|
||||
|
||||
75
docs/12-quick-reference/VALIDATED_SET_QUICK_REFERENCE.md
Normal file
75
docs/12-quick-reference/VALIDATED_SET_QUICK_REFERENCE.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# Validated Set Deployment - Quick Reference
|
||||
|
||||
## One-Command Deployment
|
||||
|
||||
```bash
|
||||
cd /opt/smom-dbis-138-proxmox
|
||||
sudo ./scripts/deployment/deploy-validated-set.sh \
|
||||
--source-project /path/to/smom-dbis-138
|
||||
```
|
||||
|
||||
## Common Commands
|
||||
|
||||
### Deploy Everything
|
||||
```bash
|
||||
sudo ./scripts/deployment/deploy-validated-set.sh --source-project /path/to/smom-dbis-138
|
||||
```
|
||||
|
||||
### Bootstrap Existing Network
|
||||
```bash
|
||||
sudo ./scripts/network/bootstrap-network.sh
|
||||
```
|
||||
|
||||
### Validate Validators
|
||||
```bash
|
||||
sudo ./scripts/validation/validate-validator-set.sh
|
||||
```
|
||||
|
||||
### Check Node Health
|
||||
```bash
|
||||
sudo ./scripts/health/check-node-health.sh <VMID>
|
||||
```
|
||||
|
||||
### Check All Services
|
||||
```bash
|
||||
for vmid in 1000 1001 1002 1003 1004 1500 1501 1502 1503 2500 2501 2502; do
|
||||
echo "=== Container $vmid ==="
|
||||
pct exec $vmid -- systemctl status besu-validator besu-sentry besu-rpc --no-pager 2>/dev/null | head -5
|
||||
done
|
||||
```
|
||||
|
||||
## VMID Reference
|
||||
|
||||
| VMID Range | Type | Service Name |
|
||||
|------------|------|--------------|
|
||||
| 1000-1004 | Validators | besu-validator |
|
||||
| 1500-1503 | Sentries | besu-sentry |
|
||||
| 2500-2502 | RPC Nodes | besu-rpc |
|
||||
|
||||
## Script Options
|
||||
|
||||
### deploy-validated-set.sh
|
||||
- `--skip-deployment` - Skip container deployment
|
||||
- `--skip-config` - Skip configuration copy
|
||||
- `--skip-bootstrap` - Skip network bootstrap
|
||||
- `--skip-validation` - Skip validation
|
||||
- `--source-project PATH` - Source project path
|
||||
- `--help` - Show help
|
||||
|
||||
## Troubleshooting Quick Commands
|
||||
|
||||
```bash
|
||||
# View logs
|
||||
pct exec <vmid> -- journalctl -u besu-validator -f
|
||||
|
||||
# Restart service
|
||||
pct exec <vmid> -- systemctl restart besu-validator
|
||||
|
||||
# Check connectivity
|
||||
pct exec <vmid> -- netstat -tuln | grep 30303
|
||||
|
||||
# Check RPC (if enabled)
|
||||
pct exec <vmid> -- curl -s -X POST -H "Content-Type: application/json" \
|
||||
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
|
||||
http://localhost:8545
|
||||
```
|
||||
Reference in New Issue
Block a user