dotfiles

Settings and scripts
git clone git://git.konyahin.xyz/dotfiles
Log | Files | Refs | Submodules | LICENSE

git_setup.sh (1606B)


      1 #!/usr/bin/env sh
      2 
      3 set -e
      4 
      5 pkg_add git stagit
      6 
      7 user add -m git
      8 cd /home/git
      9 su git <<ENDGIT
     10 
     11 mkdir -p .ssh && chmod 700 .ssh
     12 touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
     13 
     14 cat > ~/.ssh/authorized_keys << "END"
     15 no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILcXnswpV545z89oFFWY0YuoAIFDShZ7+OdfFTWYCbtL me@konyahin.xyz
     16 END
     17 ENDGIT
     18 
     19 chsh -s /usr/local/bin/git-shell git
     20 
     21 cat >> /etc/httpd.conf << "END"
     22 
     23 server "git.konyahin.xyz" {
     24   listen on * tls port 443
     25   root "/htdocs/git"
     26   tls {
     27     certificate "/etc/ssl/konyahin.xyz.fullchain.pem"
     28     key "/etc/ssl/private/konyahin.xyz.key"
     29   }
     30 
     31   location "./well-known/acme-challenge/*" {
     32     root "/acme"
     33     request strip 2
     34   }
     35 
     36   location "*/style.css" {
     37     request rewrite "/style.css"
     38   }
     39 
     40   location "*/logo.png" {
     41     request rewrite "/logo.png"
     42   }
     43 
     44   location "*/favicon.png" {
     45     request rewrite "/favicon.png"
     46   }
     47 }
     48 END
     49 
     50 mkdir -p /var/www/htdocs/git
     51 chown -R git:git /var/www/htdocs/git
     52 
     53 httpd -n
     54 rcctl restart httpd
     55 
     56 mkdir -p /git/
     57 chown -R git:git /git
     58 
     59 rcctl enable gitdaemon
     60 rcctl set gitdaemon flags --export-all --base-path="/git"
     61 rcctl set gitdaemon user git
     62 rcctl start gitdaemon
     63 
     64 cat > /usr/local/share/git-core/templates/hooks/post-receive << "END"
     65 #!/usr/bin/env sh
     66 
     67 set -e
     68 
     69 rm -rf /var/www/htdocs/git/index.html
     70 
     71 cd /git/
     72 for repo in */ ; do
     73     mkdir -p /var/www/htdocs/git/$repo
     74     cd /var/www/htdocs/git/$repo
     75     stagit /git/$repo
     76 done
     77 
     78 cd /var/www/htdocs/git/
     79 stagit-index /git/* >> index.html
     80 END
     81 
     82 chmod +x /usr/local/share/git-core/templates/hooks/post-receive