Regalamiunsorriso/.github/instructions/regalamiunsorriso-83-149-164-4.instructions.md

131 lines
No EOL
4.8 KiB
Markdown

---
description: 'Use when: deploying, staging, copying, or promoting regalamiunsorriso site files on server 83.149.164.4, especially for sync/** and www/** changes.'
applyTo: 'sync/**, www/**'
---
# Regalami Un Sorriso Server 83.149.164.4
Instructions in this file are specific to the `regalamiunsorriso` site hosted on server `83.149.164.4` over SSH port `410`.
## Server Access
- SSH user: `marco`
- SSH key: `C:\Users\Maddo\.ssh\id_rsa`
- SSH port: `410`
- Direct SSH login works with the key above.
- The login banner before authentication is expected.
## Preferred SSH Workflow
Use an interactive TTY when a command may need sudo:
```powershell
ssh -tt -i C:\Users\Maddo\.ssh\id_rsa -p 410 marco@83.149.164.4
```
For root access, use:
```tcsh
sudo tcsh
```
If you need a single elevated command:
```powershell
ssh -tt -i C:\Users\Maddo\.ssh\id_rsa -p 410 marco@83.149.164.4 "sudo tcsh -c 'command here'"
```
## Shell Behavior On This Host
- The remote login shell behaves as `tcsh`.
- POSIX shell constructs like `for ...; do ...; done` fail unless you explicitly run them through `sh -c`.
- The server `sh` does not support `-l`, so use `sh -c`, not `sh -lc`.
- If `sudo` reports that a terminal is required, reconnect with `-tt`.
## MCP Limitation
- The MCP SSH tools have not been reliable for this host and previously failed authentication or transport checks.
- Prefer direct terminal SSH commands for this server unless the MCP path is revalidated.
## Site Paths
- Incoming staging root: `/home/marco/regalamiunsorriso/incoming/www`
- Live site root: `/home/sites/regalamiunsorriso/www`
## Staging Workflow
When `www/**` files need deployment:
1. Build the file list from git changes after the initial `www` import baseline.
2. Include any required uncommitted working tree files explicitly if they must be deployed.
3. Copy the selected files into `/home/marco/regalamiunsorriso/incoming/www`, preserving the `www/...` directory structure.
4. Prefer a streamed tar transfer over SSH for batches of files.
Example staging command pattern:
```powershell
tar -cf - -C K:\various\regalamiunsorriso <file-list-under-www> | ssh -i C:\Users\Maddo\.ssh\id_rsa -p 410 marco@83.149.164.4 "tar -xf - -C /home/marco/regalamiunsorriso/incoming"
```
## Promotion Rules
- Promotion to the live site must happen through `sudo tcsh`.
- Do not copy directly as `marco` into `/home/sites/regalamiunsorriso/www`.
- Before replacing an existing live file, capture its exact owner, group, and mode.
- After copy, restore the same owner, group, and mode exactly.
- For new files, use the permissions of surrounding live files of the same type in the same directory.
- If same-extension files in the directory have mixed modes, choose an explicit metadata source file and reuse its owner, group, and mode.
## Promotion Automation
Use these scripts for this site:
- Local helper: `sync/promote-file.sh`
- Local batch helper: `sync/promote-www-remaining.sh`
- Remote helper: `/home/marco/promote-file.sh`
- Remote batch helper: `/home/marco/promote-www-remaining.sh`
### Single File Promotion
Run:
```powershell
ssh -tt -i C:\Users\Maddo\.ssh\id_rsa -p 410 marco@83.149.164.4 "sudo tcsh -c '/home/marco/promote-file.sh <staged-path> <live-path> [metadata-source]'"
```
Behavior of `promote-file.sh`:
- If the destination already exists, it copies the file and restores that destination file's original owner, group, and mode.
- If the destination does not exist, it can use an optional third argument as the metadata source file.
- If no third argument is provided for a new file, it falls back to sampling sibling files in the destination directory.
### New PHP Files In Live Root
Root-level PHP files on this site do not all share one mode.
- `/home/sites/regalamiunsorriso/www/_inc_footer.php` is `jenkins:www` with mode `775`
- `/home/sites/regalamiunsorriso/www/gallery1.php` is `jenkins:www` with mode `775`
- `/home/sites/regalamiunsorriso/www/test.php` is `jenkins:www` with mode `644`
For the `faceai_*.php` files, use `/home/sites/regalamiunsorriso/www/_inc_footer.php` as the explicit metadata source.
## Verification
After staging or promotion, verify with:
- `ls -l` for owner, group, and visible mode
- `stat -f` for exact metadata
- `cksum` to compare staged and live file contents
Run verification commands separately if a parallel terminal run becomes unreliable.
## Documentation Expectations
When performing deployments or promotions for this site:
- Record the list of changed files being deployed.
- Distinguish updated files from new files.
- Note whether any deployed file came from the working tree instead of a commit.
- Document every shell quirk or command failure encountered.
- Document the metadata source used for any new live file.
- Update `sync/www-deploy-manifest.md` when the deployment set or procedure changes.