Skip to content

Upgrade gitea via bash on an uberspace webspace

I've just finished writing a little bash script to almost automatically upgrade my gitea instance on my uberspace webspace.

Hope it will help you.

    cat > "${HOME}/upgrade_gitea.sh" <<DELIM
#!/bin/bash
####
# @see: https://lab.uberspace.de/guide_gitea/
# @since: 2022-05-16
# @author: stev leibelt <artodeto@bazzline.net>
####

function _do_the_update () {
    local PATH_TO_GITEA="${HOME}/gitea/gitea"

    if [[ -f "\${PATH_TO_GITEA}" ]];
    then
        echo ":: Stopping all running gitea process."

        killall gitea

        echo ":: Moving >>\${PATH_TO_GITEA}<< to >>\${PATH_TO_GITEA}.previous<<"

        mv "\${PATH_TO_GITEA}" "\${PATH_TO_GITEA}.previous"
    fi

    echo ":: Please visit >>https://github.com/go-gitea/gitea/releases/tag/latest<<."
    echo ""

    echo ":: Please insert latest Version number without the v."
    read LATEST_GITEAVERSION

    wget -O "\${PATH_TO_GITEA}" https://github.com/go-gitea/gitea/releases/download/v\${LATEST_GITEAVERSION}/gitea-\${LATEST_GITEAVERSION}-linux-amd64

    if [[ -f "\${PATH_TO_GITEA}" ]];
    then
        wget --output-document "\${PATH_TO_GITEA}.asc" https://github.com/go-gitea/gitea/releases/download/v\${LATEST_GITEAVERSION}/gitea-\${LATEST_GITEAVERSION}-linux-amd64.asc

        curl --silent https://keys.openpgp.org/vks/v1/by-fingerprint/7C9E68152594688862D62AF62D9AE806EC1592E2 | gpg --import

        gpg --verify "\${PATH_TO_GITEA}.asc" "\${PATH_TO_GITEA}"

        chmod u+x "\${PATH_TO_GITEA}"

        echo ":: Starting migration"

        \${PATH_TO_GITEA} migrate

        echo ":: Starting gitea"

        \${PATH_TO_GITEA} web
    else
        echo ":: Something went wrong."

        if [[ -f "\${PATH_TO_GITEA}.previous" ]];
        then
            echo ":: Restoring previous gitea."

            mv "\${PATH_TO_GITEA}.previous" \"${PATH_TO_GITEA}"

            echo ":: Starting gitea"

            \${PATH_TO_GITEA} web
        fi
    fi
}

_do_the_update
DELIM

    chmod +x ${HOME}/upgrade_gitea.sh

Best regards, artodeto.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

The author does not allow comments to this entry

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Markdown format allowed
Form options