chore: implemented whole functionality since it's not too complex (linux)
This commit is contained in:
+98
-26
@@ -21,57 +21,129 @@ show_help(){
|
|||||||
|
|
||||||
install(){
|
install(){
|
||||||
printf "Fetching version...\n"
|
printf "Fetching version...\n"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GITEA_URL="${GITEA_URL:-https://git.mypapercloud.de}"
|
GITEA_URL="${GITEA_URL:-https://git.mypapercloud.de}"
|
||||||
OWNER="${OWNER:-fierke}"
|
OWNER="${OWNER:-fierke}"
|
||||||
REPO="${REPO:-logofclient}"
|
REPO="${REPO:-logofclient}"
|
||||||
|
|
||||||
|
|
||||||
API="${GITEA_URL%/}/api/v1"
|
API="${GITEA_URL%/}/api/v1"
|
||||||
|
|
||||||
release_json="$(
|
release_json="$(
|
||||||
curl --fail --silent --show-error --location \
|
curl --fail --silent --show-error --location \
|
||||||
"$API/repos/$OWNER/$REPO/releases/latest"
|
"$API/repos/$OWNER/$REPO/releases/latest"
|
||||||
)"
|
)"
|
||||||
|
|
||||||
tag="$(
|
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="logofclient-$tag-linux.tar.xz"
|
||||||
|
|
||||||
asset_url="$(
|
asset_url="$(
|
||||||
jq --exit-status --raw-output \
|
jq --exit-status --raw-output \
|
||||||
--arg asset "$ASSET" \
|
--arg asset "$ASSET" \
|
||||||
'.assets[]
|
'.assets[]
|
||||||
| select(.name == $asset)
|
| select(.name == $asset)
|
||||||
| .browser_download_url' \
|
| .browser_download_url' \
|
||||||
<<<"$release_json"
|
<<<"$release_json"
|
||||||
)"
|
)"
|
||||||
|
|
||||||
#printf 'Release tag: %s\n' "$tag"
|
|
||||||
printf 'Downloading package: %s\n' "$asset_url"
|
printf 'Downloading package: %s\n' "$asset_url"
|
||||||
|
|
||||||
curl --fail --location --retry 3 \
|
curl --fail --location --retry 3 \
|
||||||
"${AUTH[@]}" \
|
--output "$ASSET" \
|
||||||
--output "$ASSET" \
|
"$asset_url"
|
||||||
"$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(){
|
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
|
while getopts "yhv" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
v) exit 0 ;;
|
v) exit 0 ;;
|
||||||
@@ -91,13 +163,13 @@ fi
|
|||||||
|
|
||||||
if [[ "$1" == "update" ]]; then
|
if [[ "$1" == "update" ]]; then
|
||||||
|
|
||||||
# update
|
update
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$1" == "uninstall" ]]; then
|
if [[ "$1" == "uninstall" ]]; then
|
||||||
|
|
||||||
# uninstall
|
uninstall
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user