chore(skills): consolidar n8n-* (6→1) e cwp-* (8→1) em meta-skills
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,484 @@
|
||||
---
|
||||
name: cwp
|
||||
description: Meta-skill CWP (CentOS Web Panel, servidor 176.9.3.158) cobrindo gestão de contas, backups, email/Postfix/DKIM, PHP Switcher/Selector, segurança CSF/LFD, SSL/acme.sh, webservers Apache/Nginx e referência completa dos scripts oficiais. Triggers — cwp, centos web panel, cwp_api, /scripts/, csf, lfd, acme, autossl, postfix, dkim, php selector, php switcher, varnish, httpd, nginx cwp, user_backup, whoowns, list_users, hostname ssl, mail queue, fix_perms.
|
||||
---
|
||||
|
||||
# /cwp - Meta-skill CWP (CentOS Web Panel)
|
||||
|
||||
Skill unificada para o servidor **CWP Principal `176.9.3.158`** (MCP `ssh-unified`, user `root`). Substitui as antigas cwp-accounts, cwp-backup, cwp-email, cwp-php, cwp-scripts, cwp-security, cwp-ssl, cwp-webserver.
|
||||
|
||||
**REGRA #38 — ZERO INVENÇÃO:** NUNCA improvisar comandos. Verificar estado actual ANTES de alterar. Pesquisar wiki CWP se necessário. Usar APENAS scripts oficiais (`/scripts/*` e `/scripts/cwp_api`). Se não souber: PERGUNTAR.
|
||||
|
||||
## Documentação base
|
||||
|
||||
- Wiki: https://wiki.centos-webpanel.com/cwp-admin-api , /cwp-scripts , /csf-firewall-command-line
|
||||
- Hub manuais: `Hub/06-Operacoes/Documentacao/Manuais/CWP/` (`CWP-Manual-Completo.md` 503KB, `CWP-Ferramentas-Desenvolvimento.md` 82KB, `CWP-Guia-do-Utilizador.md`, `CWP-Guia-do-Revendedor.md`)
|
||||
- QR: `Hub/06-Operacoes/Documentacao/Quick-Reference/QR-CWP.md`
|
||||
- NotebookLM CWP: `0ded7bd6-69b3-4c76-b327-452396bf7ea7`
|
||||
- NotebookLM Cibersegurança WordPress (para secção segurança): `5f60adfd-2435-4725-8c12-9c11c5f51d75`
|
||||
|
||||
```
|
||||
mcp__notebooklm__notebook_query notebook_id:"0ded7bd6-69b3-4c76-b327-452396bf7ea7" query:"<adaptar>"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 1. Contas (accounts)
|
||||
|
||||
### Consulta (read-only)
|
||||
```bash
|
||||
sh /scripts/list_users
|
||||
sh /scripts/list_domains
|
||||
sh /scripts/list_subdomains
|
||||
sh /scripts/whoowns DOMINIO
|
||||
```
|
||||
|
||||
### API gestão
|
||||
```bash
|
||||
/scripts/cwp_api account remove_user USERNAME
|
||||
/scripts/cwp_api account suspend_user USERNAME
|
||||
/scripts/cwp_api account unsuspend_user USERNAME
|
||||
/scripts/cwp_api account fix_perms USERNAME # OBRIGATÓRIO após qualquer SSH manual
|
||||
/scripts/cwp_api account list_domains USERNAME
|
||||
```
|
||||
|
||||
### Bandwidth
|
||||
```bash
|
||||
/scripts/cwp_api account unsuspend_bandwidth USERNAME # após aumentar limites
|
||||
/scripts/cwp_api account reset_bandwidth USERNAME
|
||||
```
|
||||
|
||||
### Massa
|
||||
```bash
|
||||
/scripts/cwp_api account update_diskquota_all
|
||||
/scripts/cwp_api account update_limits_all # quota, hourly_emails, cgroups, nproc, apache_nproc, inode, nofile
|
||||
/scripts/cwp_api account mail_fix_permissions
|
||||
/scripts/cwp_api account update_policyd_all
|
||||
```
|
||||
|
||||
### DNS
|
||||
```bash
|
||||
/scripts/cwp_api account rebuild_etc_named_conf
|
||||
/scripts/cwp_api account rebuild_var_named_all
|
||||
/scripts/cwp_api account rebuild_var_named USERNAME DOMAIN
|
||||
```
|
||||
|
||||
### Auxiliares
|
||||
```bash
|
||||
sh /scripts/ulimit_user_check USERNAME
|
||||
sh /scripts/cwpsrv_rebuild_user_conf
|
||||
```
|
||||
|
||||
### Workflows típicos
|
||||
1. Suspender: `suspend_user` -> `list_users | grep`.
|
||||
2. Reactivar: `unsuspend_user` -> `fix_perms`.
|
||||
3. Pós-SSH manual: SEMPRE `fix_perms USERNAME`.
|
||||
|
||||
### Validação
|
||||
```bash
|
||||
sh /scripts/list_users | grep USERNAME
|
||||
/scripts/cwp_api account list_domains USERNAME
|
||||
curl -sI http://DOMINIO | head -5
|
||||
```
|
||||
|
||||
### Anti-patterns
|
||||
Remover sem backup | editar ficheiros manualmente | esquecer fix_perms após SSH | suspender sem avisar cliente.
|
||||
|
||||
---
|
||||
|
||||
## 2. Backups
|
||||
|
||||
### Comando principal
|
||||
```bash
|
||||
sh /scripts/user_backup USERNAME # backup completo: ficheiros, BD, emails, configs
|
||||
```
|
||||
|
||||
Localização padrão: `/backup/`. Cron: `/usr/local/cwpsrv/htdocs/resources/admin/include/cron_backup.php`.
|
||||
|
||||
### Workflow
|
||||
```bash
|
||||
df -h /backup # 1. espaço
|
||||
sh /scripts/whoowns DOMINIO # 2. identificar
|
||||
du -sh /home/USERNAME/ # 3. tamanho conta
|
||||
sh /scripts/user_backup USERNAME # 4. backup
|
||||
ls -lh /backup/ | grep USERNAME # 5. verificar
|
||||
tar -tzf /backup/FILE.tar.gz > /dev/null && echo OK || echo CORRUPTO # 6. integridade
|
||||
```
|
||||
|
||||
### Restauro manual (GUI restore não é fiável segundo doc)
|
||||
```bash
|
||||
mkdir /tmp/restore_test
|
||||
tar -xzf /backup/FILE.tar.gz -C /tmp/restore_test
|
||||
# copiar manualmente para localização correcta
|
||||
chown -R USERNAME:USERNAME /home/USERNAME/public_html/
|
||||
rm -rf /tmp/restore_test
|
||||
```
|
||||
|
||||
### Boas práticas
|
||||
Backup antes de operações destrutivas | manter cópias remotas (GDrive/S3) | testar restauro periodicamente | limpar >30 dias | nunca confiar só em locais.
|
||||
|
||||
---
|
||||
|
||||
## 3. Email (Postfix, DKIM, Mail Queue)
|
||||
|
||||
### Scripts oficiais
|
||||
| Script | Função |
|
||||
|--------|--------|
|
||||
| `/scripts/install_cbpolicyd` | Instalar limites emails/hora |
|
||||
| `/scripts/check_postqueue` | Verificar mail queue |
|
||||
| `/scripts/mail_queue_stats` | Estatísticas queue |
|
||||
| `/scripts/mail_roundcube_update` | Update RoundCube |
|
||||
| `/scripts/mail_vmail_import` | Importar contas /var/vmail |
|
||||
| `/scripts/mail_rebuild_sni_certs` | Rebuild certificados mail |
|
||||
|
||||
### DKIM/SPF
|
||||
1. CWP.admin -> Postfix Manager -> rebuild com DKIM&SPF activos.
|
||||
2. DKIM Manager -> adicionar key por domínio.
|
||||
3. Testar: enviar para `check-auth@verifier.port25.com` (deve responder "DKIM check: pass").
|
||||
4. DKIM 2048-bit: dividir TXT record ao meio, ambas partes em quotes.
|
||||
|
||||
### Mail queue
|
||||
```bash
|
||||
sh /scripts/check_postqueue
|
||||
sh /scripts/mail_queue_stats
|
||||
postqueue -p # ver
|
||||
postqueue -f # flush
|
||||
postcat -q QUEUE_ID # ver mensagem
|
||||
postsuper -d ALL # CUIDADO: limpa tudo
|
||||
```
|
||||
|
||||
### Policyd
|
||||
```bash
|
||||
sh /scripts/install_cbpolicyd
|
||||
/scripts/cwp_api account update_policyd_all
|
||||
```
|
||||
|
||||
### Após SSL: rebuild certs mail
|
||||
```bash
|
||||
sh /scripts/mail_rebuild_sni_certs
|
||||
```
|
||||
|
||||
### Anti-spam
|
||||
- rDNS: só configurável pelo provider de hosting.
|
||||
- Blacklists: https://mxtoolbox.com/blacklists.aspx.
|
||||
- DMARC recomendado.
|
||||
|
||||
### Validação
|
||||
```bash
|
||||
echo "Test" | mail -s "Subject" dest@example.com
|
||||
tail -100 /var/log/maillog
|
||||
```
|
||||
|
||||
### Anti-patterns
|
||||
Limpar queue sem ver | ignorar blacklists | DKIM sem testar | editar postfix directamente.
|
||||
|
||||
---
|
||||
|
||||
## 4. PHP (Switcher / Selector / FPM)
|
||||
|
||||
3 ferramentas: **PHP Switcher** (versão default), **PHP Selector** (por pasta), **PHP-FPM Selector**.
|
||||
|
||||
Versões suportadas (Selector): 4.4, 5.2-5.6, 7.0-7.4, 8.0, 8.1.
|
||||
|
||||
### Paths
|
||||
| Path | Descrição |
|
||||
|------|-----------|
|
||||
| `/usr/local/cwpsrv/htdocs/resources/conf/el7/php_switcher/` | Configs CentOS 7 |
|
||||
| `/usr/local/cwpsrv/htdocs/resources/conf/el8/php_switcher/` | Configs CentOS 8 |
|
||||
| `/var/log/php-rebuild.log` | Log compilação |
|
||||
|
||||
### Comandos
|
||||
```bash
|
||||
php -v
|
||||
php -i | grep -E 'memory_limit|upload_max|post_max|max_execution'
|
||||
php -i | grep -E 'opcache.enable|opcache.memory_consumption'
|
||||
ps aux | grep php-fpm | wc -l
|
||||
sh /scripts/phpfpm_rebuild_user_conf
|
||||
tail -f /var/log/php-rebuild.log # monitorizar instalação versão PHP
|
||||
```
|
||||
|
||||
### Desactivar funções perigosas
|
||||
```bash
|
||||
echo "disable_functions = exec, system, popen, proc_open, shell_exec, passthru, show_source" \
|
||||
> /usr/local/php/php.d/disabled_function.ini
|
||||
```
|
||||
(cada versão PHP tem path próprio)
|
||||
|
||||
### Flags compilação
|
||||
Editar `/usr/local/cwpsrv/htdocs/resources/conf/el7/php_switcher/7.0.ini`:
|
||||
```ini
|
||||
[nome-unico]
|
||||
default=0
|
||||
option="--enable-opcao"
|
||||
```
|
||||
**Aviso doc:** "CWP update will overwrite these files" — documentar para reaplicar.
|
||||
|
||||
### Anti-patterns
|
||||
Editar .ini sem documentar | compilar PHP manualmente | ignorar php-rebuild.log.
|
||||
|
||||
---
|
||||
|
||||
## 5. Segurança (CSF / LFD)
|
||||
|
||||
### Paths
|
||||
`/etc/csf/csf.conf` | `/etc/csf/csf.pignore` | `/var/log/lfd.log`
|
||||
|
||||
### Controlo firewall
|
||||
| Comando | Descrição |
|
||||
|---------|-----------|
|
||||
| `csf -e` | Activar |
|
||||
| `csf -x` | Desactivar |
|
||||
| `csf -r` | Restart iptables |
|
||||
| `csf -ra` | Restart completo (iptables + LFD) |
|
||||
| `service lfd restart` | Restart só LFD |
|
||||
|
||||
### IPs
|
||||
| Comando | Descrição |
|
||||
|---------|-----------|
|
||||
| `csf -g IP` | Verificar bloqueio e razão |
|
||||
| `csf -d IP` | Bloquear permanente |
|
||||
| `csf -td IP 86400` | Bloquear temp (segundos) |
|
||||
| `csf -dr IP` | Desbloquear |
|
||||
| `csf -a IP` | Whitelist permanente |
|
||||
| `csf -a 192.168.0.0/24` | Whitelist range |
|
||||
| `csf -ta IP 86400` | Whitelist temp |
|
||||
| `csf -tf` | Limpar bloqueios temp |
|
||||
| `csf -df` | Limpar bloqueios permanentes |
|
||||
|
||||
```bash
|
||||
grep "IP" /var/log/lfd.log
|
||||
```
|
||||
|
||||
### Configuração portas
|
||||
`/etc/csf/csf.conf` -> `TCP_IN`, `TCP_OUT`, `UDP_IN`, `UDP_OUT`. Após alterar: `csf -r`.
|
||||
|
||||
### Ignorar país
|
||||
```
|
||||
CC_IGNORE = "PT"
|
||||
```
|
||||
|
||||
### Scripts segurança
|
||||
```bash
|
||||
sh /scripts/cwp_bruteforce_protection
|
||||
sh /scripts/security_is_my_server_hacked # verifica sinais de hack
|
||||
sh /scripts/cwpsecure_update_rules
|
||||
```
|
||||
|
||||
### Hardening documentado
|
||||
- **SSH port:** alterar `/etc/ssh/sshd_config` -> actualizar `csf.conf` TCP_IN -> `service sshd restart`.
|
||||
- **tmpfs:** `/etc/fstab` -> `tmpfs /dev/shm tmpfs defaults,nodev,nosuid,noexec 0 0`.
|
||||
- **Kernel panic:** `/etc/sysctl.conf` -> `vm.panic_on_oom=1`, `kernel.panic=10`, `sysctl -p`.
|
||||
- **MySQL:** `[mysqld] max_user_connections=45`, `service mysql restart`.
|
||||
|
||||
### Validação
|
||||
```bash
|
||||
csf -l | head -20
|
||||
csf -g IP
|
||||
service lfd status
|
||||
```
|
||||
|
||||
### Anti-patterns
|
||||
Bloquear sem `csf -g` | desactivar firewall | editar iptables directamente | ignorar logs LFD.
|
||||
|
||||
---
|
||||
|
||||
## 6. SSL (acme.sh nativo CWP)
|
||||
|
||||
### Paths oficiais
|
||||
| Path | Descrição |
|
||||
|------|-----------|
|
||||
| `/root/.acme.sh/cwp_certs/` | Certificados CWP |
|
||||
| `/root/.acme.sh/acme.sh.log` | Log acme.sh |
|
||||
| `/var/log/cwp/autossl.log` | Log AutoSSL |
|
||||
| `/usr/local/apache/autossl_tmp/` | **Webroot validação** (única pasta válida) |
|
||||
| `/etc/pki/tls/certs/` | Certs Nginx |
|
||||
| `/etc/pki/tls/private/` | Chaves Nginx |
|
||||
|
||||
### Scripts
|
||||
```bash
|
||||
sh /scripts/install_acme # reinstalar acme.sh
|
||||
sh /scripts/autossl_reload
|
||||
sh /scripts/generate_hostname_ssl
|
||||
sh /scripts/hostname_ssl_restart_services
|
||||
```
|
||||
|
||||
### Comandos chave
|
||||
```bash
|
||||
ls /root/.acme.sh/cwp_certs/
|
||||
grep "Le_NextRenewTimeStr" /root/.acme.sh/cwp_certs/www.DOMINIO_ecc/www.DOMINIO.conf
|
||||
|
||||
# FORÇAR renovação (oficial)
|
||||
/root/.acme.sh/acme.sh --renew -d DOMINIO --force --home /root/.acme.sh/cwp_certs
|
||||
|
||||
# Verificar produção
|
||||
echo | openssl s_client -connect DOMINIO:443 2>/dev/null | openssl x509 -noout -dates
|
||||
|
||||
tail -100 /root/.acme.sh/acme.sh.log | grep DOMINIO
|
||||
tail -100 /var/log/cwp/autossl.log
|
||||
```
|
||||
|
||||
Cron renovação CWP: `23 2 * * *` (diário 02:23). `crontab -l | grep -i acme`.
|
||||
|
||||
### Workflow listar todos
|
||||
```bash
|
||||
for d in $(ls /root/.acme.sh/cwp_certs/); do
|
||||
echo "=== $d ==="
|
||||
grep -E 'Le_NextRenewTimeStr|Le_Alt' /root/.acme.sh/cwp_certs/$d/*.conf 2>/dev/null | head -3
|
||||
done
|
||||
```
|
||||
|
||||
### Troubleshooting documentado
|
||||
- **Muitos subdomínios em Le_Alt** (mail/ftp/cpanel): qualquer falha bloqueia tudo. **Solução:** editar `.conf` e reduzir `Le_Alt` ao domínio principal.
|
||||
- **Webroot incorrecto:** Nginx CWP serve validação de pasta GLOBAL `/usr/local/apache/autossl_tmp/`. NUNCA usar `/home/user/.../.well-known/`.
|
||||
|
||||
### Thresholds
|
||||
| Expira | Acção |
|
||||
|--------|-------|
|
||||
| >30d | OK |
|
||||
| 15-30d | Monitorizar |
|
||||
| <15d | Crítico — renovar |
|
||||
| Expirado | Forçar renovação |
|
||||
|
||||
### Anti-patterns
|
||||
**Usar certbot** (conflito com acme.sh nativo) | incluir mail/ftp/cpanel em `Le_Alt` | hooks manuais (sobrescritos em update) | editar certs em `/etc/pki/`.
|
||||
|
||||
---
|
||||
|
||||
## 7. WebServers (Apache / Nginx / Varnish)
|
||||
|
||||
### API webservers
|
||||
```bash
|
||||
/scripts/cwp_api webservers rebuild_all
|
||||
/scripts/cwp_api webservers rebuild_user USERNAME
|
||||
/scripts/cwp_api webservers restart
|
||||
/scripts/cwp_api webservers reload
|
||||
```
|
||||
|
||||
### Scripts
|
||||
```bash
|
||||
sh /scripts/restart_httpd
|
||||
sh /scripts/cwpsrv_rebuild_user_conf
|
||||
sh /scripts/varnish_clear_cache
|
||||
sh /scripts/apache_mpm_calculator
|
||||
```
|
||||
|
||||
### Verificações
|
||||
```bash
|
||||
systemctl status httpd --no-pager | head -15
|
||||
systemctl status nginx --no-pager | head -15
|
||||
httpd -t # SEMPRE testar antes de restart
|
||||
nginx -t
|
||||
httpd -S 2>&1 | grep -E 'port|namevhost' | head -20
|
||||
```
|
||||
|
||||
### Restart vs Reload
|
||||
| Operação | Quando |
|
||||
|----------|--------|
|
||||
| Reload | Alterações pequenas, sem downtime |
|
||||
| Restart | Alterações grandes, módulos |
|
||||
|
||||
### Workflow rebuild completo
|
||||
```bash
|
||||
/scripts/cwp_api webservers rebuild_all
|
||||
/scripts/cwp_api webservers restart
|
||||
```
|
||||
|
||||
### Validação
|
||||
```bash
|
||||
systemctl is-active httpd nginx
|
||||
curl -sI localhost | head -5
|
||||
curl -sI http://DOMINIO | head -5
|
||||
tail -20 /var/log/httpd/error_log
|
||||
tail -20 /var/log/nginx/error.log
|
||||
```
|
||||
|
||||
### Anti-patterns (críticos)
|
||||
Inventar comandos (PHP desactivado, site offline) | restart sem `httpd -t` | editar vhosts manualmente (sobrescritos) | ignorar erros teste | restart em vez de reload | alterar sysctl sem pesquisar | `kill -9` em processos CWP.
|
||||
|
||||
---
|
||||
|
||||
## 8. Scripts oficiais CWP — referência completa
|
||||
|
||||
Forma de execução: `sh /scripts/NOME` ou `/scripts/NOME`.
|
||||
|
||||
### Sistema CWP
|
||||
| Script | Descrição |
|
||||
|--------|-----------|
|
||||
| `cwp_version` | Ver versão CWP |
|
||||
| `update_cwp` | Actualizar CWP |
|
||||
| `restart_cwpsrv` / `reload_cwpsrv` | Restart/reload painel |
|
||||
| `cwp_monitor` | Verificar load |
|
||||
| `cwp_set_memory_limit` | Alterar memory limit |
|
||||
| `add_alert` | Adicionar alerta |
|
||||
|
||||
### Utilizadores
|
||||
`list_users`, `list_domains`, `list_subdomains`, `whoowns DOMINIO`, `user_backup USERNAME`, `ulimit_user_check`, `cwpsrv_rebuild_user_conf`.
|
||||
|
||||
### SSL
|
||||
`install_acme`, `autossl_reload`, `autossl_fix_tmp_path`, `autossl_generate_apache_conf`, `generate_hostname_ssl`, `hostname_ssl_restart_services`.
|
||||
|
||||
### MySQL
|
||||
`upgrade_mysql`, `mysql_pwd_reset`, `mysql_fix_myisam_tables`, `mysql_phpmyadmin_update`, `mysql_set_max_connections`, `mysql_show_max_connections`, `checkdb`.
|
||||
|
||||
### Email
|
||||
`install_cbpolicyd`, `check_postqueue`, `mail_queue_stats`, `mail_roundcube_update`, `mail_vmail_import`, `mail_rebuild_sni_certs`.
|
||||
|
||||
### WebServers
|
||||
`restart_httpd`, `apache_mpm_calculator`, `varnish_clear_cache`.
|
||||
|
||||
### PHP
|
||||
`phpfpm_rebuild_user_conf`, `php_big_file_upload`, `update_ioncube`, `cron_fix_openbasedir`, `dso_handler_remove`.
|
||||
|
||||
### Segurança
|
||||
`cwp_bruteforce_protection`, `security_is_my_server_hacked`, `cwpsecure_update_rules`.
|
||||
|
||||
### FTP
|
||||
`reinstall_pure-ftpd`, `install_pure-ftpd_tls`.
|
||||
|
||||
### DNS
|
||||
`dns_sync_slave2`.
|
||||
|
||||
### Aplicações
|
||||
`install_imagick`, `install_maldet`, `install_net2ftp`, `install_terminal`, `install_supportKey`, `softaculous_fix_update`.
|
||||
|
||||
### Antivírus
|
||||
`freshclam`, `reinstall_clamd_amavisd`, `clamd_fix_100_cpu_usage`.
|
||||
|
||||
### API
|
||||
`install_api`, `check_api`.
|
||||
|
||||
### Outros
|
||||
`chroot_add`/`chroot_remove`, `bandwidth_run`, `disk_check`, `cgroups_blkio`, `net_show_connections`, `open_basedir-suphp`, `image_rebuild_server_config`, `cpanel_addhandlers`, `el8_stream_convert_to_cwp_stable`.
|
||||
|
||||
### Top 10 mais usados
|
||||
1. `user_backup USERNAME`
|
||||
2. `whoowns DOMINIO`
|
||||
3. `list_users`
|
||||
4. `security_is_my_server_hacked`
|
||||
5. `mysql_pwd_reset`
|
||||
6. `restart_httpd`
|
||||
7. `check_postqueue`
|
||||
8. `cwp_version`
|
||||
9. `update_cwp`
|
||||
10. `varnish_clear_cache`
|
||||
|
||||
### API unificada — outras secções
|
||||
|
||||
**Apps:**
|
||||
```bash
|
||||
/scripts/cwp_api apps install_softaculous
|
||||
/scripts/cwp_api apps remove_softaculous
|
||||
/scripts/cwp_api apps install_sitepad
|
||||
/scripts/cwp_api apps remove_sitepad
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Versão:** 2.0.0 (consolidação 8->1, 07-04-2026) | **Autor:** Descomplicar®
|
||||
**Fonte:** wiki.centos-webpanel.com, docs.control-webpanel.com
|
||||
|
||||
## Healing Log
|
||||
|
||||
```jsonl
|
||||
{"date":"","issue":"","fix":"","source":"user|auto"}
|
||||
```
|
||||
Reference in New Issue
Block a user