On 02/28/13 12:37 PM, [email protected] wrote:
https://cr.opensolaris.org/action/browse/pkg/timf/periodic-recv-3/

Thanks for taking a look!

src/svc/pkg-repositories-setup.xml
Yes, sorry - I meant milestone/network and system/filesystem/autofs.  I
don't believe the former needs to be listed as a dependency either.

Yep, fixed that.

Sounds good, though 'return $EXIT' as the last line, I think.

Yes, that last line should be 'return $EXIT'.

Oops (I point out a correction, then forget to make the correction :-)

I've made the other changes you suggested, and fixed the nits.

src/svc/svc-pkg-repositories-setup

        Line 62 - Not sure what I was thinking previously. The old code
        where you saved the exist status from the "$ZFS allow" before
        calling $CHOWN was better. That said, perhaps it would be
        clearer to avoid the default setting of
        result=$SMF_EXIT_ERR_FATAL and instead explicitly 'exit
        $SMF_EXIT_ERR_FATAL' in the cases where the $ZFS create, allow
        or $CHOWN fail (with appropriate messaging?)

Sounds good. I'm now using pkg5_include.sh here, and calling check_failure() for each of those, returning $SMF_EXIT_OK otherwise. I've attached the minor changes, but give me a shout if you'd prefer to see another webrev.

        cheers,
                        tim

diff --git a/src/svc/pkg-repositories-setup.xml 
b/src/svc/pkg-repositories-setup.xml
--- a/src/svc/pkg-repositories-setup.xml
+++ b/src/svc/pkg-repositories-setup.xml
@@ -45,16 +45,6 @@
        <create_default_instance enabled='true' />
 
         <!--
-          Wait for network interfaces to be initialized.
-        -->
-        <dependency name='network'
-            grouping='require_all'
-            restart_on='error'
-            type='service'>
-            <service_fmri value='svc:/milestone/network:default'/>
-        </dependency>
-
-        <!--
           Wait for all local filesystems to be mounted.
         -->
         <dependency name='filesystem-local'
diff --git a/src/svc/pkg5_include.sh b/src/svc/pkg5_include.sh
--- a/src/svc/pkg5_include.sh
+++ b/src/svc/pkg5_include.sh
@@ -115,7 +115,7 @@
                EXIT=1
        fi
        $RM $CRONTAB_LOCKDIR/actual-crontab.$$
-       return $?
+       return $EXIT
 }
 
 #
@@ -140,8 +140,10 @@
        typeset new_crontab=$CRONTAB_LOCKDIR/pkg5-new-crontab.$$
        typeset current_crontab=$CRONTAB_LOCKDIR/pkg5-current-crontab.$$
 
+       #
        # adding a cron job is essentially just looking for an existing
        # entry, removing it, and appending a new one.
+       #
        acquire_crontab_lock
        $CRONTAB -l | $GREP -v "${CMD}" > $current_crontab
        $CP $current_crontab $new_crontab
diff --git a/src/svc/svc-pkg-mirror b/src/svc/svc-pkg-mirror
--- a/src/svc/svc-pkg-mirror
+++ b/src/svc/svc-pkg-mirror
@@ -96,8 +96,10 @@
            | $AWK '{print $NF}' | $SORT | $WC -l)
        REPOS=$($SVCPROP -p config/repository "$SVCNAME:*" \
            | $AWK '{print $NF}' | $SORT -u | $WC -l)
+       #
        # if the unique list of repositories is not the same as the
        # list of repositories, then we have duplicates.
+       #
        if [ "$ALL_REPOS" != "$REPOS" ]; then           
                return 1
        fi
@@ -119,9 +121,11 @@
        schedule=$($SVCPROP -p config/crontab_period $SMF_FMRI \
            | $SED -e 's/\\//g')
 
+       #
        # Validate the cron_period property value, checking that we have
        # exactly 5 fields, and that 'random' only appears in the 3rd
        # field.  We leave other validation up to cron(1).
+       #
        echo "$schedule" | $AWK '
                NF != 5 {
                        print "config/crontab_period property must contain 5 " \
@@ -140,9 +144,11 @@
        RAND=$(( ($RANDOM % 27) + 1 ))
        new_schedule=$(echo "$schedule" | $SED -e "s/random/$RAND/1")
        if [ "$new_schedule" != "$schedule" ]; then
+               #
                # Save the schedule in the instance. Note that this
                # will not appear in the running instance until the
                # refresh method has fired.
+               #
                new_schedule=$(echo $new_schedule| $SED -e 's/ /\\ /g')
                $SVCCFG -s $SMF_FMRI setprop \
                    config/crontab_period = astring: \"$new_schedule\"
@@ -369,20 +375,17 @@
        echo "$TSTAMP: $SMF_FMRI updates to $repo from $origin :" \
            >> $LOG
 
-       if [ -n "$key" ]&&  [ -n "$cert" ]; then
+       if [ -n "$key" ] && [ -n "$cert" ]; then
                key="--key $key"
                cert="--cert $cert"
        fi
        # show the command we're running
        if [ "$debug_flag" = "true" ] ; then
                echo $PKGRECV -s $origin -c "$cachedir"/$instance \
-                   -d "$repo" -m all-timestamps \
-                   $key \
-                   $cert '*'
+                   -d "$repo" -m all-timestamps $key $cert '*'
        fi
        $PKGRECV -s $origin -c "$cachedir"/$instance -d "$repo" \
-           -m all-timestamps $key $cert '*' \
-           >  $LOG.tmp 2>&1
+           -m all-timestamps $key $cert '*' >  $LOG.tmp 2>&1
        EXIT=$?
 
        if [ "$debug_flag" = "true" ]; then
diff --git a/src/svc/svc-pkg-repositories-setup 
b/src/svc/svc-pkg-repositories-setup
--- a/src/svc/svc-pkg-repositories-setup
+++ b/src/svc/svc-pkg-repositories-setup
@@ -25,6 +25,7 @@
 # Load SMF constants and functions
 . /lib/svc/share/smf_include.sh
 . /lib/svc/share/fs_include.sh
+. /lib/svc/share/pkg5_include.sh
 
 CHOWN=/usr/bin/chown
 ZFS=/usr/sbin/zfs
@@ -53,17 +54,19 @@
                fi
                DS="$rpool/VARSHARE/pkg/repositories"
                $ZFS create -p $DS
-               if [ $? -eq 1 ]; then
-                       echo "Unable to create $DS"
-                       exit $SMF_EXIT_ERR_FATAL
-               fi
+               check_failure $? "Unable to create $DS" $SMF_FMRI exit
+
                $ZFS allow pkg5srv create,mount,snapshot "$DS"
-               if [ $? -eq 0 ]; then
-                       exit $SMF_EXIT_OK
-               fi
+               check_failure $? \
+                   "Unable to delegate ZFS permissions on $DS" \
+                   $SMF_FMRI exit
+
                $CHOWN pkg5srv:pkg5srv /var/share/pkg/repositories
+               check_failure $? \
+                   "Unable to chown /var/share/pkg/repositories" \
+                   $SMF_FMRI exit
        fi
-        ;;
+       ;;
 esac
 
-exit $result
+exit $SMF_EXIT_OK
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to