feat: Versionsnummer auf 1.0.5 erhöht und Installationsskript aktualisiert
This commit is contained in:
11
README.md
11
README.md
@@ -274,12 +274,7 @@ sudo systemctl stop picopy
|
|||||||
|
|
||||||
So wird ein neues Release erstellt, das alle Nutzer automatisch als Update angezeigt bekommen:
|
So wird ein neues Release erstellt, das alle Nutzer automatisch als Update angezeigt bekommen:
|
||||||
|
|
||||||
**1. Versionen erhöhen**
|
**1. Version erhöhen**
|
||||||
|
|
||||||
In `app.py`:
|
|
||||||
```python
|
|
||||||
VERSION = '1.1.0' # ← neue Versionsnummer
|
|
||||||
```
|
|
||||||
|
|
||||||
In `version.txt`:
|
In `version.txt`:
|
||||||
```
|
```
|
||||||
@@ -289,7 +284,7 @@ In `version.txt`:
|
|||||||
**2. Committen & pushen**
|
**2. Committen & pushen**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git add app.py version.txt
|
git add version.txt
|
||||||
git commit -m "Release v1.1.0"
|
git commit -m "Release v1.1.0"
|
||||||
git push
|
git push
|
||||||
```
|
```
|
||||||
@@ -300,7 +295,7 @@ Unter [git.leuschner.dev/Tobias/PiCopy/releases](https://git.leuschner.dev/Tobia
|
|||||||
|
|
||||||
**Das war's.** Alle laufenden PiCopy-Instanzen erkennen das Update innerhalb von 6 Stunden automatisch und zeigen das Badge im Web-Interface an.
|
**Das war's.** Alle laufenden PiCopy-Instanzen erkennen das Update innerhalb von 6 Stunden automatisch und zeigen das Badge im Web-Interface an.
|
||||||
|
|
||||||
> **Hinweis:** `version.txt` und `app.py` müssen immer dieselbe Versionsnummer haben. Die `version.txt` ist der einzige Vergleichspunkt – der Inhalt der `app.py` wird erst beim tatsächlichen Update-Install heruntergeladen.
|
> **Hinweis:** `version.txt` ist die Quelle der Wahrheit. `app.py` liest diese Datei beim Start und der Installer/Updater legt sie neben der App unter `/opt/picopy/version.txt` ab.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
19
app.py
19
app.py
@@ -18,8 +18,18 @@ from flask import Flask, jsonify, request
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
VERSION = '1.0.3'
|
|
||||||
RAW_BASE = 'https://git.leuschner.dev/Tobias/PiCopy/raw/branch/main'
|
RAW_BASE = 'https://git.leuschner.dev/Tobias/PiCopy/raw/branch/main'
|
||||||
|
VERSION_FILE = Path(__file__).with_name('version.txt')
|
||||||
|
|
||||||
|
|
||||||
|
def load_installed_version():
|
||||||
|
try:
|
||||||
|
return VERSION_FILE.read_text(encoding='utf-8').strip() or '1.0.4'
|
||||||
|
except Exception:
|
||||||
|
return 'X.X.X'
|
||||||
|
|
||||||
|
|
||||||
|
VERSION = load_installed_version()
|
||||||
|
|
||||||
BASE_DIR = Path('/opt/picopy')
|
BASE_DIR = Path('/opt/picopy')
|
||||||
CONFIG_FILE = BASE_DIR / 'config.json'
|
CONFIG_FILE = BASE_DIR / 'config.json'
|
||||||
@@ -1091,6 +1101,8 @@ def r_update_install():
|
|||||||
log.info('Update wird heruntergeladen…')
|
log.info('Update wird heruntergeladen…')
|
||||||
req = _urlreq.urlopen(f'{RAW_BASE}/app.py', timeout=60)
|
req = _urlreq.urlopen(f'{RAW_BASE}/app.py', timeout=60)
|
||||||
new_code = req.read().decode()
|
new_code = req.read().decode()
|
||||||
|
vreq = _urlreq.urlopen(f'{RAW_BASE}/version.txt', timeout=10)
|
||||||
|
new_version = vreq.read().decode().strip()
|
||||||
|
|
||||||
# Syntax-Check bevor wir irgendetwas überschreiben
|
# Syntax-Check bevor wir irgendetwas überschreiben
|
||||||
compile(new_code, 'app.py', 'exec')
|
compile(new_code, 'app.py', 'exec')
|
||||||
@@ -1100,6 +1112,11 @@ def r_update_install():
|
|||||||
with open(tmp, 'rb') as fh:
|
with open(tmp, 'rb') as fh:
|
||||||
os.fsync(fh.fileno()) # Sicherstellen dass Daten auf der Platte sind
|
os.fsync(fh.fileno()) # Sicherstellen dass Daten auf der Platte sind
|
||||||
os.replace(str(tmp), '/opt/picopy/app.py') # Atomares Umbenennen
|
os.replace(str(tmp), '/opt/picopy/app.py') # Atomares Umbenennen
|
||||||
|
vtmp = Path('/opt/picopy/version.txt.tmp')
|
||||||
|
vtmp.write_text(new_version + '\n', encoding='utf-8')
|
||||||
|
with open(vtmp, 'rb') as fh:
|
||||||
|
os.fsync(fh.fileno())
|
||||||
|
os.replace(str(vtmp), '/opt/picopy/version.txt')
|
||||||
log.info('Update installiert – starte Dienst neu…')
|
log.info('Update installiert – starte Dienst neu…')
|
||||||
|
|
||||||
# Systemd startet den Dienst automatisch neu
|
# Systemd startet den Dienst automatisch neu
|
||||||
|
|||||||
11
install.sh
11
install.sh
@@ -53,6 +53,17 @@ else
|
|||||||
fi
|
fi
|
||||||
ok "app.py installiert"
|
ok "app.py installiert"
|
||||||
|
|
||||||
|
# ── Versionsdatei kopieren oder herunterladen ────────────────────────────────
|
||||||
|
if [ -f "./version.txt" ]; then
|
||||||
|
info "Lokale version.txt wird verwendet..."
|
||||||
|
cp version.txt "$INSTALL_DIR/version.txt"
|
||||||
|
else
|
||||||
|
info "version.txt wird heruntergeladen..."
|
||||||
|
curl -sSfL "$REPO_RAW/version.txt" -o "$INSTALL_DIR/version.txt" \
|
||||||
|
|| fail "Download der version.txt fehlgeschlagen. Prüfe die Internet-Verbindung."
|
||||||
|
fi
|
||||||
|
ok "version.txt installiert"
|
||||||
|
|
||||||
# ── Python-Umgebung ───────────────────────────────────────────────────────────
|
# ── Python-Umgebung ───────────────────────────────────────────────────────────
|
||||||
info "Python venv wird erstellt..."
|
info "Python venv wird erstellt..."
|
||||||
python3 -m venv "$INSTALL_DIR/venv"
|
python3 -m venv "$INSTALL_DIR/venv"
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.0.4
|
1.0.5
|
||||||
Reference in New Issue
Block a user