# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

description "Run the tlsdate daemon to set the system time"
author      "chromium-os-dev@chromium.org"

start on started system-services
stop on stopping system-services
respawn

script
  GOOGLE_CERTS=/usr/share/chromeos-ca-certificates
  mkdir -m 755 -p /var/cache/tlsdated
  # Make sure the timestamp file has the proper permissions.
  chmod 0644 /var/cache/tlsdated/timestamp || true
  # When it runs tlsdate, tlsdated stitches together an argument vector for it
  # as follows: it begins with everything supplied to it after the --, then
  # appends -H $host -p $port, and maybe -x $proxy if it has a proxy to use.
  exec tlsdated -v -- /usr/bin/tlsdate -v -C "$GOOGLE_CERTS" -l \
      2>&1 | logger -t tlsdate
end script
