svc-pkg-repositories-setup revision 2867
2867N/A#!/usr/bin/ksh -p
2867N/A#
2867N/A# CDDL HEADER START
2867N/A#
2867N/A# The contents of this file are subject to the terms of the
2867N/A# Common Development and Distribution License (the "License").
2867N/A# You may not use this file except in compliance with the License.
2867N/A#
2867N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2867N/A# or http://www.opensolaris.org/os/licensing.
2867N/A# See the License for the specific language governing permissions
2867N/A# and limitations under the License.
2867N/A#
2867N/A# When distributing Covered Code, include this CDDL HEADER in each
2867N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2867N/A# If applicable, add the following below this CDDL HEADER, with the
2867N/A# fields enclosed by brackets "[]" replaced with your own identifying
2867N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2867N/A#
2867N/A# CDDL HEADER END
2867N/A#
2867N/A# Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
2867N/A#
2867N/A
2867N/A# Load SMF constants and functions
2867N/A. /lib/svc/share/smf_include.sh
2867N/A. /lib/svc/share/fs_include.sh
2867N/A. /lib/svc/share/pkg5_include.sh
2867N/A
2867N/ACHOWN=/usr/bin/chown
2867N/AZFS=/usr/sbin/zfs
2867N/A
2867N/Aresult=$SMF_EXIT_ERR_FATAL
2867N/A
2867N/Acase "$1" in
2867N/A'start')
2867N/A # check if we already have a mounted /var/share/pkg/repositories
2867N/A readmnttab /var/share/pkg/repositories < /etc/mnttab
2867N/A if [ "$fstype" = zfs ] ; then
2867N/A exit $SMF_EXIT_OK
2867N/A else
2867N/A rootistmpmnt=0
2867N/A readmnttab / < /etc/mnttab
2867N/A if [ "$fstype" = zfs ] ; then
2867N/A #
2867N/A # $special gets set by readmnttab in
2867N/A # /lib/svc/share/fs_include.sh
2867N/A #
2867N/A be=$special
2867N/A rpool=$(print $be | cut -d / -f1)
2867N/A else
2867N/A # we're on a LiveCD, so exit immediately.
2867N/A exit $SMF_EXIT_OK
2867N/A fi
2867N/A DS="$rpool/VARSHARE/pkg/repositories"
2867N/A $ZFS create -p $DS
2867N/A check_failure $? "Unable to create $DS" $SMF_FMRI exit
2867N/A
2867N/A $ZFS allow pkg5srv create,mount,snapshot "$DS"
2867N/A check_failure $? \
2867N/A "Unable to delegate ZFS permissions on $DS" \
2867N/A $SMF_FMRI exit
2867N/A
2867N/A $CHOWN pkg5srv:pkg5srv /var/share/pkg/repositories
2867N/A check_failure $? \
2867N/A "Unable to chown /var/share/pkg/repositories" \
2867N/A $SMF_FMRI exit
2867N/A fi
2867N/A ;;
2867N/Aesac
2867N/A
2867N/Aexit $SMF_EXIT_OK