diff --git a/Propellor/Property/Git.hs b/Propellor/Property/Git.hs new file mode 100644 index 0000000..356ff87 --- /dev/null +++ b/Propellor/Property/Git.hs @@ -0,0 +1,47 @@ +module Propellor.Property.Git where + +import Propellor +import Propellor.Property.File +import qualified Propellor.Property.Apt as Apt +import qualified Propellor.Property.Service as Service + +import Data.List + +-- | Exports all git repos in a directory (that user nobody can read) +-- using git-daemon, run from inetd. +-- +-- Note that reverting this property does not remove or stop inetd. +daemonRunning :: FilePath -> RevertableProperty +daemonRunning exportdir = RevertableProperty setup unsetup + where + setup = containsLine conf (mkl "tcp4") + `requires` + containsLine conf (mkl "tcp6") + `requires` + dirExists exportdir + `requires` + Apt.serviceInstalledRunning "openbsd-inetd" + `onChange` + Service.reloaded "openbsd-inetd" + unsetup = lacksLine conf (mkl "tcp4") + `requires` + lacksLine conf (mkl "tcp6") + `onChange` + Service.reloaded "openbsd-inetd" + + conf = "/etc/inetd.conf" + + mkl tcpv = intercalate "\t" + [ "git" + , "stream" + , tcpv + , "nowait" + , "nobody" + , "/usr/bin/git" + , "git" + , "daemon" + , "--inetd" + , "--export-all" + , "--base-path=" ++ exportdir + , exportdir + ] diff --git a/config-joey.hs b/config-joey.hs index 9c64acb..b4aeebe 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -16,6 +16,7 @@ import qualified Propellor.Property.Tor as Tor import qualified Propellor.Property.Dns as Dns import qualified Propellor.Property.OpenId as OpenId import qualified Propellor.Property.Docker as Docker +import qualified Propellor.Property.Git as Git import qualified Propellor.Property.SiteSpecific.GitHome as GitHome import qualified Propellor.Property.SiteSpecific.GitAnnexBuilder as GitAnnexBuilder import qualified Propellor.Property.SiteSpecific.JoeySites as JoeySites @@ -61,12 +62,16 @@ host hostname@"diatom.kitenet.net" = Just $ props & Hostname.set hostname & Apt.unattendedUpgrades & Apt.serviceInstalledRunning "ntp" - & Apt.serviceInstalledRunning "bind9" & Dns.zones myDnsSecondary & Apt.serviceInstalledRunning "apache2" - & Apt.serviceInstalledRunning "git-daemon-sysvinit" & Apt.installed ["git", "git-annex", "rsync"] & Apt.buildDep ["git-annex"] `period` Daily + & Git.daemonRunning "/srv/git" + -- git repos restore (how?) + -- kgb installation and setup + -- ssh keys for branchable and github repo hooks + -- gitweb + -- downloads.kitenet.net setup (including ssh key to turtle) -- My laptop host _hostname@"darkstar.kitenet.net" = Just $ props & Docker.configured diff --git a/propellor.cabal b/propellor.cabal index 8f53d59..03d1474 100644 --- a/propellor.cabal +++ b/propellor.cabal @@ -72,6 +72,7 @@ Library Propellor.Property.Dns Propellor.Property.Docker Propellor.Property.File + Propellor.Property.Git Propellor.Property.Network Propellor.Property.OpenId Propellor.Property.Reboot