From fa6c3b8bb2201cad25b96abf3fa524e34df452ef Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 15 Dec 2018 19:43:29 +0100 Subject: [PATCH] document update script --- README.md | 20 +++++++++++++++++++- bin/update-gitea.sh | 32 +++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c71bda2..1701af6 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ > Gitea installation notes [git.berlin](https://git.berlin) - [Migration from GitLab](#migration-from-gitlab) +- [Update Gitea](#update-gitea) - [Customization](#customization) - [Handy commands](#handy-commands) - [Gitea Documentation](#gitea-documentation) @@ -13,7 +14,24 @@ ## Migration from GitLab -- [`migrate-gitlab-gitea.sh`](migrate-gitlab-gitea.sh) +- [`bin/migrate-gitlab-gitea.sh`](bin/migrate-gitlab-gitea.sh) + +## Update Gitea + +- [`bin/update-gitea.sh`](bin/update-gitea.sh) + +Update script sets options by default, can be changed at top of script: + +- `giteaBinary`: Gitea binary under `/home/git/gitea/gitea` +- `arch`: architecture is `linux-amd64` +- `giteaUpdateStorage`: downloaded files will be stored in `/home/git/gitea-update` +- `giteaUser`: linux user Gitea is running under, `git` +- `giteaGroup`: linux group Gitea is running under, `git` + +```bash +# run update script with sudo, passing version number as option +sudo ./bin/update-gitea.sh 1.6.1 +``` ## Customization diff --git a/bin/update-gitea.sh b/bin/update-gitea.sh index d5fc23d..a49bbdc 100755 --- a/bin/update-gitea.sh +++ b/bin/update-gitea.sh @@ -1,12 +1,7 @@ #!/bin/sh # -# usage, run as user git: -# -# sudo service gitea stop -# ./update-gitea.sh 1.6.1 -# sudo service gitea start -# -# su -c "./update-gitea.sh 1.6.1" -s /bin/sh git +# usage, run with sudo: +# sudo ./update-gitea.sh 1.6.1 # set -e @@ -14,10 +9,29 @@ set -e version=$1 arch="linux-amd64" giteaBinary="/home/git/gitea/gitea" +giteaUpdateStorage="/home/git/gitea-update" +giteaUser="git" +giteaGroup="git" -cd /home/git/gitea-update +# stop Gitea +sudo service gitea stop +echo "Stopped Gitea." + +# download new binary +cd $giteaUpdateStorage +echo "Downloading gitea-${version}-${arch}..." wget -O "gitea-${version}-${arch}" "https://dl.gitea.io/gitea/${version}/gitea-${version}-${arch}" +# copy new binary over old one cp "gitea-${version}-${arch}" $giteaBinary -chmod +x $giteaBinary \ No newline at end of file +echo "Updated Gitea binary v${version}." + +# set permissions +chown $giteaUser:$giteaGroup $giteaBinary +chmod +x $giteaBinary +echo "Set permissions." + +# start Gitea +sudo service gitea start +echo "Restarted Gitea. Update done."