2014-11-19 03:54:49 +00:00
-- | Specific configuration for Joey Hess's sites. Probably not useful to
2014-03-31 03:37:54 +00:00
-- others except as an example.
2014-03-31 02:14:14 +00:00
2014-04-01 20:58:11 +00:00
module Propellor.Property.SiteSpecific.JoeySites where
2014-03-31 02:14:14 +00:00
2014-03-31 03:55:59 +00:00
import Propellor
2014-03-31 03:37:54 +00:00
import qualified Propellor.Property.Apt as Apt
2014-04-13 18:01:30 +00:00
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Gpg as Gpg
import qualified Propellor.Property.Ssh as Ssh
import qualified Propellor.Property.Git as Git
2014-04-14 18:53:19 +00:00
import qualified Propellor.Property.Cron as Cron
2014-04-13 18:01:30 +00:00
import qualified Propellor.Property.Service as Service
import qualified Propellor.Property.User as User
import qualified Propellor.Property.Obnam as Obnam
import qualified Propellor.Property.Apache as Apache
2014-07-18 01:16:03 +00:00
import qualified Propellor.Property.Postfix as Postfix
2014-04-13 20:38:58 +00:00
import Utility.SafeCommand
2014-05-01 00:55:12 +00:00
import Utility.FileMode
2014-03-31 02:14:14 +00:00
2014-04-18 03:32:42 +00:00
import Data.List
import System.Posix.Files
2014-07-22 19:25:07 +00:00
import Data.String.Utils
2014-04-18 03:32:42 +00:00
2015-03-12 02:06:08 +00:00
scrollBox :: Property HasInfo
2015-03-12 02:47:39 +00:00
scrollBox = propertyList " scroll server " $ props
2015-04-22 17:04:39 +00:00
& User . accountFor ( User " scroll " )
& Git . cloned ( User " scroll " ) " git://git.kitenet.net/scroll " ( d </> " scroll " ) Nothing
2015-03-12 02:06:08 +00:00
& Apt . installed [ " ghc " , " make " , " cabal-install " , " libghc-vector-dev " ,
" libghc-bytestring-dev " , " libghc-mtl-dev " , " libghc-ncurses-dev " ,
2015-03-13 18:32:00 +00:00
" libghc-random-dev " , " libghc-monad-loops-dev " , " libghc-text-dev " ,
2015-03-12 02:34:10 +00:00
" libghc-ifelse-dev " , " libghc-case-insensitive-dev " ,
2015-03-13 20:50:44 +00:00
" libghc-transformers-dev " ,
2015-03-13 02:48:29 +00:00
" libghc-data-default-dev " , " libghc-optparse-applicative-dev " ]
2015-04-22 17:04:39 +00:00
& userScriptProperty ( User " scroll " )
2015-03-12 02:06:08 +00:00
[ " cd " ++ d </> " scroll "
2015-03-12 02:31:45 +00:00
, " git pull "
2015-03-12 02:06:08 +00:00
, " cabal configure "
, " make "
]
& s ` File . hasContent `
[ " #!/bin/sh "
, " set -e "
, " echo Preparing to run scroll! "
2015-03-12 02:31:45 +00:00
, " cd " ++ d
2015-03-12 02:06:08 +00:00
, " mkdir -p tmp "
, " TMPDIR= t=$(tempfile -d tmp) "
2015-03-12 20:46:52 +00:00
, " export t "
2015-03-12 02:06:08 +00:00
, " rm -f \ " $t \ " "
, " mkdir \ " $t \ " "
, " cd \ " $t \ " "
2015-03-12 23:41:35 +00:00
, " echo "
2015-03-13 02:05:17 +00:00
, " echo Note that games on this server are time-limited to 2 hours "
, " echo 'Need more time? Run scroll locally instead!' "
, " echo "
2015-03-12 23:41:35 +00:00
, " echo Press Enter to start the game. "
, " read me "
2015-03-12 20:23:45 +00:00
, " SHELL=/bin/sh script --timing=timing -c " ++ g
] ` onChange ` ( s ` File . mode ` ( combineModes ( ownerWriteMode : readModes ++ executeModes ) ) )
& g ` File . hasContent `
[ " #!/bin/sh "
2015-03-13 02:05:17 +00:00
, " if ! timeout --kill-after 1m --foreground 2h ../../scroll/scroll; then "
2015-03-12 20:34:44 +00:00
, " echo Scroll seems to have ended unexpectedly. Possibly a bug.. "
, " else "
2015-03-12 20:23:45 +00:00
, " echo Thanks for playing scroll! https://joeyh.name/code/scroll/ "
2015-03-12 20:34:44 +00:00
, " fi "
2015-03-12 20:23:45 +00:00
, " echo Your game was recorded, as ID:$(basename \ " $t \ " ) "
, " echo if you would like to talk about how it went, email scroll@joeyh.name "
2015-03-12 20:38:29 +00:00
, " echo 'or, type comments below (finish with a dot on its own line)' "
2015-03-12 21:13:37 +00:00
, " echo "
, " echo Your comments: "
2015-03-21 13:52:58 +00:00
, " timeout --kill-after 1m --foreground 2h mail -E -s \ " scroll test $t \ " joey@kitenet.net "
2015-03-12 20:38:47 +00:00
] ` onChange ` ( g ` File . mode ` ( combineModes ( ownerWriteMode : readModes ++ executeModes ) ) )
2015-03-12 20:43:09 +00:00
& Apt . installed [ " bsd-mailx " ]
2015-03-12 02:06:08 +00:00
-- prevent port forwarding etc by not letting scroll log in via ssh
2015-03-12 02:18:50 +00:00
& Ssh . sshdConfig ` File . containsLine ` ( " DenyUsers scroll " )
` onChange ` Ssh . restarted
2015-04-22 17:48:52 +00:00
& User . shellSetTo ( User " scroll " ) s
2015-04-22 17:04:39 +00:00
& User . hasPassword ( User " scroll " )
2015-03-12 02:06:08 +00:00
& Apt . serviceInstalledRunning " telnetd "
2015-03-12 02:47:39 +00:00
& Apt . installed [ " shellinabox " ]
& File . hasContent " /etc/default/shellinabox "
[ " # Deployed by propellor "
, " SHELLINABOX_DAEMON_START=1 "
, " SHELLINABOX_PORT=4242 "
2015-03-12 03:07:41 +00:00
, " SHELLINABOX_ARGS= \ " --disable-ssl --no-beep --service=:scroll:scroll: " ++ d ++ " : " ++ s ++ " \ " "
2015-03-12 02:47:39 +00:00
]
` onChange ` Service . restarted " shellinabox "
& Service . running " shellinabox "
2015-03-12 02:06:08 +00:00
where
d = " /home/scroll "
s = d </> " login.sh "
2015-03-12 20:23:45 +00:00
g = d </> " game.sh "
2015-03-12 02:06:08 +00:00
2015-01-25 02:38:10 +00:00
oldUseNetServer :: [ Host ] -> Property HasInfo
oldUseNetServer hosts = propertyList " olduse.net server " $ props
2015-02-11 02:31:00 +00:00
& Apt . installed [ " leafnode " ]
2015-01-25 02:38:10 +00:00
& oldUseNetInstalled " oldusenet-server "
& Obnam . latestVersion
& oldUseNetBackup
& check ( not . isSymbolicLink <$> getSymbolicLinkStatus newsspool )
( property " olduse.net spool in place " $ makeChange $ do
2014-04-18 03:32:42 +00:00
removeDirectoryRecursive newsspool
createSymbolicLink ( datadir </> " news " ) newsspool
2015-01-25 02:38:10 +00:00
)
& " /etc/news/leafnode/config " ` File . hasContent `
2014-04-18 03:32:42 +00:00
[ " # olduse.net configuration (deployed by propellor) "
, " expire = 1000000 " -- no expiry via texpire
, " server = " -- no upstream server
, " debugmode = 1 "
, " allowSTRANGERS = 42 " -- lets anyone connect
, " nopost = 1 " -- no new posting (just gather them)
]
2015-01-25 02:38:10 +00:00
& " /etc/hosts.deny " ` File . lacksLine ` " leafnode: ALL "
& Apt . serviceInstalledRunning " openbsd-inetd "
& File . notPresent " /etc/cron.daily/leafnode "
& File . notPresent " /etc/cron.d/leafnode "
2015-04-22 17:04:39 +00:00
& Cron . niceJob " oldusenet-expire " ( Cron . Times " 11 1 * * * " ) ( User " news " ) newsspool expirecommand
& Cron . niceJob " oldusenet-uucp " ( Cron . Times " */5 * * * * " ) ( User " news " ) " / " uucpcommand
2015-01-25 02:38:10 +00:00
& Apache . siteEnabled " nntp.olduse.net " nntpcfg
where
newsspool = " /var/spool/news "
datadir = " /var/spool/oldusenet "
expirecommand = intercalate " ; "
2014-04-18 03:32:42 +00:00
[ " find \ \ ( -path ./out.going -or -path ./interesting.groups -or -path './*/.overview' \ \ ) -prune -or -type f -ctime +60 -print | xargs --no-run-if-empty rm "
, " find -type d -empty | xargs --no-run-if-empty rmdir "
]
2015-01-25 02:38:10 +00:00
uucpcommand = " /usr/bin/uucp " ++ datadir
nntpcfg = apachecfg " nntp.olduse.net " False
2014-04-18 03:32:42 +00:00
[ " DocumentRoot " ++ datadir ++ " / "
, " <Directory " ++ datadir ++ " /> "
, " Options Indexes FollowSymlinks "
, " AllowOverride None "
2014-07-22 20:40:11 +00:00
, Apache . allowAll
2014-04-18 03:32:42 +00:00
, " </Directory> "
]
2015-02-01 21:34:04 +00:00
oldUseNetBackup = Obnam . backup datadir ( Cron . Times " 33 4 * * * " )
2015-01-25 02:38:10 +00:00
[ " --repository=sftp://2318@usw-s002.rsync.net/~/olduse.net "
, " --client-name=spool "
2015-02-11 00:29:04 +00:00
, " --ssh-key= " ++ keyfile
2015-01-25 02:38:10 +00:00
] Obnam . OnlyClient
2015-04-22 17:04:39 +00:00
` requires ` Ssh . keyImported' ( Just keyfile ) SshRsa ( User " root " ) ( Context " olduse.net " )
` requires ` Ssh . knownHost hosts " usw-s002.rsync.net " ( User " root " )
2015-02-11 00:29:04 +00:00
keyfile = " /root/.ssh/olduse.net.key "
2015-01-25 02:38:10 +00:00
oldUseNetShellBox :: Property HasInfo
oldUseNetShellBox = propertyList " olduse.net shellbox " $ props
& oldUseNetInstalled " oldusenet "
& Service . running " shellinabox "
2014-04-18 03:32:42 +00:00
2015-01-25 02:38:10 +00:00
oldUseNetInstalled :: Apt . Package -> Property HasInfo
2014-04-18 03:32:42 +00:00
oldUseNetInstalled pkg = check ( not <$> Apt . isInstalled pkg ) $
2015-01-25 02:38:10 +00:00
propertyList ( " olduse.net " ++ pkg ) $ props
& Apt . installed ( words " build-essential devscripts debhelper git libncursesw5-dev libpcre3-dev pkg-config bison libicu-dev libidn11-dev libcanlock2-dev libuu-dev ghc libghc-strptime-dev libghc-hamlet-dev libghc-ifelse-dev libghc-hxt-dev libghc-utf8-string-dev libghc-missingh-dev libghc-sha-dev " )
2014-03-31 02:14:14 +00:00
` describe ` " olduse.net build deps "
2015-01-25 02:38:10 +00:00
& scriptProperty
2014-03-31 02:25:11 +00:00
[ " rm -rf /root/tmp/oldusenet " -- idenpotency
2014-03-31 02:24:21 +00:00
, " git clone git://olduse.net/ /root/tmp/oldusenet/source "
2014-03-31 02:14:14 +00:00
, " cd /root/tmp/oldusenet/source/ "
, " dpkg-buildpackage -us -uc "
2014-04-18 03:32:42 +00:00
, " dpkg -i ../ " ++ pkg ++ " _*.deb || true "
2014-03-31 02:40:55 +00:00
, " apt-get -fy install " -- dependencies
2014-03-31 02:14:14 +00:00
, " rm -rf /root/tmp/oldusenet "
] ` describe ` " olduse.net built "
2014-04-13 18:01:30 +00:00
2015-01-25 02:38:10 +00:00
kgbServer :: Property HasInfo
kgbServer = propertyList desc $ props
& installed
& File . hasPrivContent " /etc/kgb-bot/kgb.conf " anyContext
` onChange ` Service . restarted " kgb-bot "
where
desc = " kgb.kitenet.net setup "
installed = withOS desc $ \ o -> case o of
2014-07-06 21:15:27 +00:00
( Just ( System ( Debian Unstable ) _ ) ) ->
ensureProperty $ propertyList desc
[ Apt . serviceInstalledRunning " kgb-bot "
, " /etc/default/kgb-bot " ` File . containsLine ` " BOT_ENABLED=1 "
` describe ` " kgb bot enabled "
` onChange ` Service . running " kgb-bot "
]
_ -> error " kgb server needs Debian unstable (for kgb-bot 1.31+) "
2014-04-13 20:38:58 +00:00
2015-01-25 02:38:10 +00:00
mumbleServer :: [ Host ] -> Property HasInfo
mumbleServer hosts = combineProperties hn $ props
& Apt . serviceInstalledRunning " mumble-server "
& Obnam . latestVersion
2015-02-01 21:34:04 +00:00
& Obnam . backup " /var/lib/mumble-server " ( Cron . Times " 55 5 * * * " )
2015-02-01 20:40:03 +00:00
[ " --repository=sftp://2318@usw-s002.rsync.net/~/ " ++ hn ++ " .obnam "
2014-04-20 02:22:23 +00:00
, " --client-name=mumble "
] Obnam . OnlyClient
2015-04-22 17:04:39 +00:00
` requires ` Ssh . keyImported SshRsa ( User " root " ) ( Context hn )
` requires ` Ssh . knownHost hosts " usw-s002.rsync.net " ( User " root " )
2015-01-25 02:38:10 +00:00
& trivial ( cmdProperty " chown " [ " -R " , " mumble-server:mumble-server " , " /var/lib/mumble-server " ] )
2014-07-06 19:56:56 +00:00
where
hn = " mumble.debian.net "
2014-04-20 02:22:23 +00:00
2014-04-13 18:01:30 +00:00
-- git.kitenet.net and git.joeyh.name
2015-01-25 02:38:10 +00:00
gitServer :: [ Host ] -> Property HasInfo
gitServer hosts = propertyList " git.kitenet.net setup " $ props
& Obnam . latestVersion
2015-02-01 21:34:04 +00:00
& Obnam . backupEncrypted " /srv/git " ( Cron . Times " 33 3 * * * " )
2014-04-18 02:30:23 +00:00
[ " --repository=sftp://2318@usw-s002.rsync.net/~/git.kitenet.net "
2015-02-11 00:29:04 +00:00
, " --ssh-key= " ++ sshkey
2014-07-17 19:53:12 +00:00
, " --client-name=wren " -- historical
2014-11-15 21:02:25 +00:00
] Obnam . OnlyClient ( Gpg . GpgKeyId " 1B169BE1 " )
2015-04-22 17:04:39 +00:00
` requires ` Ssh . keyImported' ( Just sshkey ) SshRsa ( User " root " ) ( Context " git.kitenet.net " )
` requires ` Ssh . knownHost hosts " usw-s002.rsync.net " ( User " root " )
` requires ` Ssh . authorizedKeys ( User " family " ) ( Context " git.kitenet.net " )
` requires ` User . accountFor ( User " family " )
2015-01-25 02:38:10 +00:00
& Apt . installed [ " git " , " rsync " , " gitweb " ]
2015-02-10 23:57:18 +00:00
& Apt . installed [ " git-annex " ]
2015-02-11 01:01:38 +00:00
& Apt . installed [ " kgb-client " ]
2015-01-25 02:38:10 +00:00
& File . hasPrivContentExposed " /etc/kgb-bot/kgb-client.conf " anyContext
2015-02-11 01:01:38 +00:00
` requires ` File . dirExists " /etc/kgb-bot/ "
2015-01-25 02:38:10 +00:00
& Git . daemonRunning " /srv/git "
& " /etc/gitweb.conf " ` File . containsLines `
2014-04-13 18:45:18 +00:00
[ " $projectroot = '/srv/git'; "
2014-04-14 01:04:34 +00:00
, " @git_base_url_list = ('git://git.kitenet.net', 'http://git.kitenet.net/git', 'https://git.kitenet.net/git', 'ssh://git.kitenet.net/srv/git'); "
2014-04-13 18:01:30 +00:00
, " # disable snapshot download; overloads server "
, " $feature{'snapshot'}{'default'} = []; "
]
` describe ` " gitweb configured "
2014-04-13 20:49:49 +00:00
-- Repos push on to github.
2015-04-22 17:04:39 +00:00
& Ssh . knownHost hosts " github.com " ( User " joey " )
2014-04-13 18:12:11 +00:00
-- I keep the website used for gitweb checked into git..
2015-04-22 17:04:39 +00:00
& Git . cloned ( User " root " ) " /srv/git/joey/git.kitenet.net.git " " /srv/web/git.kitenet.net " Nothing
2015-01-25 02:38:10 +00:00
& website " git.kitenet.net "
& website " git.joeyh.name "
& Apache . modEnabled " cgi "
2014-04-13 18:01:30 +00:00
where
2015-02-11 00:29:04 +00:00
sshkey = " /root/.ssh/git.kitenet.net.key "
2015-01-25 02:38:10 +00:00
website hn = apacheSite hn True
2014-04-14 00:22:35 +00:00
[ " DocumentRoot /srv/web/git.kitenet.net/ "
, " <Directory /srv/web/git.kitenet.net/> "
, " Options Indexes ExecCGI FollowSymlinks "
, " AllowOverride None "
, " AddHandler cgi-script .cgi "
, " DirectoryIndex index.cgi "
2015-02-11 01:21:51 +00:00
, Apache . allowAll
2014-04-14 00:22:35 +00:00
, " </Directory> "
, " "
, " ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ "
, " <Directory /usr/lib/cgi-bin> "
, " SetHandler cgi-script "
, " Options ExecCGI "
, " </Directory> "
]
2014-04-13 18:01:30 +00:00
2014-04-13 20:38:58 +00:00
type AnnexUUID = String
-- | A website, with files coming from a git-annex repository.
2015-01-25 02:38:10 +00:00
annexWebSite :: Git . RepoUrl -> HostName -> AnnexUUID -> [ ( String , Git . RepoUrl ) ] -> Property HasInfo
annexWebSite origin hn uuid remotes = propertyList ( hn ++ " website using git-annex " ) $ props
2015-04-22 17:04:39 +00:00
& Git . cloned ( User " joey " ) origin dir Nothing
2014-04-14 01:04:34 +00:00
` onChange ` setup
2015-01-25 02:38:10 +00:00
& alias hn
& postupdatehook ` File . hasContent `
2014-05-01 00:56:24 +00:00
[ " #!/bin/sh "
2014-05-01 00:55:12 +00:00
, " exec git update-server-info "
] ` onChange `
( postupdatehook ` File . mode ` ( combineModes ( ownerWriteMode : readModes ++ executeModes ) ) )
2015-01-25 02:38:10 +00:00
& setupapache
2014-04-13 20:38:58 +00:00
where
dir = " /srv/web/ " ++ hn
2014-05-01 00:55:12 +00:00
postupdatehook = dir </> " .git/hooks/post-update "
2015-04-22 17:04:39 +00:00
setup = userScriptProperty ( User " joey " ) setupscript
2014-04-13 21:03:21 +00:00
setupscript =
2014-04-13 20:38:58 +00:00
[ " cd " ++ shellEscape dir
2015-02-11 01:39:16 +00:00
, " git annex reinit " ++ shellEscape uuid
2014-04-13 20:38:58 +00:00
] ++ map addremote remotes ++
[ " git annex get "
2015-01-06 05:00:48 +00:00
, " git update-server-info "
2014-04-13 20:38:58 +00:00
]
addremote ( name , url ) = " git remote add " ++ shellEscape name ++ " " ++ shellEscape url
2015-01-25 02:38:10 +00:00
setupapache = apacheSite hn True
2014-04-14 00:22:35 +00:00
[ " ServerAlias www. " ++ hn
, " "
, " DocumentRoot /srv/web/ " ++ hn
, " <Directory /srv/web/ " ++ hn ++ " > "
, " Options FollowSymLinks "
, " AllowOverride None "
2015-02-11 01:46:31 +00:00
, Apache . allowAll
2014-04-14 00:22:35 +00:00
, " </Directory> "
, " <Directory /srv/web/ " ++ hn ++ " > "
, " Options Indexes FollowSymLinks ExecCGI "
, " AllowOverride None "
2014-04-14 18:04:18 +00:00
, " AddHandler cgi-script .cgi "
2014-04-14 18:05:42 +00:00
, " DirectoryIndex index.html index.cgi "
2015-02-11 01:46:31 +00:00
, Apache . allowAll
2014-04-14 00:22:35 +00:00
, " </Directory> "
]
2014-04-13 20:38:58 +00:00
2015-01-25 02:38:10 +00:00
apacheSite :: HostName -> Bool -> Apache . ConfigFile -> RevertableProperty
apacheSite hn withssl middle = Apache . siteEnabled hn $ apachecfg hn withssl middle
2014-04-14 00:22:35 +00:00
apachecfg :: HostName -> Bool -> Apache . ConfigFile -> Apache . ConfigFile
apachecfg hn withssl middle
| withssl = vhost False ++ vhost True
| otherwise = vhost False
2014-04-13 20:38:58 +00:00
where
2014-04-14 00:22:35 +00:00
vhost ssl =
[ " <VirtualHost *: " ++ show port ++ " > "
, " ServerAdmin grue@joeyh.name "
, " ServerName " ++ hn ++ " : " ++ show port
]
++ mainhttpscert ssl
++ middle ++
[ " "
, " ErrorLog /var/log/apache2/error.log "
, " LogLevel warn "
, " CustomLog /var/log/apache2/access.log combined "
, " ServerSignature On "
, " "
, " <Directory \ " /usr/share/apache2/icons \ " > "
, " Options Indexes MultiViews "
, " AllowOverride None "
2015-02-11 01:46:31 +00:00
, Apache . allowAll
2014-04-14 00:22:35 +00:00
, " </Directory> "
, " </VirtualHost> "
2014-04-13 20:38:58 +00:00
]
where
2014-04-14 00:22:35 +00:00
port = if ssl then 443 else 80 :: Int
2014-04-13 20:38:58 +00:00
2014-04-14 00:22:35 +00:00
mainhttpscert :: Bool -> Apache . ConfigFile
mainhttpscert False = []
mainhttpscert True =
[ " SSLEngine on "
, " SSLCertificateFile /etc/ssl/certs/web.pem "
, " SSLCertificateKeyFile /etc/ssl/private/web.pem "
, " SSLCertificateChainFile /etc/ssl/certs/startssl.pem "
2014-04-13 18:01:30 +00:00
]
2014-04-14 18:00:37 +00:00
2015-01-25 02:38:10 +00:00
gitAnnexDistributor :: Property HasInfo
gitAnnexDistributor = combineProperties " git-annex distributor, including rsync server and signer " $ props
& Apt . installed [ " rsync " ]
& File . hasPrivContent " /etc/rsyncd.conf " ( Context " git-annex distributor " )
2014-05-26 22:59:13 +00:00
` onChange ` Service . restarted " rsync "
2015-01-25 02:38:10 +00:00
& File . hasPrivContent " /etc/rsyncd.secrets " ( Context " git-annex distributor " )
2014-05-26 22:59:13 +00:00
` onChange ` Service . restarted " rsync "
2015-01-25 02:38:10 +00:00
& " /etc/default/rsync " ` File . containsLine ` " RSYNC_ENABLE=true "
2014-05-26 22:59:13 +00:00
` onChange ` Service . running " rsync "
2015-01-25 02:38:10 +00:00
& endpoint " /srv/web/downloads.kitenet.net/git-annex/autobuild "
2015-02-13 19:59:50 +00:00
& endpoint " /srv/web/downloads.kitenet.net/git-annex/autobuild/x86_64-apple-yosemite "
2015-02-19 22:40:50 +00:00
& endpoint " /srv/web/downloads.kitenet.net/git-annex/autobuild/windows "
2014-04-21 15:11:47 +00:00
-- git-annex distribution signing key
2015-04-22 17:04:39 +00:00
& Gpg . keyImported ( Gpg . GpgKeyId " 89C809CB " ) ( User " joey " )
2014-04-14 18:00:37 +00:00
where
endpoint d = combineProperties ( " endpoint " ++ d )
[ File . dirExists d
2015-04-22 17:04:39 +00:00
, File . ownerGroup d ( User " joey " ) ( Group " joey " )
2014-04-14 18:00:37 +00:00
]
2014-04-14 18:40:57 +00:00
2015-02-11 01:39:16 +00:00
downloads :: [ Host ] -> Property HasInfo
downloads hosts = annexWebSite " /srv/git/downloads.git "
" downloads.kitenet.net "
" 840760dc-08f0-11e2-8c61-576b7e66acfd "
[ ( " eubackup " , " ssh://eubackup.kitenet.net/~/lib/downloads/ " ) ]
2015-04-22 17:04:39 +00:00
` requires ` Ssh . knownHost hosts " eubackup.kitenet.net " ( User " joey " )
2015-02-11 01:39:16 +00:00
tmp :: Property HasInfo
tmp = propertyList " tmp.kitenet.net " $ props
& annexWebSite " /srv/git/joey/tmp.git "
" tmp.kitenet.net "
" 26fd6e38-1226-11e2-a75f-ff007033bdba "
[]
& twitRss
& pumpRss
2014-04-14 18:53:19 +00:00
-- Twitter, you kill us.
2015-01-25 02:38:10 +00:00
twitRss :: Property HasInfo
twitRss = combineProperties " twitter rss " $ props
2015-04-22 17:04:39 +00:00
& Git . cloned ( User " joey " ) " git://git.kitenet.net/twitrss.git " dir Nothing
2015-01-25 02:38:10 +00:00
& check ( not <$> doesFileExist ( dir </> " twitRss " ) ) compiled
& feed " http://twitter.com/search/realtime?q=git-annex " " git-annex-twitter "
& feed " http://twitter.com/search/realtime?q=olduse+OR+git-annex+OR+debhelper+OR+etckeeper+OR+ikiwiki+-ashley_ikiwiki " " twittergrep "
2014-04-14 18:40:57 +00:00
where
dir = " /srv/web/tmp.kitenet.net/twitrss "
2015-02-01 21:34:04 +00:00
crontime = Cron . Times " 15 * * * * "
2015-04-22 17:04:39 +00:00
feed url desc = Cron . job desc crontime ( User " joey " ) dir $
2014-04-14 18:55:03 +00:00
" ./twitRss " ++ shellEscape url ++ " > " ++ shellEscape ( " ../ " ++ desc ++ " .rss " )
2015-04-22 17:04:39 +00:00
compiled = userScriptProperty ( User " joey " )
2015-01-25 02:38:10 +00:00
[ " cd " ++ dir
, " ghc --make twitRss "
]
` requires ` Apt . installed
[ " libghc-xml-dev "
, " libghc-feed-dev "
, " libghc-tagsoup-dev "
]
2014-05-09 13:31:30 +00:00
2014-08-21 19:52:49 +00:00
-- Work around for expired ssl cert.
2015-01-25 02:38:10 +00:00
pumpRss :: Property NoInfo
2015-04-22 17:04:39 +00:00
pumpRss = Cron . job " pump rss " ( Cron . Times " 15 * * * * " ) ( User " joey " ) " /srv/web/tmp.kitenet.net/ "
2015-03-06 19:40:38 +00:00
" wget https://pump2rss.com/feed/joeyh@identi.ca.atom -O pump.atom.new --no-check-certificate 2>/dev/null; sed 's/ & / /g' pump.atom.new > pump.atom "
2014-08-21 19:52:49 +00:00
2015-01-25 02:38:10 +00:00
ircBouncer :: Property HasInfo
ircBouncer = propertyList " IRC bouncer " $ props
& Apt . installed [ " znc " ]
2015-04-22 17:04:39 +00:00
& User . accountFor ( User " znc " )
2015-01-25 02:38:10 +00:00
& File . dirExists ( takeDirectory conf )
& File . hasPrivContent conf anyContext
2015-04-22 17:04:39 +00:00
& File . ownerGroup conf ( User " znc " ) ( Group " znc " )
& Cron . job " znconboot " ( Cron . Times " @reboot " ) ( User " znc " ) " ~ " " znc "
2014-07-05 20:24:22 +00:00
-- ensure running if it was not already
2015-04-22 17:04:39 +00:00
& trivial ( userScriptProperty ( User " znc " ) [ " znc || true " ] )
2014-07-06 21:43:48 +00:00
` describe ` " znc running "
2014-05-09 13:31:30 +00:00
where
conf = " /home/znc/.znc/configs/znc.conf "
2014-05-31 18:15:16 +00:00
2015-01-25 02:38:10 +00:00
kiteShellBox :: Property NoInfo
2014-05-31 18:15:16 +00:00
kiteShellBox = propertyList " kitenet.net shellinabox "
2015-03-13 00:29:39 +00:00
[ Apt . installed [ " openssl " , " shellinabox " ]
2014-05-31 18:15:16 +00:00
, File . hasContent " /etc/default/shellinabox "
[ " # Deployed by propellor "
, " SHELLINABOX_DAEMON_START=1 "
, " SHELLINABOX_PORT=443 "
2014-05-31 18:28:12 +00:00
, " SHELLINABOX_ARGS= \ " --no-beep --service=/:SSH:kitenet.net \ " "
2014-05-31 18:15:16 +00:00
]
` onChange ` Service . restarted " shellinabox "
, Service . running " shellinabox "
]
2014-06-01 17:07:31 +00:00
2015-01-25 02:38:10 +00:00
githubBackup :: Property HasInfo
githubBackup = propertyList " github-backup box " $ props
& Apt . installed [ " github-backup " , " moreutils " ]
& githubKeys
2015-04-22 17:04:39 +00:00
& Cron . niceJob " github-backup run " ( Cron . Times " 30 4 * * * " ) ( User " joey " )
2015-01-25 02:38:10 +00:00
" /home/joey/lib/backup " backupcmd
2015-04-22 17:04:39 +00:00
& Cron . niceJob " gitriddance " ( Cron . Times " 30 4 * * * " ) ( User " joey " )
2015-01-25 02:38:10 +00:00
" /home/joey/lib/backup " gitriddancecmd
2014-12-22 19:05:05 +00:00
where
2015-01-25 02:38:10 +00:00
backupcmd = intercalate " && " $
[ " mkdir -p github "
, " cd github "
, " . $HOME/.github-keys "
, " github-backup joeyh "
]
gitriddancecmd = intercalate " && " $
[ " cd github "
, " . $HOME/.github-keys "
] ++ map gitriddance githubMirrors
2014-12-22 19:05:05 +00:00
gitriddance ( r , msg ) = " (cd " ++ r ++ " && gitriddance " ++ shellEscape msg ++ " ) "
2014-12-22 21:16:52 +00:00
2015-01-25 02:38:10 +00:00
githubKeys :: Property HasInfo
githubKeys =
let f = " /home/joey/.github-keys "
in File . hasPrivContent f anyContext
2015-04-22 17:04:39 +00:00
` onChange ` File . ownerGroup f ( User " joey " ) ( Group " joey " )
2015-01-25 02:38:10 +00:00
2014-12-22 21:16:52 +00:00
-- these repos are only mirrored on github, I don't want
-- all the proprietary features
githubMirrors :: [ ( String , String ) ]
githubMirrors =
[ ( " ikiwiki " , plzuseurl " http://ikiwiki.info/todo/ " )
, ( " git-annex " , plzuseurl " http://git-annex.branchable.com/todo/ " )
, ( " myrepos " , plzuseurl " http://myrepos.branchable.com/todo/ " )
, ( " propellor " , plzuseurl " http://propellor.branchable.com/todo/ " )
, ( " etckeeper " , plzuseurl " http://etckeeper.branchable.com/todo/ " )
]
where
2015-04-11 14:13:17 +00:00
plzuseurl u = " Please submit changes to " ++ u ++ " instead of using github pull requests, which are not part of my workflow. -- A robot acting on behalf of Joey Hess "
2014-06-07 02:46:31 +00:00
2015-01-25 02:38:10 +00:00
rsyncNetBackup :: [ Host ] -> Property NoInfo
2015-02-01 21:34:04 +00:00
rsyncNetBackup hosts = Cron . niceJob " rsync.net copied in daily " ( Cron . Times " 30 5 * * * " )
2015-04-22 17:04:39 +00:00
( User " joey " ) " /home/joey/lib/backup " " mkdir -p rsync.net && rsync --delete -az 2318@usw-s002.rsync.net: rsync.net "
` requires ` Ssh . knownHost hosts " usw-s002.rsync.net " ( User " joey " )
2014-07-17 19:33:02 +00:00
2015-02-01 20:40:03 +00:00
backupsBackedupFrom :: [ Host ] -> HostName -> FilePath -> Property NoInfo
backupsBackedupFrom hosts srchost destdir = Cron . niceJob desc
2015-04-22 17:04:39 +00:00
( Cron . Times " @reboot " ) ( User " joey " ) " / " cmd
` requires ` Ssh . knownHost hosts srchost ( User " joey " )
2014-07-17 19:33:02 +00:00
where
2015-02-01 20:40:03 +00:00
desc = " backups copied from " ++ srchost ++ " on boot "
2015-02-01 21:01:32 +00:00
cmd = " rsync -az --bwlimit=300K --partial --delete " ++ srchost ++ " :lib/backup/ " ++ destdir </> srchost
2014-07-17 19:33:02 +00:00
2015-01-25 02:38:10 +00:00
obnamRepos :: [ String ] -> Property NoInfo
2014-06-07 02:46:31 +00:00
obnamRepos rs = propertyList ( " obnam repos for " ++ unwords rs )
( mkbase : map mkrepo rs )
where
2014-10-08 17:14:21 +00:00
mkbase = mkdir " /home/joey/lib/backup "
2014-06-07 02:49:55 +00:00
` requires ` mkdir " /home/joey/lib "
2014-06-07 02:47:42 +00:00
mkrepo r = mkdir ( " /home/joey/lib/backup/ " ++ r ++ " .obnam " )
2014-06-07 02:46:31 +00:00
mkdir d = File . dirExists d
2015-04-22 17:04:39 +00:00
` before ` File . ownerGroup d ( User " joey " ) ( Group " joey " )
2014-06-07 02:46:31 +00:00
2015-01-25 02:38:10 +00:00
podcatcher :: Property NoInfo
2015-02-01 21:34:04 +00:00
podcatcher = Cron . niceJob " podcatcher run hourly " ( Cron . Times " 55 * * * * " )
2015-04-22 17:04:39 +00:00
( User " joey " ) " /home/joey/lib/sound/podcasts "
2014-07-17 19:33:02 +00:00
" xargs git-annex importfeed -c annex.genmetadata=true < feeds; mr --quiet update "
2014-07-17 20:16:13 +00:00
` requires ` Apt . installed [ " git-annex " , " myrepos " ]
2014-07-18 01:16:03 +00:00
2015-01-25 02:38:10 +00:00
kiteMailServer :: Property HasInfo
kiteMailServer = propertyList " kitenet.net mail server " $ props
& Postfix . installed
& Apt . installed [ " postfix-pcre " ]
& Apt . serviceInstalledRunning " postgrey "
2014-07-18 04:36:21 +00:00
2015-01-25 02:38:10 +00:00
& Apt . serviceInstalledRunning " spamassassin "
& " /etc/default/spamassassin " ` File . containsLines `
2014-07-18 05:03:05 +00:00
[ " # Propellor deployed "
, " ENABLED=1 "
2014-07-18 01:16:03 +00:00
, " OPTIONS= \ " --create-prefs --max-children 5 --helper-home-dir \ " "
, " CRON=1 "
, " NICE= \ " --nicelevel 15 \ " "
] ` onChange ` Service . restarted " spamassassin "
2014-07-18 02:23:49 +00:00
` describe ` " spamd enabled "
2014-07-18 05:03:05 +00:00
` requires ` Apt . serviceInstalledRunning " cron "
2014-07-18 04:36:21 +00:00
2015-01-25 02:38:10 +00:00
& Apt . serviceInstalledRunning " spamass-milter "
2014-07-18 04:36:21 +00:00
-- Add -m to prevent modifying messages Subject or body.
2015-01-25 02:38:10 +00:00
& " /etc/default/spamass-milter " ` File . containsLine `
2014-07-18 04:36:21 +00:00
" OPTIONS= \ " -m -u spamass-milter -i 127.0.0.1 \ " "
` onChange ` Service . restarted " spamass-milter "
` describe ` " spamass-milter configured "
2015-01-25 02:38:10 +00:00
& Apt . serviceInstalledRunning " amavisd-milter "
& " /etc/default/amavisd-milter " ` File . containsLines `
2014-07-18 06:51:47 +00:00
[ " # Propellor deployed "
, " MILTERSOCKET=/var/spool/postfix/amavis/amavis.sock "
, " MILTERSOCKETOWNER= \ " postfix:postfix \ " "
, " MILTERSOCKETMODE= \ " 0660 \ " "
]
` onChange ` Service . restarted " amavisd-milter "
` describe ` " amavisd-milter configured for postfix "
2015-01-25 02:38:10 +00:00
& Apt . serviceInstalledRunning " clamav-freshclam "
2014-07-18 06:27:15 +00:00
2015-01-25 02:38:10 +00:00
& dkimInstalled
2015-01-09 01:17:06 +00:00
2015-02-01 18:48:13 +00:00
& Postfix . saslAuthdInstalled
2015-01-25 02:38:10 +00:00
& Apt . installed [ " maildrop " ]
& " /etc/maildroprc " ` File . hasContent `
2014-07-18 05:03:05 +00:00
[ " # Global maildrop filter file (deployed with propellor) "
2014-07-18 04:36:21 +00:00
, " DEFAULT= \ " $HOME/Maildir \ " "
, " MAILBOX= \ " $DEFAULT/. \ " "
, " # Filter spam to a spam folder, unless .keepspam exists "
, " if (/^X-Spam-Status: Yes/) "
, " { "
, " `test -e \ " $HOME/.keepspam \ " ` "
, " if ( $RETURNCODE != 0 ) "
, " to ${MAILBOX}spam "
, " } "
]
` describe ` " maildrop configured "
2015-01-25 02:38:10 +00:00
& " /etc/aliases " ` File . hasPrivContentExposed ` ctx
2014-07-18 05:03:05 +00:00
` onChange ` Postfix . newaliases
2015-01-25 02:38:10 +00:00
& hasJoeyCAChain
& hasPostfixCert ctx
2014-07-18 04:36:21 +00:00
2015-01-25 02:38:10 +00:00
& " /etc/postfix/mydomain " ` File . containsLines `
2014-07-18 01:16:03 +00:00
[ " /.* \ \ .kitenet \ \ .net/ \ t OK "
, " /ikiwiki \ \ .info/ \ t OK "
, " /joeyh \ \ .name/ \ t OK "
]
2014-07-18 06:08:13 +00:00
` onChange ` Postfix . reloaded
2014-07-18 01:47:15 +00:00
` describe ` " postfix mydomain file configured "
2015-01-25 02:38:10 +00:00
& " /etc/postfix/obscure_client_relay.pcre " ` File . hasContent `
2014-09-24 15:18:12 +00:00
-- Remove received lines for mails relayed from trusted
2015-01-09 01:17:06 +00:00
-- clients. These can be a privacy violation, or trigger
2014-09-24 15:18:12 +00:00
-- spam filters.
[ " /^Received: from ([^.]+) \ \ .kitenet \ \ .net.*using TLS.*by kitenet \ \ .net \ \ (([^)]+) \ \ ) with (E?SMTPS?A?) id ([A-F[:digit:]]+)(.*)/ IGNORE "
2014-09-24 18:03:23 +00:00
-- Munge local Received line for postfix running on a
2014-09-24 15:18:12 +00:00
-- trusted client that relays through. These can trigger
-- spam filters.
2015-01-09 02:01:12 +00:00
, " /^Received: by ([^.]+) \ \ .kitenet \ \ .net.*/ REPLACE X-Question: 42 "
2014-09-24 15:18:12 +00:00
]
2014-07-18 06:08:13 +00:00
` onChange ` Postfix . reloaded
2014-07-18 01:47:15 +00:00
` describe ` " postfix obscure_client_relay file configured "
2015-01-25 02:38:10 +00:00
& Postfix . mappedFile " /etc/postfix/virtual "
2014-07-18 01:47:15 +00:00
( flip File . containsLines
2014-07-18 01:16:03 +00:00
[ " # *@joeyh.name to joey "
, " @joeyh.name \ t joey "
]
2014-07-18 01:47:15 +00:00
) ` describe ` " postfix virtual file configured "
2014-07-18 06:08:13 +00:00
` onChange ` Postfix . reloaded
2015-01-25 02:38:10 +00:00
& Postfix . mappedFile " /etc/postfix/relay_clientcerts "
( flip File . hasPrivContentExposed ctx )
& Postfix . mainCfFile ` File . containsLines `
2014-07-18 01:16:03 +00:00
[ " myhostname = kitenet.net "
, " mydomain = $myhostname "
, " append_dot_mydomain = no "
, " myorigin = kitenet.net "
, " mydestination = $myhostname, localhost.$mydomain, $mydomain, kite.$mydomain., localhost, regexp:$config_directory/mydomain "
, " mailbox_command = maildrop "
, " virtual_alias_maps = hash:/etc/postfix/virtual "
, " # Allow clients with trusted certs to relay mail through. "
, " relay_clientcerts = hash:/etc/postfix/relay_clientcerts "
, " smtpd_relay_restrictions = permit_mynetworks,permit_tls_clientcerts,permit_sasl_authenticated,reject_unauth_destination "
, " # Filter out client relay lines from headers. "
, " header_checks = pcre:$config_directory/obscure_client_relay.pcre "
2015-02-01 18:48:13 +00:00
, " # Password auth for relaying (used by errol) "
2015-02-01 17:14:45 +00:00
, " smtpd_sasl_auth_enable = yes "
, " smtpd_sasl_security_options = noanonymous "
, " smtpd_sasl_local_domain = kitenet.net "
2014-07-18 01:16:03 +00:00
, " # Enable postgrey. "
2015-02-01 17:14:45 +00:00
, " smtpd_recipient_restrictions = permit_tls_clientcerts,permit_sasl_authenticated,,permit_mynetworks,reject_unauth_destination,check_policy_service inet:127.0.0.1:10023 "
2014-07-18 01:16:03 +00:00
2015-01-09 01:41:55 +00:00
, " # Enable spamass-milter, amavis-milter, opendkim "
, " smtpd_milters = unix:/spamass/spamass.sock unix:amavis/amavis.sock inet:localhost:8891 "
, " # opendkim is used for outgoing mail "
, " non_smtpd_milters = inet:localhost:8891 "
2014-07-18 01:16:03 +00:00
, " milter_connect_macros = j {daemon_name} v {if_name} _ "
2015-01-09 01:41:55 +00:00
, " # If a milter is broken, fall back to just accepting mail. "
, " milter_default_action = accept "
2014-07-18 01:16:03 +00:00
, " # TLS setup -- server "
, " smtpd_tls_CAfile = /etc/ssl/certs/joeyca.pem "
, " smtpd_tls_cert_file = /etc/ssl/certs/postfix.pem "
, " smtpd_tls_key_file = /etc/ssl/private/postfix.pem "
, " smtpd_tls_loglevel = 1 "
, " smtpd_tls_received_header = yes "
, " smtpd_use_tls = yes "
, " smtpd_tls_ask_ccert = yes "
, " smtpd_tls_session_cache_database = sdbm:/etc/postfix/smtpd_scache "
, " # TLS setup -- client "
, " smtp_tls_CAfile = /etc/ssl/certs/joeyca.pem "
, " smtp_tls_cert_file = /etc/ssl/certs/postfix.pem "
, " smtp_tls_key_file = /etc/ssl/private/postfix.pem "
, " smtp_tls_loglevel = 1 "
, " smtp_use_tls = yes "
, " smtp_tls_session_cache_database = sdbm:/etc/postfix/smtp_scache "
]
2014-07-18 03:42:10 +00:00
` onChange ` Postfix . dedupMainCf
2014-07-18 06:08:13 +00:00
` onChange ` Postfix . reloaded
2014-07-18 01:47:15 +00:00
` describe ` " postfix configured "
2014-07-18 04:36:21 +00:00
2015-01-25 02:38:10 +00:00
& Apt . serviceInstalledRunning " dovecot-imapd "
& Apt . serviceInstalledRunning " dovecot-pop3d "
& " /etc/dovecot/conf.d/10-mail.conf " ` File . containsLine `
2014-07-18 19:58:05 +00:00
" mail_location = maildir:~/Maildir "
` onChange ` Service . reloaded " dovecot "
2014-07-18 20:40:09 +00:00
` describe ` " dovecot mail.conf "
2015-01-25 02:38:10 +00:00
& " /etc/dovecot/conf.d/10-auth.conf " ` File . containsLine `
2014-07-18 20:45:40 +00:00
" !include auth-passwdfile.conf.ext "
2014-07-18 20:40:09 +00:00
` onChange ` Service . restarted " dovecot "
` describe ` " dovecot auth.conf "
2015-01-25 02:38:10 +00:00
& File . hasPrivContent dovecotusers ctx
2014-07-18 20:40:09 +00:00
` onChange ` ( dovecotusers ` File . mode `
combineModes [ ownerReadMode , groupReadMode ] )
2015-04-22 17:04:39 +00:00
& File . ownerGroup dovecotusers ( User " root " ) ( Group " dovecot " )
2014-07-18 04:36:21 +00:00
2015-01-25 02:38:10 +00:00
& Apt . installed [ " mutt " , " bsd-mailx " , " alpine " ]
2014-07-18 19:58:05 +00:00
2015-01-25 02:38:10 +00:00
& pinescript ` File . hasContent `
2014-07-18 19:58:05 +00:00
[ " #!/bin/sh "
, " # deployed with propellor "
, " set -e "
, " pass=$HOME/.pine-password "
, " if [ ! -e $pass ]; then "
, " \ t touch $pass "
, " fi "
2014-07-18 19:59:17 +00:00
, " chmod 600 $pass "
2014-07-18 19:58:05 +00:00
, " exec alpine -passfile $pass \ " $@ \ " "
]
2014-07-18 20:40:09 +00:00
` onChange ` ( pinescript ` File . mode `
combineModes ( readModes ++ executeModes ) )
2014-07-18 19:58:05 +00:00
` describe ` " pine wrapper script "
2015-01-25 02:38:10 +00:00
& " /etc/pine.conf " ` File . hasContent `
2014-09-11 02:56:42 +00:00
[ " # deployed with propellor "
, " inbox-path={localhost/novalidate-cert/NoRsh}inbox "
2014-07-18 19:58:05 +00:00
]
` describe ` " pine configured to use local imap server "
2014-09-08 14:56:08 +00:00
2015-01-25 02:38:10 +00:00
& Apt . serviceInstalledRunning " mailman "
2014-07-18 01:16:03 +00:00
where
ctx = Context " kitenet.net "
2014-07-18 19:58:05 +00:00
pinescript = " /usr/local/bin/pine "
2014-07-18 20:40:09 +00:00
dovecotusers = " /etc/dovecot/users "
2014-07-18 01:35:43 +00:00
2015-01-09 02:44:36 +00:00
-- Configures postfix to relay outgoing mail to kitenet.net, with
-- verification via tls cert.
2015-01-25 02:38:10 +00:00
postfixClientRelay :: Context -> Property HasInfo
2015-01-09 02:44:36 +00:00
postfixClientRelay ctx = Postfix . mainCfFile ` File . containsLines `
[ " relayhost = kitenet.net "
, " smtp_tls_CAfile = /etc/ssl/certs/joeyca.pem "
, " smtp_tls_cert_file = /etc/ssl/certs/postfix.pem "
, " smtp_tls_key_file = /etc/ssl/private/postfix.pem "
, " smtp_tls_loglevel = 0 "
, " smtp_use_tls = yes "
]
` describe ` " postfix client relay "
` onChange ` Postfix . dedupMainCf
` onChange ` Postfix . reloaded
` requires ` hasJoeyCAChain
` requires ` hasPostfixCert ctx
2015-01-09 03:02:06 +00:00
-- Configures postfix to have the dkim milter, and no other milters.
2015-01-25 02:38:10 +00:00
dkimMilter :: Property HasInfo
2015-01-09 03:02:06 +00:00
dkimMilter = Postfix . mainCfFile ` File . containsLines `
2015-01-10 01:21:06 +00:00
[ " smtpd_milters = inet:localhost:8891 "
2015-01-09 03:02:06 +00:00
, " non_smtpd_milters = inet:localhost:8891 "
, " milter_default_action = accept "
]
` describe ` " postfix dkim milter "
` onChange ` Postfix . dedupMainCf
` onChange ` Postfix . reloaded
` requires ` dkimInstalled
2015-01-09 02:44:36 +00:00
-- This does not configure postfix to use the dkim milter,
-- nor does it set up domainkey DNS.
2015-01-25 02:38:10 +00:00
dkimInstalled :: Property HasInfo
dkimInstalled = go ` onChange ` Service . restarted " opendkim "
where
go = propertyList " opendkim installed " $ props
& Apt . serviceInstalledRunning " opendkim "
& File . dirExists " /etc/mail "
& File . hasPrivContent " /etc/mail/dkim.key " ( Context " kitenet.net " )
2015-04-22 17:04:39 +00:00
& File . ownerGroup " /etc/mail/dkim.key " ( User " opendkim " ) ( Group " opendkim " )
2015-01-25 02:38:10 +00:00
& " /etc/default/opendkim " ` File . containsLine `
" SOCKET= \ " inet:8891@localhost \ " "
& " /etc/opendkim.conf " ` File . containsLines `
[ " KeyFile /etc/mail/dkim.key "
, " SubDomains yes "
, " Domain * "
, " Selector mail "
]
2015-01-09 01:41:55 +00:00
-- This is the dkim public key, corresponding with /etc/mail/dkim.key
-- This value can be included in a domain's additional records to make
-- it use this domainkey.
domainKey :: ( BindDomain , Record )
domainKey = ( RelDomain " mail._domainkey " , TXT " v=DKIM1; k=rsa; t=y; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCc+/rfzNdt5DseBBmfB3C6sVM7FgVvf4h1FeCfyfwPpVcmPdW6M2I+NtJsbRkNbEICxiP6QY2UM0uoo9TmPqLgiCCG2vtuiG6XMsS0Y/gGwqKM7ntg/7vT1Go9vcquOFFuLa5PnzpVf8hB9+PMFdS4NPTvWL2c5xxshl/RJzICnQIDAQAB " )
2015-01-25 02:38:10 +00:00
hasJoeyCAChain :: Property HasInfo
2014-07-18 01:35:43 +00:00
hasJoeyCAChain = " /etc/ssl/certs/joeyca.pem " ` File . hasPrivContentExposed `
Context " joeyca.pem "
2014-07-22 19:25:07 +00:00
2015-01-25 02:38:10 +00:00
hasPostfixCert :: Context -> Property HasInfo
2015-01-09 02:44:36 +00:00
hasPostfixCert ctx = combineProperties " postfix tls cert installed "
[ " /etc/ssl/certs/postfix.pem " ` File . hasPrivContentExposed ` ctx
, " /etc/ssl/private/postfix.pem " ` File . hasPrivContent ` ctx
]
2015-01-25 02:38:10 +00:00
kitenetHttps :: Property HasInfo
kitenetHttps = propertyList " kitenet.net https certs " $ props
& File . hasPrivContent " /etc/ssl/certs/web.pem " ctx
& File . hasPrivContent " /etc/ssl/private/web.pem " ctx
& File . hasPrivContent " /etc/ssl/certs/startssl.pem " ctx
& Apache . modEnabled " ssl "
2014-07-22 19:25:07 +00:00
where
ctx = Context " kitenet.net "
-- Legacy static web sites and redirections from kitenet.net to newer
-- sites.
2015-01-25 02:38:10 +00:00
legacyWebSites :: Property HasInfo
legacyWebSites = propertyList " legacy web sites " $ props
& Apt . serviceInstalledRunning " apache2 "
& Apache . modEnabled " rewrite "
& Apache . modEnabled " cgi "
& Apache . modEnabled " speling "
& userDirHtml
& kitenetHttps
& apacheSite " kitenet.net " True
2014-07-22 19:25:07 +00:00
-- /var/www is empty
[ " DocumentRoot /var/www "
, " <Directory /var/www> "
2014-07-22 19:27:44 +00:00
, " Options Indexes FollowSymLinks MultiViews ExecCGI Includes "
2014-07-22 19:25:07 +00:00
, " AllowOverride None "
2014-07-22 20:40:11 +00:00
, Apache . allowAll
2014-07-22 19:25:07 +00:00
, " </Directory> "
, " ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ "
-- for mailman cgi scripts
, " <Directory /usr/lib/cgi-bin> "
, " AllowOverride None "
, " Options ExecCGI "
2014-07-22 20:40:11 +00:00
, Apache . allowAll
2014-07-22 19:25:07 +00:00
, " </Directory> "
, " Alias /pipermail/ /var/lib/mailman/archives/public/ "
, " <Directory /var/lib/mailman/archives/public/> "
, " Options Indexes MultiViews FollowSymlinks "
, " AllowOverride None "
2014-07-22 20:40:11 +00:00
, Apache . allowAll
2014-07-22 19:25:07 +00:00
, " </Directory> "
, " Alias /images/ /usr/share/images/ "
, " <Directory /usr/share/images/> "
, " Options Indexes MultiViews "
, " AllowOverride None "
2014-07-22 20:40:11 +00:00
, Apache . allowAll
2014-07-22 19:25:07 +00:00
, " </Directory> "
, " RewriteEngine On "
, " # Force hostname to kitenet.net "
, " RewriteCond %{HTTP_HOST} !^kitenet \ \ .net [NC] "
, " RewriteCond %{HTTP_HOST} !^$ "
, " RewriteRule ^/(.*) http://kitenet \ \ .net/$1 [L,R] "
, " # Moved pages "
, " RewriteRule /programs/debhelper http://joeyh.name/code/debhelper/ [L] "
, " RewriteRule /programs/satutils http://joeyh.name/code/satutils/ [L] "
, " RewriteRule /programs/filters http://joeyh.name/code/filters/ [L] "
, " RewriteRule /programs/ticker http://joeyh.name/code/ticker/ [L] "
, " RewriteRule /programs/pdmenu http://joeyh.name/code/pdmenu/ [L] "
, " RewriteRule /programs/sleepd http://joeyh.name/code/sleepd/ [L] "
, " RewriteRule /programs/Lingua::EN::Words2Nums http://joeyh.name/code/Words2Nums/ [L] "
, " RewriteRule /programs/wmbattery http://joeyh.name/code/wmbattery/ [L] "
, " RewriteRule /programs/dpkg-repack http://joeyh.name/code/dpkg-repack/ [L] "
, " RewriteRule /programs/debconf http://joeyh.name/code/debconf/ [L] "
, " RewriteRule /programs/perlmoo http://joeyh.name/code/perlmoo/ [L] "
, " RewriteRule /programs/alien http://joeyh.name/code/alien/ [L] "
, " RewriteRule /~joey/blog/entry/(.+)-[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9].html http://joeyh.name/blog/entry/$1/ [L] "
, " RewriteRule /~anna/.* http://waldeneffect \ \ .org/ [R] "
, " RewriteRule /~anna/.* http://waldeneffect \ \ .org/ [R] "
, " RewriteRule /~anna http://waldeneffect \ \ .org/ [R] "
, " RewriteRule /simpleid/ http://openid.kitenet.net:8081/simpleid/ "
, " # Even the kite home page is not here any more! "
, " RewriteRule ^/$ http://www.kitenet.net/ [R] "
, " RewriteRule ^/index.html http://www.kitenet.net/ [R] "
, " RewriteRule ^/joey http://www.kitenet.net/joey/ [R] "
, " RewriteRule ^/joey/index.html http://www.kitenet.net/joey/ [R] "
, " RewriteRule ^/wifi http://www.kitenet.net/wifi/ [R] "
, " RewriteRule ^/wifi/index.html http://www.kitenet.net/wifi/ [R] "
, " # Old ikiwiki filenames for kitenet.net wiki. "
, " rewritecond $1 !^/~ "
, " rewritecond $1 !^/doc/ "
, " rewritecond $1 !^/pipermail/ "
, " rewritecond $1 !^/cgi-bin/ "
, " rewritecond $1 !.*/index$ "
, " rewriterule (.+).html$ $1/ [r] "
, " # Old ikiwiki filenames for joey's wiki. "
, " rewritecond $1 ^/~joey/ "
, " rewritecond $1 !.*/index$ "
, " rewriterule (.+).html$ http://kitenet.net/$1/ [L,R] "
, " # ~joey to joeyh.name "
, " rewriterule /~joey/(.*) http://joeyh.name/$1 [L] "
, " # Old familywiki location. "
, " rewriterule /~family/(.*).html http://family.kitenet.net/$1 [L] "
, " rewriterule /~family/(.*).rss http://family.kitenet.net/$1/index.rss [L] "
, " rewriterule /~family(.*) http://family.kitenet.net$1 [L] "
, " rewriterule /~kyle/bywayofscience(.*) http://bywayofscience.branchable.com$1 [L] "
, " rewriterule /~kyle/family/wiki/(.*).html http://macleawiki.branchable.com/$1 [L] "
, " rewriterule /~kyle/family/wiki/(.*).rss http://macleawiki.branchable.com/$1/index.rss [L] "
, " rewriterule /~kyle/family/wiki(.*) http://macleawiki.branchable.com$1 [L] "
]
2015-01-25 02:38:10 +00:00
& alias " anna.kitenet.net "
& apacheSite " anna.kitenet.net " False
2014-07-22 19:25:07 +00:00
[ " DocumentRoot /home/anna/html "
, " <Directory /home/anna/html/> "
, " Options Indexes ExecCGI "
, " AllowOverride None "
2014-07-22 20:40:11 +00:00
, Apache . allowAll
2014-07-22 19:25:07 +00:00
, " </Directory> "
]
2015-01-25 02:38:10 +00:00
& alias " sows-ear.kitenet.net "
& alias " www.sows-ear.kitenet.net "
& apacheSite " sows-ear.kitenet.net " False
2014-07-22 19:25:07 +00:00
[ " ServerAlias www.sows-ear.kitenet.net "
, " DocumentRoot /srv/web/sows-ear.kitenet.net "
, " <Directory /srv/web/sows-ear.kitenet.net> "
, " Options FollowSymLinks "
, " AllowOverride None "
2014-07-22 20:40:11 +00:00
, Apache . allowAll
2014-07-22 19:25:07 +00:00
, " </Directory> "
]
2015-01-25 02:38:10 +00:00
& alias " wortroot.kitenet.net "
& alias " www.wortroot.kitenet.net "
& apacheSite " wortroot.kitenet.net " False
2014-07-22 19:25:07 +00:00
[ " ServerAlias www.wortroot.kitenet.net "
, " DocumentRoot /srv/web/wortroot.kitenet.net "
, " <Directory /srv/web/wortroot.kitenet.net> "
, " Options FollowSymLinks "
, " AllowOverride None "
2014-07-22 20:40:11 +00:00
, Apache . allowAll
2014-07-22 19:25:07 +00:00
, " </Directory> "
]
2015-01-25 02:38:10 +00:00
& alias " creeksidepress.com "
& apacheSite " creeksidepress.com " False
2014-07-23 14:52:26 +00:00
[ " ServerAlias www.creeksidepress.com "
2014-07-23 14:54:21 +00:00
, " DocumentRoot /srv/web/www.creeksidepress.com "
, " <Directory /srv/web/www.creeksidepress.com> "
2014-07-23 14:52:26 +00:00
, " Options FollowSymLinks "
, " AllowOverride None "
, Apache . allowAll
, " </Directory> "
]
2015-01-25 02:38:10 +00:00
& alias " joey.kitenet.net "
& apacheSite " joey.kitenet.net " False
2014-09-11 03:01:19 +00:00
[ " DocumentRoot /var/www "
, " <Directory /var/www/> "
2014-07-22 19:25:07 +00:00
, " Options Indexes ExecCGI "
, " AllowOverride None "
2014-07-22 20:40:11 +00:00
, Apache . allowAll
2014-07-22 19:25:07 +00:00
, " </Directory> "
, " RewriteEngine On "
, " # Old ikiwiki filenames for joey's wiki. "
, " rewritecond $1 !.*/index$ "
, " rewriterule (.+).html$ http://joeyh.name/$1/ [l] "
, " rewritecond $1 !.*/index$ "
, " rewriterule (.+).rss$ http://joeyh.name/$1/index.rss [l] "
, " # Redirect all to joeyh.name. "
, " rewriterule (.*) http://joeyh.name$1 [r] "
]
2015-01-25 02:38:10 +00:00
userDirHtml :: Property HasInfo
2014-07-22 19:25:07 +00:00
userDirHtml = File . fileProperty " apache userdir is html " ( map munge ) conf
` onChange ` Apache . reloaded
` requires ` ( toProp $ Apache . modEnabled " userdir " )
where
munge = replace " public_html " " html "
conf = " /etc/apache2/mods-available/userdir.conf "
2015-01-25 02:38:10 +00:00