#!/usr/bin/env cbsd
#v11.0.0
CBSDMODULE="bsdconf"
CIXARG=""
CIXOPTARG="jname"
MYDESC="cbsd tzsetup wrapper"
ADDHELP="
${H3_COLOR}Description${N0_COLOR}:

 Wrapper for tzsetup(8) to configure timezone inside a jail or host system.

${H3_COLOR}Options${N0_COLOR}:

 ${N2_COLOR}jname=${N0_COLOR} - target jail. If omitted, operates on host.

${H3_COLOR}Examples${N0_COLOR}:

 # cbsd tzsetup
 # cbsd tzsetup jname=myjail

${H3_COLOR}See also${N0_COLOR}:

 cbsd service --help

"

. ${subrdir}/nc.subr
cixinit
cixinit

. ${system}

if [ -n "${jname}" ]; then
	. ${subrdir}/rcconf.subr
	[ $? -eq 1 ] && err 1 "${N1_COLOR}No such jail: ${N2_COLOR}${jname}${N0_COLOR}"
	[ ${jid} -eq 0 ] && err 1 "Jail is not running"
else
	data="/"
fi

/usr/sbin/tzsetup -C ${data} ${@}
exec /usr/sbin/tzsetup -r
