moved old scriptfiles
This commit is contained in:
Executable
+176
@@ -0,0 +1,176 @@
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
echo "Welcome to logofclient!"
|
||||
echo "(c)2026 - MyPapertown, MyPaperCloud, Elias Fierke"
|
||||
echo "Version 1.0"
|
||||
echo ""
|
||||
|
||||
show_help(){
|
||||
echo "-- HELP --"
|
||||
echo " -v | Print the current application version"
|
||||
echo " -h | Show this help text"
|
||||
echo " -y | Answer all questions with yes"
|
||||
echo ""
|
||||
echo "-- COMMANDS --"
|
||||
echo " install | install logofclient to your linux-system"
|
||||
echo " update | update the logofclient to the newest version"
|
||||
echo " uninstall | remove logofclient from your system"
|
||||
exit 0
|
||||
}
|
||||
|
||||
install(){
|
||||
printf "Fetching version...\n"
|
||||
|
||||
GITEA_URL="${GITEA_URL:-https://git.mypapercloud.de}"
|
||||
OWNER="${OWNER:-fierke}"
|
||||
REPO="${REPO:-logofclient}"
|
||||
|
||||
API="${GITEA_URL%/}/api/v1"
|
||||
|
||||
release_json="$(
|
||||
curl --fail --silent --show-error --location \
|
||||
"$API/repos/$OWNER/$REPO/releases/latest"
|
||||
)"
|
||||
|
||||
tag="$(
|
||||
jq --exit-status --raw-output '.tag_name' <<<"$release_json"
|
||||
)"
|
||||
|
||||
printf "Installing logofclient %s...\n" "$tag"
|
||||
|
||||
ASSET="logofclient-$tag-linux.tar.xz"
|
||||
|
||||
asset_url="$(
|
||||
jq --exit-status --raw-output \
|
||||
--arg asset "$ASSET" \
|
||||
'.assets[]
|
||||
| select(.name == $asset)
|
||||
| .browser_download_url' \
|
||||
<<<"$release_json"
|
||||
)"
|
||||
|
||||
printf 'Downloading package: %s\n' "$asset_url"
|
||||
|
||||
curl --fail --location --retry 3 \
|
||||
--output "$ASSET" \
|
||||
"$asset_url"
|
||||
|
||||
INSTALL_DIR="/opt/logofclient"
|
||||
|
||||
printf 'Installing to: %s\n' "$INSTALL_DIR"
|
||||
|
||||
sudo rm -rf "$INSTALL_DIR"
|
||||
sudo mkdir -p "$INSTALL_DIR"
|
||||
|
||||
sudo tar -xf "$ASSET" -C "$INSTALL_DIR"
|
||||
echo "$tag" | sudo tee "$INSTALL_DIR/.version" > /dev/null
|
||||
|
||||
sudo ln -sf "$INSTALL_DIR/Logof Client" "/usr/local/bin/logofclient"
|
||||
|
||||
sudo tee /usr/share/applications/logofclient.desktop > /dev/null <<EOF
|
||||
[Desktop Entry]
|
||||
Name=logofclient
|
||||
Comment=logoclient
|
||||
Exec=/usr/local/bin/logofclient
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Icon=/opt/logofclient/assets/icon.png
|
||||
Categories=Office;
|
||||
EOF
|
||||
|
||||
rm -f "$ASSET"
|
||||
|
||||
printf 'Installed logofclient %s successfully.\n' "$tag"
|
||||
}
|
||||
|
||||
|
||||
uninstall(){
|
||||
INSTALL_DIR="/opt/logofclient"
|
||||
DESKTOP_FILE="/usr/share/applications/logofclient.desktop"
|
||||
BINARY_LINK="/usr/local/bin/logofclient"
|
||||
|
||||
printf "Uninstalling logofclient...\n"
|
||||
|
||||
sudo rm -rf "$INSTALL_DIR"
|
||||
sudo rm -f "$BINARY_LINK"
|
||||
sudo rm -f "$DESKTOP_FILE"
|
||||
|
||||
printf "logofclient has been uninstalled.\n"
|
||||
}
|
||||
|
||||
|
||||
update(){
|
||||
printf "Checking for updates...\n"
|
||||
|
||||
GITEA_URL="${GITEA_URL:-https://git.mypapercloud.de}"
|
||||
OWNER="${OWNER:-fierke}"
|
||||
REPO="${REPO:-logofclient}"
|
||||
|
||||
API="${GITEA_URL%/}/api/v1"
|
||||
INSTALL_DIR="/opt/logofclient"
|
||||
|
||||
if [[ -f "$INSTALL_DIR/.version" ]]; then
|
||||
installed_tag="$(cat "$INSTALL_DIR/.version")"
|
||||
else
|
||||
installed_tag=""
|
||||
fi
|
||||
|
||||
release_json="$(
|
||||
curl --fail --silent --show-error --location \
|
||||
"$API/repos/$OWNER/$REPO/releases/latest"
|
||||
)"
|
||||
|
||||
latest_tag="$(
|
||||
jq --exit-status --raw-output '.tag_name' <<<"$release_json"
|
||||
)"
|
||||
|
||||
printf "Installed version: %s\n" "${installed_tag:-none}"
|
||||
printf "Latest version: %s\n" "$latest_tag"
|
||||
|
||||
if [[ "$installed_tag" == "$latest_tag" ]]; then
|
||||
printf "Already up to date.\n"
|
||||
return 0
|
||||
fi
|
||||
|
||||
printf "Updating logofclient: %s -> %s\n" \
|
||||
"${installed_tag:-none}" "$latest_tag"
|
||||
|
||||
if [[ -n "$installed_tag" ]]; then
|
||||
uninstall
|
||||
fi
|
||||
|
||||
install
|
||||
}
|
||||
|
||||
|
||||
while getopts "yhv" opt; do
|
||||
case $opt in
|
||||
v) exit 0 ;;
|
||||
h) show_help ;;
|
||||
y) ALWAYS_YES="1" ;;
|
||||
\?) echo "Unknown option: -$OPTARG" >&2; exit 1 ;;
|
||||
:) echo "Option -$OPTARG needs an argument" >&2; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "$1" == "install" ]]; then
|
||||
|
||||
install
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$1" == "update" ]]; then
|
||||
|
||||
update
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$1" == "uninstall" ]]; then
|
||||
|
||||
uninstall
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
@@ -0,0 +1,378 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Write-Host "Welcome to logofclient!"
|
||||
Write-Host "(c)2026 - MyPapertown, MyPaperCloud, Elias Fierke"
|
||||
Write-Host "Version 1.0"
|
||||
Write-Host ""
|
||||
Write-Host "Note: Windows (Un)Installer has been implemented with AI and is untested. Please report to fierke@mypapertown.de"
|
||||
Write-Host ""
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Configuration
|
||||
# ------------------------------------------------------------
|
||||
|
||||
$GiteaUrl = if ($env:GITEA_URL) { $env:GITEA_URL } else { "https://git.mypapercloud.de" }
|
||||
$Owner = if ($env:OWNER) { $env:OWNER } else { "fierke" }
|
||||
$Repo = if ($env:REPO) { $env:REPO } else { "logofclient" }
|
||||
|
||||
$InstallDir = Join-Path $env:ProgramFiles "logofclient"
|
||||
$VersionFile = Join-Path $InstallDir ".version"
|
||||
|
||||
$StartMenuDir = Join-Path `
|
||||
$env:ProgramData `
|
||||
"Microsoft\Windows\Start Menu\Programs"
|
||||
|
||||
$ShortcutPath = Join-Path `
|
||||
$StartMenuDir `
|
||||
"logofclient.lnk"
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Administrator privileges
|
||||
# ------------------------------------------------------------
|
||||
|
||||
function Test-IsAdministrator {
|
||||
$Identity = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$Principal = New-Object Security.Principal.WindowsPrincipal($Identity)
|
||||
|
||||
return $Principal.IsInRole(
|
||||
[Security.Principal.WindowsBuiltInRole]::Administrator
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
function Ensure-Administrator {
|
||||
if (Test-IsAdministrator) {
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "Administrator privileges are required."
|
||||
Write-Host "Requesting elevation..."
|
||||
|
||||
# Reconstruct the original arguments
|
||||
$ArgumentList = @(
|
||||
"-NoProfile"
|
||||
"-ExecutionPolicy"
|
||||
"Bypass"
|
||||
"-File"
|
||||
"`"$PSCommandPath`""
|
||||
)
|
||||
|
||||
foreach ($Arg in $args) {
|
||||
$ArgumentList += "`"$Arg`""
|
||||
}
|
||||
|
||||
Start-Process `
|
||||
-FilePath "powershell.exe" `
|
||||
-ArgumentList $ArgumentList `
|
||||
-Verb RunAs
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Help
|
||||
# ------------------------------------------------------------
|
||||
|
||||
function Show-Help {
|
||||
Write-Host "-- HELP --"
|
||||
Write-Host " -v | Print the current application version"
|
||||
Write-Host " -h | Show this help text"
|
||||
Write-Host " -y | Answer all questions with yes"
|
||||
Write-Host ""
|
||||
Write-Host "-- COMMANDS --"
|
||||
Write-Host " install | install logofclient to your Windows-system"
|
||||
Write-Host " update | update logofclient to the newest version"
|
||||
Write-Host " uninstall | remove logofclient from your system"
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Gitea
|
||||
# ------------------------------------------------------------
|
||||
|
||||
function Get-LatestRelease {
|
||||
$Api = "$($GiteaUrl.TrimEnd('/'))/api/v1"
|
||||
|
||||
Write-Host "Fetching version..."
|
||||
|
||||
return Invoke-RestMethod `
|
||||
-Uri "$Api/repos/$Owner/$Repo/releases/latest" `
|
||||
-Method Get
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Install
|
||||
# ------------------------------------------------------------
|
||||
|
||||
function Install {
|
||||
Ensure-Administrator
|
||||
|
||||
$Release = Get-LatestRelease
|
||||
$Tag = $Release.tag_name
|
||||
|
||||
Write-Host "Installing logofclient $Tag..."
|
||||
|
||||
$AssetName = "logofclient-$Tag-win.zip"
|
||||
|
||||
$Asset = $Release.assets |
|
||||
Where-Object { $_.name -eq $AssetName } |
|
||||
Select-Object -First 1
|
||||
|
||||
if (-not $Asset) {
|
||||
throw "Could not find release asset '$AssetName'."
|
||||
}
|
||||
|
||||
$AssetUrl = $Asset.browser_download_url
|
||||
|
||||
Write-Host "Downloading package: $AssetUrl"
|
||||
|
||||
$TempDir = Join-Path `
|
||||
$env:TEMP `
|
||||
"logofclient-install"
|
||||
|
||||
$Archive = Join-Path `
|
||||
$TempDir `
|
||||
$AssetName
|
||||
|
||||
if (Test-Path $TempDir) {
|
||||
Remove-Item `
|
||||
$TempDir `
|
||||
-Recurse `
|
||||
-Force
|
||||
}
|
||||
|
||||
New-Item `
|
||||
-ItemType Directory `
|
||||
-Path $TempDir | Out-Null
|
||||
|
||||
Invoke-WebRequest `
|
||||
-Uri $AssetUrl `
|
||||
-OutFile $Archive
|
||||
|
||||
Write-Host "Installing to: $InstallDir"
|
||||
|
||||
# Remove previous installation
|
||||
if (Test-Path $InstallDir) {
|
||||
Remove-Item `
|
||||
$InstallDir `
|
||||
-Recurse `
|
||||
-Force
|
||||
}
|
||||
|
||||
New-Item `
|
||||
-ItemType Directory `
|
||||
-Path $InstallDir | Out-Null
|
||||
|
||||
# Extract ZIP
|
||||
Expand-Archive `
|
||||
-Path $Archive `
|
||||
-DestinationPath $InstallDir `
|
||||
-Force
|
||||
|
||||
# Save installed version
|
||||
Set-Content `
|
||||
-Path $VersionFile `
|
||||
-Value $Tag `
|
||||
-Encoding UTF8
|
||||
|
||||
# Find executable
|
||||
$Executable = Join-Path `
|
||||
$InstallDir `
|
||||
"Logof Client.exe"
|
||||
|
||||
if (-not (Test-Path $Executable)) {
|
||||
throw "Executable '$Executable' was not found after installation."
|
||||
}
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Start Menu shortcut
|
||||
# --------------------------------------------------------
|
||||
|
||||
Write-Host "Creating Start Menu shortcut..."
|
||||
|
||||
New-Item `
|
||||
-ItemType Directory `
|
||||
-Path $StartMenuDir `
|
||||
-Force | Out-Null
|
||||
|
||||
$Shell = New-Object -ComObject WScript.Shell
|
||||
|
||||
$Shortcut = $Shell.CreateShortcut($ShortcutPath)
|
||||
|
||||
$Shortcut.TargetPath = $Executable
|
||||
$Shortcut.WorkingDirectory = $InstallDir
|
||||
$Shortcut.Description = "logofclient"
|
||||
|
||||
$IconPath = Join-Path `
|
||||
$InstallDir `
|
||||
"assets\icon.ico"
|
||||
|
||||
if (Test-Path $IconPath) {
|
||||
$Shortcut.IconLocation = $IconPath
|
||||
}
|
||||
|
||||
$Shortcut.Save()
|
||||
|
||||
# Clean up downloaded archive
|
||||
Remove-Item `
|
||||
$TempDir `
|
||||
-Recurse `
|
||||
-Force
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Installed logofclient $Tag successfully."
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Uninstall
|
||||
# ------------------------------------------------------------
|
||||
|
||||
function Uninstall {
|
||||
Ensure-Administrator
|
||||
|
||||
Write-Host "Uninstalling logofclient..."
|
||||
|
||||
if (Test-Path $InstallDir) {
|
||||
Remove-Item `
|
||||
$InstallDir `
|
||||
-Recurse `
|
||||
-Force
|
||||
}
|
||||
|
||||
if (Test-Path $ShortcutPath) {
|
||||
Remove-Item `
|
||||
$ShortcutPath `
|
||||
-Force
|
||||
}
|
||||
|
||||
Write-Host "logofclient has been uninstalled."
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Update
|
||||
# ------------------------------------------------------------
|
||||
|
||||
function Update {
|
||||
Ensure-Administrator
|
||||
|
||||
Write-Host "Checking for updates..."
|
||||
|
||||
$InstalledTag = ""
|
||||
|
||||
if (Test-Path $VersionFile) {
|
||||
$InstalledTag = (
|
||||
Get-Content `
|
||||
$VersionFile `
|
||||
-Raw
|
||||
).Trim()
|
||||
}
|
||||
|
||||
$Release = Get-LatestRelease
|
||||
$LatestTag = $Release.tag_name
|
||||
|
||||
Write-Host "Installed version: $InstalledTag"
|
||||
Write-Host "Latest version: $LatestTag"
|
||||
|
||||
if ($InstalledTag -eq $LatestTag) {
|
||||
Write-Host "Already up to date."
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Updating logofclient: $InstalledTag -> $LatestTag"
|
||||
|
||||
if ($InstalledTag) {
|
||||
Uninstall
|
||||
}
|
||||
|
||||
Install
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Argument parsing
|
||||
# ------------------------------------------------------------
|
||||
|
||||
$AlwaysYes = $false
|
||||
$Command = $null
|
||||
|
||||
foreach ($Arg in $args) {
|
||||
switch ($Arg) {
|
||||
|
||||
"-y" {
|
||||
$AlwaysYes = $true
|
||||
}
|
||||
|
||||
"-h" {
|
||||
Show-Help
|
||||
exit 0
|
||||
}
|
||||
|
||||
"--help" {
|
||||
Show-Help
|
||||
exit 0
|
||||
}
|
||||
|
||||
"-v" {
|
||||
Write-Host "Version 1.0"
|
||||
exit 0
|
||||
}
|
||||
|
||||
"install" {
|
||||
$Command = "install"
|
||||
}
|
||||
|
||||
"update" {
|
||||
$Command = "update"
|
||||
}
|
||||
|
||||
"uninstall" {
|
||||
$Command = "uninstall"
|
||||
}
|
||||
|
||||
default {
|
||||
if ($Arg.StartsWith("-")) {
|
||||
Write-Error "Unknown option: $Arg"
|
||||
}
|
||||
else {
|
||||
Write-Error "Unknown command: $Arg"
|
||||
}
|
||||
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (-not $Command) {
|
||||
Show-Help
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Execute command
|
||||
# ------------------------------------------------------------
|
||||
|
||||
switch ($Command) {
|
||||
|
||||
"install" {
|
||||
Install
|
||||
}
|
||||
|
||||
"update" {
|
||||
Update
|
||||
}
|
||||
|
||||
"uninstall" {
|
||||
Uninstall
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user