chore: implemented whole functionality since it's not too complex (linux)

This commit is contained in:
2026-09-01 18:42:02 +02:00
parent e9087d8fab
commit 618b2b9483
+98 -26
View File
@@ -21,57 +21,129 @@ show_help(){
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"
curl --fail --silent --show-error --location \
"$API/repos/$OWNER/$REPO/releases/latest"
)"
tag="$(
jq --exit-status --raw-output '.tag_name' <<<"$release_json"
jq --exit-status --raw-output '.tag_name' <<<"$release_json"
)"
printf "Installing logofclient $tag...\n"
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"
jq --exit-status --raw-output \
--arg asset "$ASSET" \
'.assets[]
| select(.name == $asset)
| .browser_download_url' \
<<<"$release_json"
)"
#printf 'Release tag: %s\n' "$tag"
printf 'Downloading package: %s\n' "$asset_url"
curl --fail --location --retry 3 \
"${AUTH[@]}" \
--output "$ASSET" \
"$asset_url"
--output "$ASSET" \
"$asset_url"
#printf 'Gespeichert als: %s\n' "$ASSET"
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"
}
update(){
echo "updating logofclient"
}
uninstall(){
echo "removing logofclient from your system"
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 ;;
@@ -91,13 +163,13 @@ fi
if [[ "$1" == "update" ]]; then
# update
update
exit 0
fi
if [[ "$1" == "uninstall" ]]; then
# uninstall
uninstall
exit 0
fi