Skip to content

Instantly share code, notes, and snippets.

@glaszig
Last active May 2, 2018 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glaszig/4d88bf5d7cea178cd8e5b9ecaeba2c20 to your computer and use it in GitHub Desktop.
Save glaszig/4d88bf5d7cea178cd8e5b9ecaeba2c20 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
set -e
HOME_DIR="/home/git"
WWW_DIR="/usr/local/www/gitweb"
REPOS_PATH="$HOME_DIR/repositories"
GITWEB_CONF="/etc/gitweb.conf"
GITWEB_PATH="/usr/local/share/examples/git/gitweb"
BANNER="# created by bootstrap script. manual changes might get lost."
# `latest` contains packages unable to run on older kernels if you're not current
sed -i"" -e '/url:/ s/latest/release_1/g' /usr/local/etc/pkg/repos/FreeBSD.conf
pkg install -y vim-lite lighttpd git gitolite
# get us a pretty gitweb theme
ARCHIVE_URL="https://github.com/kogakure/gitweb-theme/archive/master.tar.gz"
curl -sSL $ARCHIVE_URL | tar -C /tmp -xzf-
mkdir -p $WWW_DIR
cp -r $GITWEB_PATH/* $WWW_DIR
cp $HOME_DIR/gitweb-theme-master/gitweb.css $WWW_DIR/static/
cp $HOME_DIR/gitweb-theme-master/git-logo.png $WWW_DIR/static/
cp $HOME_DIR/gitweb-theme-master/git-favicon.png $WWW_DIR/static/
rm -rf /tmp/gitweb-theme-master
# create git user
pw user show git
if [ "65" == "$?" ]; then
pw user add -n git -m -d /home/git
fi
chown -R git:git $HOME_DIR
#
# config files
#
cat <<EOT > ~/.vimrc
set nocompatible
set backspace=2
set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab
EOT
cat <<EOT > /usr/local/etc/lighttpd/lighttpd.conf
$BANNER
var.www_root = "/usr/local/www"
var.log_root = "/var/log/lighttpd"
var.server_root = www_root + "/lighttpd"
var.state_dir = "/var/run"
var.home_dir = "/var/run/lighttpd"
var.conf_dir = "/usr/local/etc/lighttpd"
var.cache_dir = "/var/cache/lighttpd"
include "conf.d/mime.conf"
include "conf.d/compress.conf"
server.pid-file = state_dir + "/lighttpd.pid"
server.modules += ( "mod_alias", "mod_cgi", "mod_redirect", "mod_setenv" )
server.port = 80
server.document-root = www_root + "/data"
\$HTTP["url"] =~ "^/gitweb" {
alias.url += ( "/" => "${WWW_DIR}" )
setenv.add-environment = (
"GITWEB_CONFIG" => "${GITWEB_CONF}",
"PATH" => env.PATH
)
cgi.assign = ( ".cgi" => "" )
server.indexfiles = ( "gitweb.cgi" )
}
\$HTTP["url"] =~ "^/repos" {
alias.url += ( "/repos" => "/usr/local/libexec/git-core/git-http-backend" )
cgi.assign = ( "" => "" )
setenv.add-environment = (
"GIT_HTTP_EXPORT_ALL" => "true",
"GIT_PROJECT_ROOT" => "${REPOS_PATH}"
)
}
EOT
cat <<EOT > $GITWEB_CONF
$BANNER
\$projectroot = "${REPOS_PATH}";
\$projects_list = \$projectroot;
\$feature{'pickaxe'}{'default'} = [1];
\$feature{'snapshot'}{'default'} = ['zip', 'tgz'];
\$feature{'highlight'}{'default'} = [1];
\$feature{'pathinfo'}{'default'} = [1];
\$feature{'blame'}{'default'} = [1];
EOT
#
# configure services
#
sysrc sshd_enable=YES
ssh-keygen -A
service sshd restart
sysrc lighttpd_enable=YES
service lighttpd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment