Print this page
Kayak uses sudo with variable set (and sudoers set)


  11 # or http://www.opensolaris.org/os/licensing.
  12 # See the License for the specific language governing permissions
  13 # and limitations under the License.
  14 #
  15 # When distributing Covered Code, include this CDDL HEADER in each
  16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17 # If applicable, add the following below this CDDL HEADER, with the
  18 # fields enclosed by brackets "[]" replaced with your own identifying
  19 # information: Portions Copyright [yyyy] [name of copyright owner]
  20 #
  21 # CDDL HEADER END
  22 #
  23 #
  24 # Copyright 2011-2012 OmniTI Computer Consulting, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 
  28 # We have to build as root to manipulate ZFS datasets
  29 export ROOT_OK=yes
  30 










  31 # Load support functions
  32 . ../../lib/functions.sh
  33 
  34 if [[ "$UID" != "0" ]]; then
  35     logerr "--- This script needs to be run as root."
  36 fi
  37 
  38 # We also need to be in the global zone to access the kernel binary
  39 if [[ `zonename` != "global" ]]; then
  40     logerr "--- This script must be run in the global zone."
  41 fi
  42 
  43 PROG=kayak
  44 VER=1.1
  45 VERHUMAN=$VER
  46 PKG=system/install/kayak
  47 SUMMARY="Kayak - network installer (server files)"
  48 DESC="Kayak is the network installer for OmniOS, using PXE, DHCP and HTTP"
  49 
  50 BUILD_DEPENDS_IPS="developer/versioning/git"


  86 
  87 build_miniroot() {
  88     if [[ -z "`zfs list $IMG_DSET`" ]]; then
  89         /sbin/zfs create $IMG_DSET
  90     fi
  91     pushd $CHECKOUTDIR/kayak > /dev/null || logerr "Cannot change to src dir"
  92     logmsg "Building miniroot"
  93     logcmd gmake BUILDSEND=$IMG_DSET DESTDIR=$DESTDIR install-tftp || \
  94         logerr "gmake failed"
  95 
  96     popd > /dev/null
  97 }
  98 
  99 init
 100 clone_source
 101 prep_build
 102 logmsg "Now building $PKG"
 103 build_server
 104 make_package kayak.mog
 105 clean_up






 106 
 107 PKG=system/install/kayak-kernel
 108 SUMMARY="Kayak - network installer (kernel, miniroot and pxegrub)"
 109 PKGE=$(url_encode $PKG)
 110 PKGD=${PKGE//%/_}
 111 DESTDIR=$DTMPDIR/${PKGD}_pkg
 112 DEPENDS_IPS=""
 113 
 114 logmsg "Now building $PKG"
 115 build_miniroot
 116 make_package
 117 clean_up






 118 
 119 # Vim hints
 120 # vim:ts=4:sw=4:et:


  11 # or http://www.opensolaris.org/os/licensing.
  12 # See the License for the specific language governing permissions
  13 # and limitations under the License.
  14 #
  15 # When distributing Covered Code, include this CDDL HEADER in each
  16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17 # If applicable, add the following below this CDDL HEADER, with the
  18 # fields enclosed by brackets "[]" replaced with your own identifying
  19 # information: Portions Copyright [yyyy] [name of copyright owner]
  20 #
  21 # CDDL HEADER END
  22 #
  23 #
  24 # Copyright 2011-2012 OmniTI Computer Consulting, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 
  28 # We have to build as root to manipulate ZFS datasets
  29 export ROOT_OK=yes
  30 
  31 if [[ "$UID" != 0 && ! -z $KAYAK_SUDO_BUILD ]]; then
  32        # Run sudo BEFORE functions.sh eats the parameters.
  33        # Installing OmniOS-on-demand should create an entry in /etc/sudoers.d/
  34        # to cover running this script under sudo.
  35        echo "Running again under sudo, currently UID = $UID, EUID = $EUID."
  36        export OLDUSER=`whoami`
  37        export KAYAK_SUDO_BUILD
  38        exec sudo -n ./build.sh $@
  39 fi
  40 
  41 # Load support functions
  42 . ../../lib/functions.sh
  43 
  44 if [[ "$UID" != "0" ]]; then
  45     logerr "--- This script needs to be run as root."
  46 fi
  47 
  48 # We also need to be in the global zone to access the kernel binary
  49 if [[ `zonename` != "global" ]]; then
  50     logerr "--- This script must be run in the global zone."
  51 fi
  52 
  53 PROG=kayak
  54 VER=1.1
  55 VERHUMAN=$VER
  56 PKG=system/install/kayak
  57 SUMMARY="Kayak - network installer (server files)"
  58 DESC="Kayak is the network installer for OmniOS, using PXE, DHCP and HTTP"
  59 
  60 BUILD_DEPENDS_IPS="developer/versioning/git"


  96 
  97 build_miniroot() {
  98     if [[ -z "`zfs list $IMG_DSET`" ]]; then
  99         /sbin/zfs create $IMG_DSET
 100     fi
 101     pushd $CHECKOUTDIR/kayak > /dev/null || logerr "Cannot change to src dir"
 102     logmsg "Building miniroot"
 103     logcmd gmake BUILDSEND=$IMG_DSET DESTDIR=$DESTDIR install-tftp || \
 104         logerr "gmake failed"
 105 
 106     popd > /dev/null
 107 }
 108 
 109 init
 110 clone_source
 111 prep_build
 112 logmsg "Now building $PKG"
 113 build_server
 114 make_package kayak.mog
 115 clean_up
 116 # Do extra cleaning up if we got run under sudo from ourselves.
 117 if [[ -z `echo $RPATH | grep http://` ]]; then
 118        OLDUSER=`ls -ltd $RPATH | awk '{print $3}'`
 119        logmsg "--- Re-chowning $RPATH to user $OLDUSER"
 120        chown -R $OLDUSER $RPATH
 121 fi
 122 
 123 PKG=system/install/kayak-kernel
 124 SUMMARY="Kayak - network installer (kernel, miniroot and pxegrub)"
 125 PKGE=$(url_encode $PKG)
 126 PKGD=${PKGE//%/_}
 127 DESTDIR=$DTMPDIR/${PKGD}_pkg
 128 DEPENDS_IPS=""
 129 
 130 logmsg "Now building $PKG"
 131 build_miniroot
 132 make_package
 133 clean_up
 134 # Do extra cleaning up if we got run under sudo from ourselves.
 135 if [[ -z `echo $RPATH | grep http://` ]]; then
 136        OLDUSER=`ls -ltd $RPATH | awk '{print $3}'`
 137        logmsg "--- Re-chowning $RPATH to user $OLDUSER"
 138        chown -R $OLDUSER $RPATH
 139 fi
 140 
 141 # Vim hints
 142 # vim:ts=4:sw=4:et: