2195N/A#!/sbin/sh
2195N/A#
2195N/A# CDDL HEADER START
2195N/A#
2195N/A# The contents of this file are subject to the terms of the
2195N/A# Common Development and Distribution License (the "License").
2195N/A# You may not use this file except in compliance with the License.
2195N/A#
2195N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2195N/A# or http://www.opensolaris.org/os/licensing.
2195N/A# See the License for the specific language governing permissions
2195N/A# and limitations under the License.
2195N/A#
2195N/A# When distributing Covered Code, include this CDDL HEADER in each
2195N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2195N/A# If applicable, add the following below this CDDL HEADER, with the
2195N/A# fields enclosed by brackets "[]" replaced with your own identifying
2195N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2195N/A#
2195N/A# CDDL HEADER END
2195N/A#
2195N/A#
2507N/A# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
2195N/A#
2195N/A
2195N/A# Standard prolog
2195N/A#
2195N/A. /lib/svc/share/smf_include.sh
2195N/A. /lib/svc/share/net_include.sh
2195N/A
2195N/AEXECFILE="/usr/lib/inet/ptpd"
2195N/A
2195N/Aif [ -z $SMF_FMRI ]; then
2195N/A echo "SMF framework variables are not initialized."
2195N/A exit $SMF_EXIT_ERR_NOSMF
2195N/Afi
2195N/A
2195N/A#
2195N/A# get_prop fmri propname
2195N/A#
2195N/Aget_prop () {
2195N/A VALUE="`$SVCPROP -cp config/$1 $SMF_FMRI 2>/dev/null`"
2195N/A # Empty astring_list values show up as "" - do not return this.
2195N/A if [ "$VALUE" != "\"\"" ]; then
2195N/A echo $VALUE
2195N/A fi
2195N/A}
2195N/A
2195N/Aerrlog () {
2195N/A echo $1 >&2
2195N/A}
2195N/A
2195N/A#Do not refresh IGMP group
2195N/ACMD_LINE_ARGS=" -j"
2195N/A
2195N/ALISTEN_IFNAME="`get_prop listen_ifname`"
2195N/Aif [ -n "$LISTEN_IFNAME" ]; then
2195N/A CMD_LINE_ARGS="$CMD_LINE_ARGS -b $LISTEN_IFNAME"
2195N/Afi
2195N/A
2195N/ANODE_TYPE="`get_prop node_type`"
2195N/Aif [ -n "$NODE_TYPE" ]; then
2195N/A if [ "$NODE_TYPE" = "master" ]; then
2195N/A CMD_LINE_ARGS="$CMD_LINE_ARGS -W"
2195N/A elif [ "$NODE_TYPE" = "slave" ]; then
2195N/A CMD_LINE_ARGS="$CMD_LINE_ARGS -g"
2195N/A else
2195N/A errlog "node_type needs to be either slave or master. See ptp (1M). Exiting."
2195N/A exit $SMF_EXIT_ERR_CONFIG
2195N/A fi
2195N/Aelse
2195N/A CMD_LINE_ARGS="$CMD_LINE_ARGS -g"
2195N/Afi
2195N/A
2195N/AUSE_HW="`get_prop use_hw`"
2195N/Aif [ "$USE_HW" = "true" ];then
2195N/A CMD_LINE_ARGS="$CMD_LINE_ARGS -K"
2195N/Afi
2195N/A
2195N/ADOMAIN="`get_prop domain`"
2195N/Aif [ "$DOMAIN" -gt 0 -a "$DOMAIN" -lt 4 ]; then
2195N/A CMD_LINE_ARGS="$CMD_LINE_ARGS -i $DOMAIN"
2195N/Afi
2195N/A
2195N/AANN_INTVL="`get_prop announce_interval`"
2195N/Aif [ "$ANN_INTVL" -gt 0 -a "$ANN_INTVL" -ne 2 ]; then
2195N/A CMD_LINE_ARGS="$CMD_LINE_ARGS -n $ANN_INTVL"
2195N/Afi
2195N/A
2195N/ASYNC_INTVL="`get_prop sync_interval`"
2195N/Aif [ "$SYNC_INTVL" -gt 0 -a "$SYNC_INTVL" -ne 1 ]; then
2195N/A CMD_LINE_ARGS="$CMD_LINE_ARGS -y $SYNC_INTVL"
2195N/Afi
2195N/A
2507N/AENABLE_LOGGING="`get_prop enable_logging`"
2195N/ALOGFILE="`get_prop logfile`"
2507N/Aif [ -n "$LOGFILE" -a "$ENABLE_LOGGING" = "true" ]; then
2195N/A CMD_LINE_ARGS="$CMD_LINE_ARGS -f $LOGFILE"
2195N/Afi
2195N/A
2195N/AOTHER_OPTIONS="`get_prop other_options`"
2195N/Aif [ -n "$OTHER_OPTIONS" ]; then
2195N/A CMD_LINE_ARGS="$CMD_LINE_ARGS $OTHER_OPTIONS"
2195N/Afi
2195N/A
2195N/A
2195N/A# start ptp daemon
2195N/A$EXECFILE $CMD_LINE_ARGS
2195N/Aexit $SMF_EXIT_OK