Files
logofclient-installer/logofclientctl.sh
T

105 lines
2.0 KiB
Bash
Executable File

#!/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 $tag...\n"
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 'Release tag: %s\n' "$tag"
printf 'Downloading package: %s\n' "$asset_url"
curl --fail --location --retry 3 \
"${AUTH[@]}" \
--output "$ASSET" \
"$asset_url"
#printf 'Gespeichert als: %s\n' "$ASSET"
}
update(){
echo "updating logofclient"
}
uninstall(){
echo "removing logofclient from your system"
}
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