Bash script for auto upgrade gogs from binary and source (linux and OSX)


#1

Hey there, i wrote a simple bash script for auto upgrade the gogs binar and source

Here is the link

https://git.trueleet.com/zeta/gogs_upgrader

I actually tested it for x32 x64 and raspi2 from binary and it works pretty nice

the ARM recognition and the source upgrade are still in testing but feel free to help me with it!

The script support OSX too, thanks to @hollie for tests.


#2

Hey @zeta,

cool, thanks for sharing!

A suggestion: could you please add detection of OS X too?

The variable $OSTYPE equals ‘darwin15’ on my computer, and in that case the link to the binary for download is:

https://dl.gogs.io/gogs_v0.9.13_darwin_amd64.zip

Best regards,
Lieven.


#3

@hollie,
yes, is not a big deal but i can’t test because i dont’ use Apple Devices

EDIT:
control added


#4

@zeta, perfect, thanks. I’ll test it out later today an report back.


#5

Hello @zeta,

sorry it took some longer than expected to test this out. I’m afraid that your script is currently not working fine on OS X.

If I try it fresh from the repo, I get:

gogs_upgrader lieven$ ./upgrade.sh
./upgrade.sh: line 124: unexpected EOF while looking for matching‘’
./upgrade.sh: line 157: syntax error: unexpected end of file

If I comment out lines 123 - 124 then the script starts.

But then the detection of the remote version fails with:
You are trying to upgrade gogs as user lieven, is this your default gogs user?[Y/N] Y Checking remote version... head: illegal byte count -- -2 ./upgrade.sh: line 75: [: 0.9.13: unary operator expected Update Found! Local version: 0.9.13 Remote version: Select update source B=Binary, S=Source C=Close:

If there is anything I can help you with to debug this further then please let me know.

Regards,
Lieven.


#6

everything fixed, you can now use git pull to update the script


#7

Hey @zeta,

your update did fix the first error, thanks for that.
There still seems to be something wrong with retrieving the remote version:

You are trying to upgrade gogs as user lieven, is this your default gogs user?[Y/N]
Y
Checking remote version... head: illegal byte count -- -2 Update Found! Local version: 0.9.13 Remote version: Select update source B=Binary, S=Source C=Close:B downloading binary... --2016-04-09 18:26:45-- https://dl.gogs.io/gogs_v_darwin_amd64.zip Resolving dl.gogs.io... 159.203.18.145 Connecting to dl.gogs.io|159.203.18.145|:443... connected. HTTP request sent, awaiting response... 404 Not Found 2016-04-09 18:26:46 ERROR 404: Not Found.

create a backup of the old gogs directory extracting archive... unzip: cannot find or open /Users/lieven/Desktop/git/gogs_v_darwin_amd64.zip, /Users/lieven/Desktop/git/gogs_v_darwin_amd64.zip.zip or /Users/lieven/Desktop/git/gogs_v_darwin_amd64.zip.ZIP. deleting archive copying custom copying data Unable to find log directory cat: /Users/lieven/Desktop/git/gogs/templates/.VERSION: No such file or directory Done! upgrade successful!


#8

Hi @hollie, i think the problem is the way head works, on linux i’v no problem so i think is an osx problem.
I already fixed it replacing head with sed .You can find the new version on the repository


#9

Hey @zeta,

I’ve tried the latest version, it works as expected now, so you can add ‘tested on OS X’ label to the script too :slight_smile:

Thanks for fixing it!

Lieven.


#10

Hey,

I’m curious if someone got the latest version of the script/repo somewhere because the link is not available anymore.

Cheers