#  -*- text -*-
#
#
#  $Id: 98c45c018515c4691227f1cdaff08fb7c6255ade $

#######################################################################
#
#  = The cron Virtual Server
#
#  The `cron` virtual server is an example of using `cron` style
#  functionality in FreeRADIUS.
#
#  == The Virtual Server
#
#  This is the `cron` virtual server.
#
server cron {
	#
	#  namespace:: The protocol / dictionary to use.
	#
	#  The `cron` functionality can be used with any protocol.
	#
	namespace = radius

	#
	#  You can have a `radius` subsection here. See the `default` virtual
	#  server for documentation.
	#

	#
	#  Create a `cron` listener. Note that leaving off the `cron` name
	#  will result in the protocol trying to open a socket!
	#
	listen cron {
		#
		#  type:: What type of packet that is read from `filename`, below.
		#
		#  The `type` should be a valid name for the current `namespace`.
		#
		type = Access-Request

		#
		#  transport:: What kind of cron functionality we are using.
		#
		#  For now, only `crontab` is supported.
		#
		transport = crontab

		#
		#  crontab:: Run `crontab` style jobs.
		#
		crontab {
			#
			#  timespec:: the `crontab` style time specification.
			#
			#  The fields are:
			#
			#  * minute (0-59)
			#  * hour (0-59)
			#  * day of month (1-31)
			#  * month of year (1-12)
			#  * day of week (0-6)
			#
			#  The allowed values follow the specification given in `man 5
			#  crontab`, or
			#  https://man7.org/linux/man-pages/man5/crontab.5.html
			#
			#  Multiple values can be given, separated by comma:
			#  * 1,2,3
			#
			#  Ranges can be specified
			#  * 1-4
			#  * `*`
			#
			#  Steps can be given for ranges:
			#  * 1-20/4
			#
			timespec = "* * * * *"

			#
			#  filename:: The file which is read, cached, and processed.
			#
			#  When the timer fires, the `cron` section sends a packet with the
			#  the contents of the file. The file is read when the server
			#  starts, and is not re-read again after that.
			#
			#  Any reply packet is discarded, and is not written anywhere. The
			#  `cron` functionality assumes that all of the work necessary for
			#  `cron` is done inside of the processing sections.
			#
			filename = /Users/alandekok/git/wrapper/freeradius-server/user_password
		}
	}

recv Access-Request {
	#
	#  Once a minute touch the "watchdog" file. An external process can
	#  then monitor this file.
	#
	#  If the watchdog file has not been modified in a few minutes, then
	#  the server is either blocked, or else it is not running.
	#
	%file.touch("${run_dir}/watchdog")
}

#
#  The missing `send` sections default to `noop`.
#

}
