Compare commits

...

6 Commits

Author SHA1 Message Date
pedro ed08684734 settings.ini: move to using domain 2024-09-26 08:50:05 -03:00
pedro 044f3b9e4b workbench-script: warn when not root 2024-09-26 08:49:53 -03:00
pedro d756a3a9be improve docs 2024-09-26 08:49:38 -03:00
pedro d4076fa2a8 pxe: do the trick for rw snapshots dir 2024-09-25 20:16:20 -03:00
pedro a22773076c workbench-script: remove ntplib
- it was not being used
- let's delegate this to Operating System
2024-09-25 18:07:43 -03:00
pedro 500531d15f pxe: move README to spanish 2024-09-25 17:59:57 -03:00
7 changed files with 59 additions and 15 deletions

View File

@ -54,3 +54,9 @@ OPCIONES
## Enfoque
workbench-script trata de ser simple y minimalista, una función principal y funciones de soporte la lectura de las diferentes funcionalidades.
## Generar ISO para el USB
Para generar la iso y preparar un usb que arranque con workbench necesitas generarte una workbench de este, con tu configuración específica
Ejecuta `./deploy-workbench.sh`

View File

@ -272,6 +272,10 @@ cd /mnt
# detect pxe env
if [ -d /run/live/medium ]; then
config_path='/run/live/medium/settings.ini'
# debian live nfs path is readonly, do a trick
# to make snapshots subdir readwrite
nfs_host="\$(df -hT | grep nfs | cut -f1 -d: | head -n1)"
mount \${nfs_host}:/snapshots /run/live/medium/snapshots
else
config_path='/mnt/settings.ini'
fi

27
pxe/README-es.md Normal file
View File

@ -0,0 +1,27 @@
# workbench via PXE
## Introducción
Permite arrancar workbench a través de la red en vez de por USB. Utiliza la misma imagen generada por el script [deploy-workbench.sh](../deploy-workbench.sh), pero en el formato compatible con el arranque por red en vez de la iso.
Ejecuta el siguiente script en un servidor debian estable que estará dedicado a la gestión del pxe server
```
./install-pxe.sh
```
Este servidor aporta un servicio de arranque por red tipo PXE, y no hace colisión con un servidor DHCP existente.
## Funcionamiento
El servidor PXE ofrece a la máquina que arranca un *debian live* a través de [NFS](https://es.wikipedia.org/wiki/Network_File_System). Una vez arrancado, ejecuta el `workbench-script.py` con la configuración remota del servidor PXE. Cuando ha terminado, también guarda en el mismo servidor PXE el snapshot resultante. También lo puede guardar en devicehub si se especifica en la variable `url` de la configuración `settings.ini`.
## Recursos
El servicio PXE
- Originalmente inspirado en este artículo https://farga.exo.cat/exo/wiki/src/branch/master/howto/apu/apu-installer.md
- https://github.com/eReuse/workbench-live/blob/feature/pxe/docs/PXE-setup.md
- https://wiki.debian.org/PXEBootInstall
- https://wiki.debian.org/DebianInstaller/NetbootFirmware
- [In this presentation](https://people.debian.org/~andi/LiveNetboot.pdf), recomienda página 12 [4.6 Building a netboot image](https://live-team.pages.debian.net/live-manual/html/live-manual/the-basics.en.html#236) [4.7 Webbooting](https://live-team.pages.debian.net/live-manual/html/live-manual/the-basics.en.html#275)

View File

@ -1,9 +1,5 @@
Run `install-pxe.sh`
# pxe
## Resources
- [Español](./README-es.md)
- [English](./README-en.md)
- I originally inspired on this article https://farga.exo.cat/exo/wiki/src/branch/master/howto/apu/apu-installer.md
- https://github.com/eReuse/workbench-live/blob/feature/pxe/docs/PXE-setup.md
- https://wiki.debian.org/PXEBootInstall
- https://wiki.debian.org/DebianInstaller/NetbootFirmware
- [In this presentation](https://people.debian.org/~andi/LiveNetboot.pdf), page 12 recommends [4.6 Building a netboot image](https://live-team.pages.debian.net/live-manual/html/live-manual/the-basics.en.html#236) [4.7 Webbooting](https://live-team.pages.debian.net/live-manual/html/live-manual/the-basics.en.html#275)

View File

@ -23,9 +23,20 @@ backup_file() {
install_nfs() {
backup_file /etc/exports
# debian live nfs path is readonly, do a trick
# to make snapshots subdir readwrite
if grep -q "/snapshots" /proc/mounts; then
mount --bind "${nfs_path}/snapshots" "/snapshots"
fi
cat > /etc/exports <<END
${nfs_path} ${nfs_allowed_lan}(rw,sync,no_subtree_check,no_root_squash)
/snapshots ${nfs_allowed_lan}(rw,sync,no_subtree_check,no_root_squash)
END
# reload nfs exports
exportfs -vra
# append live directory, which is expected by the debian live env
mkdir -p "${nfs_path}/live"
mkdir -p "${nfs_path}/snapshots"

View File

@ -1,5 +1,5 @@
[settings]
url = http://127.0.0.1:8000/api/snapshot/
url = http://localhost:8000/api/snapshot/
token = '1234'
# path = /path/to/save
# device = your_device_name

View File

@ -7,7 +7,6 @@ import hashlib
import argparse
import configparser
import ntplib
import requests
@ -228,6 +227,8 @@ def smartctl(all_disks, disk=None):
## End Command Functions ##
# TODO permitir selección
# TODO permitir que vaya más rápido
def get_data(all_disks):
lshw = 'sudo lshw -json'
hwinfo = 'sudo hwinfo --reallyall'
@ -287,12 +288,6 @@ def send_snapshot_to_devicehub(snapshot, token, url):
except:
print(f"workbench: ERROR: Snapshot not remotely sent. URL '{url}' is unreachable. Do you have internet? Is your server up & running?")
@logs
def sync_time():
# is neccessary?
ntplib.NTPClient()
response = client.request('pool.ntp.org')
def load_config(config_file="settings.ini"):
"""
Tries to load configuration from a config file.
@ -348,6 +343,11 @@ def main():
config = load_config(config_file)
# TODO show warning if non root, means data is not complete
# if annotate as potentially invalid snapshot (pending the new API to be done)
if os.geteuid() != 0:
print("workbench: WARNING: This script must be run as root. Collected data will be incomplete or unusable")
all_disks = get_disks()
snapshot = gen_snapshot(all_disks)