Little Updater Script [LINUX] Open for Ideas


#1

Hello,

i have written for my own a little updater script for gogs. It works, if you have a 64 bit linux machine. You schould have installed curl and a user called git, who executete the gogs server. You schould have setup gogs as systemd service for automatic stop and restart.I am open for ideas or improvements, that was only the first draw i made. Testet on Ubuntu 16.04.

Best Regards
ModdyLP

echo "Stoping Gogs"
systemctl stop gogs
echo "Delete the old backup"
rm -rf gogs_old
rm -rf latest.zip
echo "Creating new backup"
mv gogs gogs_old
echo "Download latest version"
curl -s -L https://github.com/gogits/gogs/releases/latest | egrep -o '/gogits/gogs/releases/download/[v][0-9\.]*\/linux_amd64.zip' | wget --base=http://github.com/ -i - -O latest.zip
echo "Unzip Update"
unzip latest.zip
echo "Copy Config from Backup to Update"
cp -R gogs_old/custom gogs
cp -R gogs_old/data gogs
cp -R gogs_old/log gogs
echo "Fix Permission"
chown -R git:git /home/git
echo "Start Gogs"
systemctl start gogs

#2

You could try to put the relevant data into folders outside the gogs folder and follow some linux standards. logs to /var/log/gogs/, app.ini to /etc/gogs/, data to /var/lib/gogs/ and repositories to /var/lib/gogs/ or /srv/gogs/. Then you do not need to move and restore it; just unpack the new archive and restart with --config.


#3

I dont know, but that must be configured in the /custom/app.ini and this way is for all users which want to use the default settings. You are right, the Linux standarts are not possible with this but you could change you config and the script easily if you need it in another way. You can also post your idea und er this post :slight_smile: