SHA256
Add initial run log file to track execution details
This commit is contained in:
+57
-13
@@ -1,26 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
# GCBoK.WebStaticBuilder — Installationsskript
|
||||
# Installiert das Tool nach /opt/GitCover/webstatic und legt einen Symlink
|
||||
# `webstatic` nach /usr/local/bin. Idempotent.
|
||||
# Installiert das Tool per-user (Default: ~/.local/share/GitCover/webstatic) und
|
||||
# legt einen ausfuehrbaren Wrapper `webstatic` nach ~/.local/bin. Idempotent.
|
||||
# Kein sudo noetig (Spiegelbild des hermes-agent-Update-Konzepts: user-owned
|
||||
# Installationsziel -> `webstatic update` laeuft als normaler User).
|
||||
#
|
||||
# Modi (WEBSTATIC_INSTALL_MODE):
|
||||
# clone (Default) — klont das Quell-Repo inkl. .git nach /opt/GitCover/webstatic.
|
||||
# clone (Default) — klont das Quell-Repo inkl. .git nach INSTALL_DIR.
|
||||
# Ermoeglicht spaeter `git pull` + lokale Anpassungen stashen/mergen
|
||||
# (Hermes-Update-Konzept). Das Ziel ist ein echtes Git-Repo.
|
||||
# copy — kopiert nur das gebaute Binary + Beispiel + Docs (kein .git).
|
||||
#
|
||||
# Hinweis: /opt ist root-owned. Das Script sinnvollerweise als root ausfuehren,
|
||||
# z.B. `sudo env PATH="$PATH" ./install.sh`, damit `dotnet` im PATH bleibt.
|
||||
# Umgebungsvariablen (optional):
|
||||
# WEBSTATIC_INSTALL_MODE clone|copy (Default: clone)
|
||||
# WEBSTATIC_INSTALL_DIR Zielverzeichnis
|
||||
# (Default: $XDG_DATA_HOME/GitCover/webstatic bzw.
|
||||
# ~/.local/share/GitCover/webstatic)
|
||||
# WEBSTATIC_BIN_DIR Verzeichnis fuer den Launcher
|
||||
# (Default: $XDG_BIN_HOME bzw. ~/.local/bin;
|
||||
# nur bei System-Install fallback /usr/local/bin via sudo)
|
||||
#
|
||||
# System-weite Installation nach /opt/GitCover/webstatic (root-owned):
|
||||
# sudo env PATH="$PATH" \
|
||||
# WEBSTATIC_INSTALL_DIR=/opt/GitCover/webstatic \
|
||||
# WEBSTATIC_BIN_DIR=/usr/local/bin ./install.sh
|
||||
set -euo pipefail
|
||||
|
||||
INSTALL_MODE="${WEBSTATIC_INSTALL_MODE:-clone}"
|
||||
INSTALL_DIR="${WEBSTATIC_INSTALL_DIR:-/opt/GitCover/webstatic}"
|
||||
BIN_LINK="/usr/local/bin/webstatic"
|
||||
INSTALL_DIR="${WEBSTATIC_INSTALL_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/GitCover/webstatic}"
|
||||
BIN_DIR="${WEBSTATIC_BIN_DIR:-${XDG_BIN_HOME:-$HOME/.local/bin}}"
|
||||
BIN_LINK="$BIN_DIR/webstatic"
|
||||
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
echo "== GCBoK.WebStaticBuilder Installer =="
|
||||
echo "Modus: $INSTALL_MODE"
|
||||
echo "Installationsziel: $INSTALL_DIR"
|
||||
echo "Launcher: $BIN_LINK"
|
||||
|
||||
# 0) Update-Modus (--update)
|
||||
if [ "${1:-}" = "--update" ]; then
|
||||
echo "== Update =="
|
||||
if [ -d "$INSTALL_DIR/.git" ]; then
|
||||
cd "$INSTALL_DIR"
|
||||
[ -n "$(git status --porcelain)" ] && git stash
|
||||
git pull
|
||||
{ [ -n "$(git stash list)" ] && git stash pop; } || true
|
||||
dotnet build "$INSTALL_DIR/GCBoK.WebStaticBuilder.csproj" -c Release -v minimal
|
||||
else
|
||||
dotnet build "$REPO_DIR/GCBoK.WebStaticBuilder.csproj" -c Release -v minimal
|
||||
rm -rf "$INSTALL_DIR/bin"
|
||||
cp -r "$REPO_DIR/bin/Release/net10.0/." "$INSTALL_DIR/"
|
||||
fi
|
||||
echo "Update abgeschlossen."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 1) .NET 10 pruefen
|
||||
if ! command -v dotnet >/dev/null 2>&1; then
|
||||
@@ -33,6 +66,7 @@ echo "Gefunden: dotnet $(dotnet --version 2>/dev/null || echo unbekannt)"
|
||||
# 2) Quelle beschaffen
|
||||
if [ "$INSTALL_MODE" = "clone" ]; then
|
||||
echo "== Clone-Modus: bereite $INSTALL_DIR vor =="
|
||||
mkdir -p "$(dirname "$INSTALL_DIR")"
|
||||
if [ -d "$INSTALL_DIR/.git" ]; then
|
||||
echo "Bereits ein Git-Repo — ueberspringe Clone (git pull ist beim Update noetig)."
|
||||
else
|
||||
@@ -70,13 +104,22 @@ fi
|
||||
echo "== Baue Release =="
|
||||
dotnet build "$BUILD_PROJECT" -c Release -v minimal
|
||||
|
||||
# 4) Symlink
|
||||
echo "== Verknuepfe $BIN_LINK -> $DLL =="
|
||||
# 4) Ausfuehrbare Wrapper-Datei (kein direkter Symlink auf die .dll —
|
||||
# eine .dll ist unter Linux nicht ausfuehrbar; der Wrapper ruft dotnet auf)
|
||||
mkdir -p "$BIN_DIR" 2>/dev/null || sudo mkdir -p "$BIN_DIR"
|
||||
echo "== Erzeuge Wrapper $BIN_LINK -> $DLL =="
|
||||
WRAPPER_CONTENT="#!/usr/bin/env bash
|
||||
exec dotnet \"$DLL\" \"\$@\"
|
||||
"
|
||||
if [ -w "$(dirname "$BIN_LINK")" ]; then
|
||||
ln -sf "$DLL" "$BIN_LINK"
|
||||
rm -f "$BIN_LINK"
|
||||
printf '%s' "$WRAPPER_CONTENT" > "$BIN_LINK"
|
||||
chmod +x "$BIN_LINK"
|
||||
else
|
||||
echo "Hinweis: $BIN_LINK benoetigt Schreibrechte; erstelle Link via sudo."
|
||||
sudo ln -sf "$DLL" "$BIN_LINK"
|
||||
echo "Hinweis: $BIN_LINK benoetigt Schreibrechte; erstelle via sudo."
|
||||
rm -f "$BIN_LINK" 2>/dev/null || sudo rm -f "$BIN_LINK"
|
||||
printf '%s' "$WRAPPER_CONTENT" | sudo tee "$BIN_LINK" >/dev/null
|
||||
sudo chmod +x "$BIN_LINK"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
@@ -85,4 +128,5 @@ echo "Beispiel-Seite erzeugen: webstatic init mysite && cd mysite && webstatic b
|
||||
echo "GCBoK bauen: webstatic build --root www --env development"
|
||||
echo "Umgebungsvariable (optional): WEBSTATIC_BUILDER=$DLL"
|
||||
echo ""
|
||||
echo "Update (Clone-Modus): cd $INSTALL_DIR && git stash && git pull && git stash pop && dotnet build -c Release"
|
||||
echo "Update (Clone-Modus, ohne sudo): webstatic update"
|
||||
echo " (alternativ: cd $INSTALL_DIR && git stash && git pull && git stash pop && dotnet build -c Release)"
|
||||
|
||||
Reference in New Issue
Block a user