Compare commits
No commits in common. "0cd1c7c50228ea7211b373e2b3bd193bfa33bd95" and "849983aaebcbc5d1c06b282ef7a14024b62016f5" have entirely different histories.
0cd1c7c502
...
849983aaeb
|
@ -1,5 +1,5 @@
|
||||||
iso
|
iso
|
||||||
settings.ini
|
settings.ini
|
||||||
# ignore all possible snapshots in this repo
|
# ignore all possible snapshots in this dir
|
||||||
*.json
|
*.json
|
||||||
pxe/.env
|
pxe/.env
|
||||||
|
|
|
@ -411,7 +411,8 @@ install_requirements() {
|
||||||
squashfs-tools
|
squashfs-tools
|
||||||
xorriso
|
xorriso
|
||||||
mtools
|
mtools
|
||||||
dosfstools'
|
dosfstools
|
||||||
|
nfs-common'
|
||||||
# secureboot:
|
# secureboot:
|
||||||
# -> extra src https://wiki.debian.org/SecureBoot/
|
# -> extra src https://wiki.debian.org/SecureBoot/
|
||||||
# -> extra src https://wiki.debian.org/SecureBoot/VirtualMachine
|
# -> extra src https://wiki.debian.org/SecureBoot/VirtualMachine
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
server_ip=192.168.1.2
|
server_ip=192.168.1.2
|
||||||
nfs_allowed_lan=192.168.1.0/24
|
nfs_allowed_lan=192.168.1.0/24
|
||||||
tftp_path='/srv/pxe-tftp'
|
tftp_path='/srv/pxe-tftp'
|
||||||
nfs_path='/srv/pxe-nfs'
|
nfs_images_path='/srv/pxe-images'
|
||||||
|
nfs_wbdata_path='/srv/workbench-data'
|
||||||
|
|
|
@ -24,15 +24,16 @@ backup_file() {
|
||||||
install_nfs() {
|
install_nfs() {
|
||||||
backup_file /etc/exports
|
backup_file /etc/exports
|
||||||
cat > /etc/exports <<END
|
cat > /etc/exports <<END
|
||||||
${nfs_path} ${nfs_allowed_lan}(rw,sync,no_subtree_check,no_root_squash)
|
${nfs_images_path} ${nfs_allowed_lan}(rw,sync,no_subtree_check,no_root_squash)
|
||||||
|
${nfs_wbdata_path} ${nfs_allowed_lan}(rw,sync,no_subtree_check,no_root_squash)
|
||||||
END
|
END
|
||||||
# append live directory, which is expected by the debian live env
|
# append live directory, which is expected by the debian live env
|
||||||
mkdir -p "${nfs_path}/live"
|
mkdir -p "${nfs_images_path}/live"
|
||||||
mkdir -p "${nfs_path}/snapshots"
|
mkdir -p "${nfs_wbdata_path}/snapshots"
|
||||||
|
|
||||||
if [ ! -f "${nfs_path}/settings.ini" ]; then
|
if [ ! -f "${nfs_wbdata_path}/settings.ini" ]; then
|
||||||
if [ -f "settings.ini" ]; then
|
if [ -f "../settings.ini" ]; then
|
||||||
ln -sv "${nfs_path}/settings.ini" "settings.ini"
|
cp -v ../settings.ini "${nfs_wbdata_path}/settings/settings.ini"
|
||||||
else
|
else
|
||||||
echo "ERROR: ../settings.ini does not exist yet, cannot read config from there. You can take inspiration with file ../settings.ini.example"
|
echo "ERROR: ../settings.ini does not exist yet, cannot read config from there. You can take inspiration with file ../settings.ini.example"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -83,7 +84,7 @@ default wb
|
||||||
label wb
|
label wb
|
||||||
KERNEL vmlinuz
|
KERNEL vmlinuz
|
||||||
INITRD initrd.img
|
INITRD initrd.img
|
||||||
APPEND ip=dhcp netboot=nfs nfsroot=${server_ip}:${nfs_path}/ boot=live text forcepae
|
APPEND ip=dhcp netboot=nfs nfsroot=${server_ip}:${nfs_images_path}/ boot=live text forcepae
|
||||||
END
|
END
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -100,7 +101,8 @@ init_config() {
|
||||||
VERSION_CODENAME="${VERSION_CODENAME:-bookworm}"
|
VERSION_CODENAME="${VERSION_CODENAME:-bookworm}"
|
||||||
tftp_path="${tftp_path:-/srv/pxe-tftp}"
|
tftp_path="${tftp_path:-/srv/pxe-tftp}"
|
||||||
server_ip="${server_ip}"
|
server_ip="${server_ip}"
|
||||||
nfs_path="${nfs_path:-/srv/pxe-nfs}"
|
nfs_images_path="${nfs_images_path:-/srv/pxe-images}"
|
||||||
|
nfs_wbdata_path="${nfs_wbdata_path:-/srv/pxe-wbdata}"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[settings]
|
|
||||||
url = http://127.0.0.1:8000/api/snapshot/
|
|
||||||
token = '1234'
|
|
||||||
path = /srv/pxe-nfs/snapshots
|
|
||||||
# device = your_device_name
|
|
||||||
# # erase = basic
|
|
|
@ -1,3 +0,0 @@
|
||||||
This is the path by default used by workbench-script
|
|
||||||
|
|
||||||
You can change it in the configuration
|
|
|
@ -249,30 +249,15 @@ def gen_snapshot(all_disks):
|
||||||
|
|
||||||
|
|
||||||
def save_snapshot_in_disk(snapshot, path):
|
def save_snapshot_in_disk(snapshot, path):
|
||||||
snapshot_path = os.path.join(path, 'snapshots')
|
|
||||||
|
|
||||||
filename = "{}/{}_{}.json".format(
|
filename = "{}/{}_{}.json".format(
|
||||||
snapshot_path,
|
|
||||||
datetime.now().strftime("%Y%m%d-%H_%M_%S"),
|
|
||||||
snapshot['uuid'])
|
|
||||||
|
|
||||||
try:
|
|
||||||
if not os.path.exists(snapshot_path):
|
|
||||||
os.makedirs(snapshot_path)
|
|
||||||
print(f"workbench: INFO: Created snapshots directory at '{snapshot_path}'")
|
|
||||||
|
|
||||||
with open(filename, "w") as f:
|
|
||||||
f.write(json.dumps(snapshot))
|
|
||||||
print(f"workbench: INFO: Snapshot written in path '{filename}'")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"workbench: WARNING: Failed to write in snapshots directory: {e}. Attempting to save in actual path.")
|
|
||||||
fallback_filename = "{}/{}_{}.json".format(
|
|
||||||
path,
|
path,
|
||||||
datetime.now().strftime("%Y%m%d-%H_%M_%S"),
|
datetime.now().strftime("%Y%m%d-%H_%M_%S"),
|
||||||
snapshot['uuid'])
|
snapshot['uuid']
|
||||||
with open(fallback_filename, "w") as f:
|
)
|
||||||
|
print(f"workbench: INFO: Snapshot written in path '{filename}'")
|
||||||
|
with open(filename, "w") as f:
|
||||||
f.write(json.dumps(snapshot))
|
f.write(json.dumps(snapshot))
|
||||||
print(f"workbench: INFO: Snapshot written in fallback path '{fallback_filename}'")
|
|
||||||
|
|
||||||
# TODO sanitize url, if url is like this, it fails
|
# TODO sanitize url, if url is like this, it fails
|
||||||
# url = 'http://127.0.0.1:8000/api/snapshot/'
|
# url = 'http://127.0.0.1:8000/api/snapshot/'
|
||||||
|
|
Loading…
Reference in New Issue