1 #!/bin/ksh -p
   2 #
   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #    
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #    
  20 # CDDL HEADER END
  21 #
  22 #
  23 # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  24 # Copyright 2015, Joyent, Inc.
  25 #
  26 # lx boot script.
  27 #
  28 # The arguments to this script are the zone name and the zonepath.
  29 #
  30 
  31 . /usr/lib/brand/shared/common.ksh
  32 
  33 ZONENAME=$1
  34 ZONEPATH=$2
  35 ZONEROOT=$ZONEPATH/root
  36 
  37 w_missing=$(gettext "Warning: \"%s\" is not installed in the global zone")
  38 
  39 arch=`uname -p`
  40 if [ "$arch" = "i386" ]; then
  41         ARCH32=i86
  42         ARCH64=amd64
  43 else
  44         echo "Unsupported architecture: $arch"
  45         exit 2
  46 fi
  47 
  48 #
  49 # Run the lx_support boot hook.
  50 #
  51 /usr/lib/brand/lx/lx_support boot $ZONEPATH $ZONENAME
  52 if (( $? != 0 )) ; then
  53         exit 1
  54 fi
  55 
  56 BRANDDIR=/native/usr/lib/brand/lx;
  57 EXIT_CODE=1
  58 
  59 #
  60 # Before we boot we validate and fix, if necessary, the required files within
  61 # the zone.  These modifications can be lost if a patch or upgrade is applied
  62 # within the zone, so we validate and fix the zone every time it boots.
  63 #
  64 
  65 #
  66 # Determine the distro.
  67 #
  68 distro=""
  69 if [[ $(zonecfg -z $ZONENAME info attr name=docker) =~ "value: true" ]]; then
  70         distro="docker"
  71 elif [[ -f $ZONEROOT/etc/redhat-release ]]; then
  72         distro="redhat"
  73 elif [[ -f $ZONEROOT/etc/lsb-release ]]; then
  74         if egrep -s Ubuntu $ZONEROOT/etc/lsb-release; then
  75                 distro="ubuntu"
  76         elif [[ -f $ZONEROOT/etc/debian_version ]]; then
  77                 distro="debian"
  78         fi
  79 elif [[ -f $ZONEROOT/etc/debian_version ]]; then
  80         distro="debian"
  81 elif [[ -f $ZONEROOT/etc/alpine-release ]]; then
  82         distro="busybox"
  83 fi
  84 
  85 [[ -z $distro ]] && fatal "Unsupported distribution!"
  86 
  87 #
  88 # Perform distro-specific customization.
  89 #
  90 . $(dirname $0)/lx_boot_zone_${distro}
  91 
  92 exit 0