Skip to content

Commit aa668a2

Browse files
committed
Release v0.2.8.4
1 parent c9c8132 commit aa668a2

3 files changed

Lines changed: 42 additions & 43 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ It outputs system details, update status, and network configuration, then writes
2121
1. Download the latest `.deb` from the [Releases](https://github.com/RoBro92/nodeinfo/releases) page and install it on your Proxmox host:
2222

2323
```bash
24-
wget https://github.com/RoBro92/nodeinfo/releases/latest/download/nodeinfo_v0.2.8.3.deb
24+
wget https://github.com/RoBro92/nodeinfo/releases/latest/download/nodeinfo_v0.2.8.4.deb
2525
```
2626

2727
2. Install the package:
2828

2929
```bash
30-
sudo dpkg -i nodeinfo_v0.2.8.3.deb
30+
sudo dpkg -i nodeinfo_v0.2.8.4.deb
3131
```
3232

3333
3. Once installed you can run:

nodeinfo/debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: nodeinfo
2-
Version: 0.2.8.3
2+
Version: 0.2.8.4
33
Section: admin
44
Priority: optional
55
Architecture: all

nodeinfo/usr/local/bin/nodeinfo

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import os
77
import re
88
import requests
99

10-
VERSION = "0.2.8.3"
10+
VERSION = "0.2.8.4"
1111
GITHUB_REPO = "RoBro92/nodeinfo"
1212

1313
if "--version" in sys.argv or "-v" in sys.argv:
@@ -256,7 +256,6 @@ def update_notes(vmid, vmtype, markdown):
256256
with open(config_path, "r") as f:
257257
lines = f.readlines()
258258

259-
# Find nodeinfo block boundaries
260259
start_idx = end_idx = None
261260
for i, line in enumerate(lines):
262261
if line.strip() == "# === nodeinfo start ===":
@@ -266,78 +265,78 @@ def update_notes(vmid, vmtype, markdown):
266265
break
267266

268267
if start_idx is not None and end_idx is not None:
268+
# Nodeinfo block exists
269+
269270
# Extract current nodeinfo block lines
270-
nodeinfo_block = lines[start_idx+1:end_idx]
271+
nodeinfo_block = lines[start_idx + 1:end_idx]
271272

272-
# Find user notes header line index in nodeinfo block
273-
user_notes_header = "📝 **User Notes**"
273+
# Find the user notes header line index inside nodeinfo block
274+
user_notes_header = "# 📝 **User Notes**"
274275
user_notes_start_idx = None
275276
for i, line in enumerate(nodeinfo_block):
276-
# Strip '#' and whitespace for matching header
277-
if line.lstrip("# ").strip() == user_notes_header:
277+
if line.strip() == user_notes_header:
278278
user_notes_start_idx = i
279279
break
280280

281281
if user_notes_start_idx is not None:
282-
# Preserve all user notes lines from header to end of nodeinfo block
283-
preserved_user_notes = nodeinfo_block[user_notes_start_idx:]
284-
# Notes before user notes section (autogenerated)
285-
autogenerated_notes = nodeinfo_block[:user_notes_start_idx]
282+
# Split autogenerated and user notes parts
283+
autogenerated_lines = nodeinfo_block[:user_notes_start_idx]
284+
user_notes_lines = nodeinfo_block[user_notes_start_idx:]
286285
else:
287-
# No user notes section: all is autogenerated
288-
preserved_user_notes = []
289-
autogenerated_notes = nodeinfo_block
290-
291-
# Confirm overwrite if notes exist (you can keep your existing confirmation logic here)
292-
293-
# Prepare new autogenerated notes lines (with '# ' prefix)
286+
# No user notes section: treat all as autogenerated, user notes empty
287+
autogenerated_lines = nodeinfo_block
288+
user_notes_lines = [
289+
"# 📝 **User Notes**\n",
290+
"#\n",
291+
"# *(You can safely add your notes here. This section will be preserved when nodeinfo updates.)*\n"
292+
]
293+
294+
# Prompt user to confirm overwrite
295+
confirm = input("⚠️ A previous nodeinfo block was found. Overwrite autogenerated section? (y/N): ").strip().lower()
296+
if confirm != "y":
297+
print("❌ Update cancelled.")
298+
return False # Don't update, no message printed below
299+
300+
# Prepare new autogenerated notes lines with '# ' prefix
294301
new_autogen_notes = [f"# {line}\n" for line in markdown.splitlines()]
295-
# Remove user notes header and below from new_autogen_notes if present
296-
# (to avoid duplication)
297-
if user_notes_header in markdown:
298-
idx = markdown.splitlines().index(user_notes_header)
299-
new_autogen_notes = [f"# {line}\n" for line in markdown.splitlines()[:idx]]
300-
301-
# Compose final new notes block:
302-
new_nodeinfo_block = new_autogen_notes
303-
if preserved_user_notes:
304-
new_nodeinfo_block.extend(preserved_user_notes)
305-
else:
306-
# Add default user notes header and placeholder if none preserved
307-
new_nodeinfo_block.append(f"# {user_notes_header}\n")
308-
new_nodeinfo_block.append("#\n")
309-
new_nodeinfo_block.append("# *(You can safely add your notes here. This section will be preserved when nodeinfo updates.)*\n")
302+
303+
# Compose final nodeinfo block: new autogenerated + preserved user notes
304+
new_nodeinfo_block = new_autogen_notes + user_notes_lines
310305

311306
# Wrap with start and end markers
312307
final_notes = ["# === nodeinfo start ===\n"] + new_nodeinfo_block + ["# === nodeinfo end ===\n"]
313308

314-
# Remove all previous note lines (lines starting with '#') between start_idx and end_idx
315-
# And insert the final_notes
316-
new_lines = lines[:start_idx] + final_notes + lines[end_idx+1:]
309+
# Replace old block with new block
310+
new_lines = lines[:start_idx] + final_notes + lines[end_idx + 1:]
317311

318312
with open(config_path, "w") as f:
319313
f.writelines(new_lines)
320314

321315
print(f"✅ Notes written to {config_path}")
322316
return True
317+
323318
else:
324-
# No nodeinfo block found, just append it at the end of the config file
319+
# No nodeinfo block found, append new block + default user notes
325320
with open(config_path, "a") as f:
326-
f.write("\n# === nodeinfo start ===\n")
321+
f.write("# === nodeinfo start ===\n")
327322
for line in markdown.splitlines():
328323
f.write(f"# {line}\n")
324+
f.write("# 📝 **User Notes**\n")
325+
f.write("#\n")
326+
f.write("# *(You can safely add your notes here. This section will be preserved when nodeinfo updates.)*\n")
329327
f.write("# === nodeinfo end ===\n")
330328
print(f"✅ Nodeinfo notes appended to {config_path}")
331329
return True
330+
332331
except Exception as e:
333332
print(f"❌ Failed to write LXC notes: {e}")
334333
return False
334+
335335
else:
336-
# QEMU notes handling (overwrite)
336+
# QEMU VM notes overwrite completely
337337
subprocess.run(["qm", "set", vmid, "--notes", markdown])
338338
return True
339339

340-
341340
def do_self_update():
342341

343342
try:

0 commit comments

Comments
 (0)