# Instalare

## Cerinte

- nod Proxmox VE cu acces root
- `jq` disponibil pe host
- acces SSH pentru instalare remote

## Metoda recomandata

Wrapper-ul [setup.sh](/Users/bogdan/Documents/Workspaces/Xdev/Madagascar/cluster/projects/pve-guests-state/setup.sh) este metoda standard de install si uninstall.

### Instalare locala

```bash
sudo ./setup.sh --local
```

### Instalare remote

```bash
sudo ./setup.sh <node>
sudo ./setup.sh --user admin <node>
```

## Ce instaleaza

- `/usr/local/sbin/pgs`
- `/usr/local/lib/xdev/pve-guests-state/uninstall.sh`
- `/usr/local/sbin/xdev-pve-guests-state-uninstall`
- `/usr/local/share/doc/xdev/pve-guests-state/*`
- state runtime in `/var/lib/xdev/pve-guests-state/`

## Verificare dupa install

```bash
/usr/local/sbin/pgs suspend --dry-run -v
journalctl -t pgs -n 20
```

## Uninstall

### Metoda recomandata

```bash
sudo ./setup.sh --local --uninstall
sudo ./setup.sh --uninstall <node>
```

### Direct pe host

```bash
sudo /usr/local/lib/xdev/pve-guests-state/uninstall.sh
```

## Reinstall

Fluxul acceptat este:

```text
uninstall -> install
```

Practic:
- daca exista deja un install curent, installerul ruleaza mai intai uninstall-ul canonic
- reinstall direct peste fisiere ramase dintr-o versiune veche nu este workflow-ul recomandat

## State file

Locatia curenta:

```bash
cat /var/lib/xdev/pve-guests-state/pgs-state.json
```

Compatibilitate:
- daca exista vechiul fisier `/var/lib/pve-manager/pgs-state.json`, noua versiune il migreaza automat

## Unitati systemd legacy

Fisierele din [systemd](/Users/bogdan/Documents/Workspaces/Xdev/Madagascar/cluster/projects/pve-guests-state/systemd) sunt pastrate doar ca referinta istorica. Scripturile actuale nu le instaleaza; dimpotriva, le elimina daca sunt prezente pe host.
