Created
April 5, 2010 17:53
-
-
Save peritus/356654 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
. "$(git --exec-path)/git-sh-setup" | |
test -e `git --exec-path`/git-http-backend||die "git-http-backend does not exist, upgrade to git >= 1.6.6" | |
test -d $GIT_DIR/gitweb || die "$GIT_DIR/gitweb does not exist, try running 'git instaweb -d webrick'" | |
test -e $GIT_DIR/gitweb/webrick || die "$GIT_DIR/gitweb/webrick does not exist, try running 'git instaweb -d webrick'" | |
GIT_BIN=`git --exec-path`/git | |
CGI_NAME=`basename \`pwd\``.cgi | |
CGI_PATH=$GIT_DIR/gitweb/$CGI_NAME | |
install_http_backend_cgi () { | |
cat > $CGI_PATH << EOF | |
#!/bin/sh | |
export GIT_PROJECT_ROOT=$GIT_DIR | |
exec $GIT_BIN http-backend \$* | |
EOF | |
chmod +x $CGI_PATH | |
PORT=`cat $GIT_DIR/gitweb/httpd.conf|grep Port|awk -F' ' '{print $2}'` | |
GITWEB_URL_CONFIGURED=`git config --get gitweb.url` | |
GITWEB_URL_NEW=http://localhost:$PORT/$CGI_NAME | |
if [ -z "$GITWEB_URL_CONFIGURED" ]; then | |
git config gitweb.url $GITWEB_URL_NEW | |
GITWEB_URL_CONFIGURED=$GITWEB_URL_NEW | |
fi | |
} | |
install_http_backend_cgi | |
echo "Status:" | |
echo | |
# webrick | |
WEBRICK_RUNNING=0 | |
if [ -e $GIT_DIR/pid ]; then | |
PID=`cat $GIT_DIR/pid` | |
ps $PID >/dev/null && WEBRICK_RUNNING=1 | |
fi | |
echo -n "webrick: " | |
test $WEBRICK_RUNNING && echo -n "running" || echo -n "stopped" | |
if [ "0" == $WEBRICK_RUNNING ]; then | |
echo -e "\t(Start: git instaweb -d webrick --start)" | |
else | |
echo -e "\t(Stop: git instaweb -d webrick --stop)" | |
fi | |
# gitweb.url | |
if [ -z "$GITWEB_URL_CONFIGURED" ]; then | |
echo "gitweb.url: not set" | |
else | |
echo "gitweb.url: $GITWEB_URL_CONFIGURED" | |
fi | |
if [ "$GITWEB_URL_CONFIGURED" != "$GITWEB_URL_NEW" ]; then | |
echo -e "\t(Fix: git config gitweb.url $GITWEB_URL_NEW)" | |
fi | |
# git-daemon-export-ok | |
if [ -e "$GIT_DIR/git-daemon-export-ok" ]; then | |
echo "git-daemon-export-ok: exists (Remove: rm $GIT_DIR/git-daemon-export-ok)" | |
else | |
echo "git-daemon-export-ok: missing (Create: touch $GIT_DIR/git-daemon-export-ok)" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment