# Nextcloud update via script

**URL:** <https://help.nextcloud.com/t/nextcloud-update-via-script/186525>\
**Category:** ℹ️ Support\
**Tags:** nc27\
**Created:** [March 27, 2024, 10:26pm UTC](https://help.nextcloud.com/t/nextcloud-update-via-script/186525 "2024-03-27T22:26:08Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ernolf](https://help.nextcloud.com/user_avatar/help.nextcloud.com/ernolf/32/77874_2.png) [@ernolf](https://help.nextcloud.com/u/ernolf)\
**Post date:** [March 29, 2024, 6:27pm UTC](https://help.nextcloud.com/t/nextcloud-update-via-script/186525/5 "2024-03-29T18:27:03Z")

</div>

> [@tony.blue](#):
>
> Does anyone have an idea how I could do this as a bash script?

I use the github api to access existing server versions and tags in a bash script.

Here is a function like I use it in [→ nc-apps ←](https://help.nextcloud.com/t/script-nc-apps-a-helpful-and-more-verbose-complement-to-occ-app-list/164389), for example:

```sh
github_api(){
    local URL="https://api.github.com/repos/$1/$2?per_page=$3"
    case $2 in
          tags) curl -s "$URL" | jq -r '.[] | .name' | sed 's/^v//' | grep "^[0-9]\{1,2\}\.[0-9]\.[0-9]" | grep -iv a
                ;;
      releases) curl -s "$URL" | jq -r '.[] | .tag_name' | sed 's/^v//' | grep "^[0-9]\{1,2\}\.[0-9]\.[0-9]" | grep -iv a
    esac
}

```

Here is a sample output:

```sh
root@box:~# github_api "nextcloud/server" "releases" "10"
29.0.0rc1
28.0.4
27.1.8
26.0.13

```

These results can now be easily parsed for patterns. You don’t even need any knowledge of regular expressions, as this version can be divided into numbers.  
I can explain all of this to you, but I feel a little strange because it’s explaining a language and doesn’t really belong here.

* * *

But I don’t want to leave you out in the cold like that. Therefore, here is a hand-picked series of sources from which you can familiarize yourself with all the techniques of bash and shell scripting.

1. **Bash Documentation:** The official Bash documentation is an excellent source for detailed information on Bash commands, syntax, and functions. It’s available at [GNU Bash manual - GNU Project - Free Software Foundation](https://www.gnu.org/software/bash/manual/).
2. **Bash Guide at TLDP:** The Bash Guide on The Linux Documentation Project (TLDP) provides a comprehensive introduction to Bash programming along with many practical examples. You can access it at [http://tldp.org/LDP/abs/html/](http://tldp.org/LDP/abs/html/).
3. **Bash Academy:** An interactive online platform offering free courses on Bash programming. It provides a blend of lessons and hands-on exercises. Visit [https://guide.bash.academy/](https://guide.bash.academy/).
4. **Shell Programming at Wikibooks:** The Shell Programming book at Wikibooks offers a solid introduction to shell scripting with plenty of examples and explanations. You can read it at [https://en.wikibooks.org/wiki/Bash\_Scripting](https://en.wikibooks.org/wiki/Bash_Scripting).
5. **Bash Scripting Cheat Sheet at Devhints:** Devhints offers a handy Bash scripting cheat sheet containing quick references to commonly used commands and syntax. You can find it at [Bash scripting cheatsheet](https://devhints.io/bash).
6. **Bash Scripting Tutorial at ShellCheck:** ShellCheck provides a tutorial on Bash scripting along with a handy shell script analysis tool to improve script quality. Access it at [https://www.shellcheck.net/](https://www.shellcheck.net/).
7. **Bash Scripting Guide at Ryanstutorials:** Ryanstutorials offers a comprehensive guide to Bash scripting with step-by-step explanations and practical examples. Explore it at [Bash Scripting Tutorial - Ryans Tutorials](https://ryanstutorials.net/bash-scripting-tutorial/).

* * *

and last but not least, the source of most of my knowledge, the man pages:

```sh
apropos . | xargs -n 1 man

```

* * *

Much and good luck,  
ernolf

---

_[View the full topic](https://help.nextcloud.com/t/nextcloud-update-via-script/186525)._
