|
#!/bin/bash |
|
# |
|
# This is a custom script for updating my install of gogs |
|
# |
|
# **This script is *not* officially endorsed by *anyone*** |
|
# |
|
# Use this script at our own risk, etc, etc |
|
# |
|
# --- |
|
# |
|
# My install may differ significantly from your own, so here are some points of note: |
|
# |
|
# - system user "git" exists solely to run gogs |
|
# |
|
# - all dependencies for gogs are installed in user git's $GOPATH |
|
# |
|
# - the *only* packages in user git's $GOPATH are for gogs |
|
# |
|
# - $GOPATH == /home/git/gocode |
|
# |
|
# - using the init script which with this directory scheme would be found at: |
|
# /home/git/gocode/src/github.com/gogits/gogs/scripts/init/debian/gogs |
|
# |
|
# - that script is just in /etc/init.d/ |
|
# |
|
# - notably however I have modified it to run the built "gogs" executable from |
|
# /home/git/gocode/src/github.com/gogits/gogs/gogs |
|
# |
|
# - because I am bad with computers |
|
# |
|
# - this will update everything to be even with origin/master, without exception |
|
# |
|
# --- |
|
# |
|
# Again, use at your own risk, but it might be an approach worth copying for |
|
# deploying go applications with tons of dependencies and keeping them updated |
|
# |
|
# ~ tso Mon 07 Dec 2015 11:25:18 AM EST |
|
|
|
trap "echo we get signal; exit" SIGINT |
|
trap "echo wow rude; exit" SIGTERM SIGKILL |
|
|
|
if [[ $(whoami) != "root" ]]; then |
|
echo "you should be root to run this, but let's see what happens..." |
|
fi |
|
|
|
prev_gopath=$GOPATH |
|
|
|
export GOPATH=/home/git/gocode |
|
|
|
for x in $(seq 2 10); do |
|
deeper="printf '*/%.0s' {1.."$x"}" |
|
for d2 in $(eval $deeper); do |
|
if [ -d $d2.git ]; then |
|
if [[ $d2 != "github.com/gogits/gogs/" ]]; then |
|
|
|
cd $d2 |
|
pkg=`pwd` |
|
echo "cd "$pkg |
|
echo "go get -u "${pkg##$GOPATH/src/} |
|
go get -u ${pkg##$GOPATH/src/} |
|
if [[ $? = 0 ]]; then |
|
echo -ne "[ \033[1;32mOK\033[0m ]\n" |
|
else |
|
echo "Trying subdirectories..." |
|
for subdir in $(ls -d */); do |
|
echo "go get -u "${pkg##$GOPATH/src/}/$subdir |
|
go get -u ${pkg##$GOPATH/src/}/$subdir |
|
if [[ $? = 0 ]]; then |
|
echo -ne "[ \033[1;32mOK\033[0m ]\n" |
|
else |
|
echo -ne "[ \033[1;33m:(\033[0m ]\n" |
|
fi |
|
done |
|
fi |
|
cd - 2>&1 > /dev/null |
|
fi |
|
fi |
|
done |
|
done |
|
|
|
trap "echo" SIGINT |
|
|
|
service gogs stop |
|
|
|
echo "cd `pwd`" |
|
cd $GOPATH/src/github.com/gogits/gogs |
|
|
|
echo "git pull" |
|
git pull |
|
|
|
echo "go build" |
|
go build |
|
if [[ $? = 0 ]]; then |
|
echo -ne "[ \033[1;32mOK\033[0m ]\n" |
|
else |
|
echo -ne "[ \033[1;31m:(\033[0m ]\n" |
|
exit 1 |
|
fi |
|
|
|
echo "test run, hit CTRL+C to finish" |
|
sudo -u git ./gogs web |
|
|
|
service gogs start |
|
|
|
export GOPATH=$prev_gopath |