-- | Maintainer: Sean Whitton <spwhitton@spwhitton.name>

module Propellor.Property.Timezone where

import Propellor.Base
import qualified Propellor.Property.Apt as Apt
import qualified Propellor.Property.File as File

-- | A timezone from /usr/share/zoneinfo
type Timezone = String

-- | Sets the system's timezone
configured :: Timezone -> Property DebianLike
configured :: Timezone -> Property DebianLike
configured Timezone
zone = Timezone -> [Timezone] -> Property UnixLike
File.hasContent Timezone
"/etc/timezone" [Timezone
zone]
	forall x y. Combines x y => x -> y -> CombinedType x y
`onChange` Property DebianLike
update
	forall p. IsProp p => p -> Timezone -> p
`describe` (Timezone
zone forall a. [a] -> [a] -> [a]
++ Timezone
" timezone configured")
  where
	update :: CombinedType (Property DebianLike) (Property UnixLike)
update = Timezone -> [(Timezone, Timezone, Timezone)] -> Property DebianLike
Apt.reConfigure Timezone
"tzdata" forall a. Monoid a => a
mempty
		-- work around a bug in recent tzdata.  See
		-- https://bugs.launchpad.net/ubuntu/+source/tzdata/+bug/1554806/
		forall x y. Combines x y => x -> y -> CombinedType x y
`requires` Timezone -> Property UnixLike
File.notPresent Timezone
"/etc/localtime"