]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-instaweb.sh
Merge commit 'jc/maint' into gfi-maint
[thirdparty/git.git] / git-instaweb.sh
index 51067d9679938ae59b68499711a8394a450de396..cbc7418e3501b37a701a5177157733d97b405376 100755 (executable)
@@ -15,17 +15,17 @@ case "$GIT_DIR" in
        fqgitdir="$PWD/$GIT_DIR" ;;
 esac
 
-local="`git repo-config --bool --get instaweb.local`"
-httpd="`git repo-config --get instaweb.httpd`"
-browser="`git repo-config --get instaweb.browser`"
-port=`git repo-config --get instaweb.port`
-module_path="`git repo-config --get instaweb.modulepath`"
+local="`git config --bool --get instaweb.local`"
+httpd="`git config --get instaweb.httpd`"
+browser="`git config --get instaweb.browser`"
+port=`git config --get instaweb.port`
+module_path="`git config --get instaweb.modulepath`"
 
 conf=$GIT_DIR/gitweb/httpd.conf
 
 # Defaults:
 
-# if installed, it doens't need further configuration (module_path)
+# if installed, it doesn't need further configuration (module_path)
 test -z "$httpd" && httpd='lighttpd -f'
 
 # probably the most popular browser among gitweb users
@@ -53,6 +53,13 @@ start_httpd () {
                                return
                        fi
                done
+               echo "$httpd_only not found. Install $httpd_only or use" \
+                    "--httpd to specify another http daemon."
+               exit 1
+       fi
+       if test $? != 0; then
+               echo "Could not execute http daemon $httpd."
+               exit 1
        fi
 }
 
@@ -156,10 +163,20 @@ apache2_conf () {
        test "$local" = true && bind='127.0.0.1:'
        echo 'text/css css' > $fqgitdir/mime.types
        cat > "$conf" <<EOF
+ServerName "git-instaweb"
 ServerRoot "$fqgitdir/gitweb"
 DocumentRoot "$fqgitdir/gitweb"
 PidFile "$fqgitdir/pid"
 Listen $bind$port
+EOF
+
+       for mod in mime dir; do
+               if test -e $module_path/mod_${mod}.so; then
+                       echo "LoadModule ${mod}_module " \
+                            "$module_path/mod_${mod}.so" >> "$conf"
+               fi
+       done
+       cat >> "$conf" <<EOF
 TypesConfig $fqgitdir/mime.types
 DirectoryIndex gitweb.cgi
 EOF
@@ -183,8 +200,10 @@ PerlPassEnv GIT_EXEC_DIR
 EOF
        else
                # plain-old CGI
+               list_mods=`echo "$httpd" | sed "s/-f$/-l/"`
+               $list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \
+               echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
                cat >> "$conf" <<EOF
-LoadModule cgi_module $module_path/mod_cgi.so
 AddHandler cgi-script .cgi
 <Location /gitweb.cgi>
        Options +ExecCGI
@@ -194,9 +213,9 @@ EOF
 }
 
 script='
-s#^\(my\|our\) $projectroot =.*#\1 $projectroot = "'`dirname $fqgitdir`'";#;
-s#\(my\|our\) $gitbin =.*#\1 $gitbin = "'$GIT_EXEC_PATH'";#;
-s#\(my\|our\) $projects_list =.*#\1 $projects_list = $projectroot;#;
+s#^\(my\|our\) $projectroot =.*#\1 $projectroot = "'`dirname $fqgitdir`'";#
+s#\(my\|our\) $gitbin =.*#\1 $gitbin = "'$GIT_EXEC_PATH'";#
+s#\(my\|our\) $projects_list =.*#\1 $projects_list = $projectroot;#
 s#\(my\|our\) $git_temp =.*#\1 $git_temp = "'$fqgitdir/gitweb/tmp'";#'
 
 gitweb_cgi () {
@@ -232,4 +251,5 @@ esac
 
 start_httpd
 test -z "$browser" && browser=echo
-$browser http://127.0.0.1:$port
+url=http://127.0.0.1:$port
+$browser $url || echo $url