txzonemgr.sh revision abddfefb3168362a915cd681eb5a6498ec6c9e09
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# This script provides a simple GUI for managing labeled zones.
# It takes no arguments, but provides contextual menus which
# provide appropriate choices. It must be run in the global
# zone as root.
export NSCD_PER_LABEL
export NSCD_INDICATOR
if [ -f $NSCD_INDICATOR ] ; then
fi
title="Labeled Zone Manager"
maxlabel=`chk_encodings -X 2>/dev/null`
if [[ ! -n $maxlabel ]]; then
fi
zonename=""
export zonename
if [ $? != 0 ]; then
console="Zone Console...\n"
fi
}
if [ $hexlabel ] ; then
else
label="Select Label...\n"
curlabel=...
fi
}
zonelist=""
if [ $q != $zonename ]; then
fi
done
if [[ -n $zonelist ]]; then
fi
}
if [[ -n $macstate ]]; then
permitrelabel="Deny Relabeling\n"
else
permitrelabel="Permit Relabeling\n"
fi
}
labelList=""
if [ $? != 0 ]; then
newlabel=`hextoalabel $p`
fi
done
alabel=$(echo $labelList|zenity --list \
--height=300 \
--width=400 \
if [[ -n $alabel ]]; then
if [[ -n $newlabel ]]; then
else
fi
fi
}
export ZONE_PATH
export ZONE_ETC_DIR
export IPNODES
export LIST
ERRORLIST=""
export ERRORLIST
# if using nscd-per-label then we have to be sure the global zone's
# hostname resolves because it is used for DISPLAY in X
export ghostname
if [[ -n "$1" ]] ; then
else
fi
# Rather than toggle on and off with NSCD_PER_LABEL, put the
# information in there and a sysadmin can remove it if necessary
# $DISPLAY will not work in X without global hostname
127.0.0.1* )
if [[ -z $ERRORLIST ]] ; then
ERRORLIST="$ghostname address 127.0.0.1 found in:\n"
fi
;;
"")
;;
*)
continue
;;
esac
done
fi
}
--height=300 \
if [[ -n $image ]]; then
if [[ -n $dataset ]]; then
fi
if [ ! -f /var/ldap/ldap_client_file ]; then
if [ $NSCD_PER_LABEL = 0 ] ; then
else
fi
fi
fi
}
--height=300 \
/usr/bin/gnome-terminal \
if [ ! -f /var/ldap/ldap_client_file ]; then
if [ $NSCD_PER_LABEL = 0 ] ; then
else
fi
fi
}
if [ $? != 0 ]; then
exit 1
fi
exit 1
fi
if [ -f /var/ldap/ldap_client_file ]; then
ldapaddress=`ldapclient list | \
profName=`ldapclient list | \
proxyPwd=`ldapclient list | \
proxyDN=`ldapclient list | \
fi
else
if [ $NSCD_PER_LABEL = 0 ] ; then
else
# had to put resolveXdisplay lower down for this case
fi
fi
if [[ -z $locale ]]; then
locale="C"
fi
#echo "root_password=$rootpwd" >> ${SYSIDCFG}
rm -f ${ZONE_ETC_DIR}/.UNCONFIGURED
if [ $NSCD_PER_LABEL = 1 ] ; then
fi
}
# if there is a zfs pool for zone
# create a new dataset for the zone
# This step is done automatically by zonecfg
# in Solaris Express 8/06 or newer
zfs create -o mountpoint=/zone/$zonename \
fi
/usr/bin/gnome-terminal \
}
# if there is an entry for this zone in tnzonecfg, remove it
# before deleting the zone.
if [ -n "${tnzone}" ]; then
fi
if [[ -n $dataset ]]; then
fi
}
nics=
do
if [ $? -eq 1 ]; then
continue
fi
i=${i%:} # Remove colon after interface name
if [ $? -eq 0 ]; then
continue
fi
done
}
cidr=
if [ $? != 0 ]; then
return;
fi
}
if [[ -z $nic ]]; then
return;
fi
if [[ -z $ipaddr ]]; then
return;
fi
if [[ -z $cidr ]]; then
return;
fi
zcfg="
add net
set address=${ipaddr}/${cidr}
set physical=$nic
end
commit
"
}
type=ignore
do
case $j in
inet) type=$j;;
zone) type=$j;;
*) continue ;;
esac;\
type=ignore;;
esac
done
if [ $ipaddr != 0.0.0.0 ]; then
else
template="..."
ipaddr="..."
fi
}
if [ $? = 0 ]; then
else
fi
}
if [ $? != 0 ]; then
return;
fi
if [[ -z $ipaddr ]]; then
if [ $? != 0 ]; then
return;
fi
fi
}
# Update hosts and ipnodes
if [[ -z $ipaddr ]]; then
return;
fi
if [ $? -eq 1 ]; then
fi
if [ $? -eq 1 ]; then
fi
}
while [ 1 -gt 0 ]; do
--height=300 \
if [ $? != 0 ]; then
break;
fi
--height=300 \
--width=450 \
if [ $? != 0 ]; then
continue
fi
break
done
}
}
}
zcfg="
set limitpriv=default,win_mac_read,win_mac_write,win_selection,win_dac_read,win_dac_write,file_downgrade_sl,file_upgrade_sl,sys_trans_label
commit
"
}
zcfg="
set limitpriv=default
commit
"
}
done
}
if [ $NSCD_PER_LABEL -ne 0 ] ; then
return
fi
if [[ $? -eq 1 ]]; then
zcfg="
add fs
set type=lofs
add options ro
end
add fs
set type=lofs
add options ro
end
commit
"
fi
}
# This routine is a toggle -- if we find it configured for global nscd,
# change to nscd-per-label and vice-versa.
#
# The user was presented with only the choice to CHANGE the existing
# configuration.
if [ $NSCD_PER_LABEL -eq 0 ] ; then
# this MUST be a regular file for svc-nscd to detect
else
export zonename
zonename=$i
done
fi
}
while [ 1 -gt 0 ]; do
do
if [ $? -eq 1 ]; then
continue
fi
nic=${i%:} # Remove colon after interface name
done
do
if [ $? -eq 1 ]; then
continue
fi
nic=${i%:} # Remove colon after interface name
done
--height=300 \
--width=450 \
if [[ -z $nic ]]; then
return
fi
# Clear list of commands
# Check for physical interface
if [ $? != 0 ]; then
else
if [ $? != 0 ]; then
unplumb="Remove Logical Interface\n"
bringup="Bring Up\n"
fi
else
bringdown="Bring Down\n"
fi
fi
else
settemplate="View Templates...\n"
share="Share\n"
fi
fi
command=$(echo ""\
$share \
$unplumb \
$bringup \
--height=300 \
" Create Logical Interface")\
" Set IP address...")\
addHost;;
" Share")\
" View Templates...")\
" Remove Logical Interface")\
" Bring Up")\
" Bring Down")\
*) continue;;
esac
done
}
ldapdomain=$(zenity --entry \
--width=400 \
ldapserver=$(zenity --entry \
--width=400 \
ldapserveraddr=$(zenity --entry \
--width=400 \
ldappassword=""
ldappassword=$(zenity --entry \
--width=400 \
ldappasswordconfirm=$(zenity --entry \
--width=400 \
done
ldapprofile=$(zenity --entry \
--width=400 \
--width=400 \
--height=250 \
if [ $? != 0 ]; then
return
fi
if [ $? -eq 1 ]; then
fi
if [ $? -eq 1 ]; then
fi
"{ ORS = \"\" } { for (i = 1; i < NF; i++) print \"dc=\"\\\$i\",\" }{ print \"dc=\"\\\$NF }"`
--width=500 \
--text="global zone will be LDAP client of $ldapserver"
ldapout=/tmp/ldapclient.$$
if [ $? -eq 0 ]; then
else
fi
--width=700 \
--height=300 \
}
# Loop for single-zone menu
if [[ ! -n $zonename ]]; then
return
fi
# Clear list of commands
stop=
copy=
delay=0
case $zonestate in
stop="Halt\n"; \
;;
stop="Halt\n" \
;;
if [[ -z $label ]]; then \
fi; \
addnet="Add Network...\n"
;;
copyCheck; \
console=; \
;;
;;
*)
;;
esac
command=$(echo ""\
$console \
$label \
$start \
$reboot \
$stop \
$clone \
$copy \
$install \
$ready \
$delete \
$addnet \
"Return to Main Menu" \
--height=300 \
" Zone Console...")
delay=2; \
/usr/bin/gnome-terminal \
" Select Label...")
" Ready")
" Boot")
" Halt")
" Reboot")
" Install...")
install;;
" Clone")
clone ;;
" Copy...")
copy ;;
" Uninstall")
" Delete")
return ;;
" Add Network...")
addNet ;;
" Permit Relabeling")
setMacPrivs ;;
" Deny Relabeling")
*)
return ;;
esac
done
}
# Main loop for top-level window
#
# are there any zfs pools?
if [ $? = 0 ]; then
# is there a zfs pool named "zone"?
if [ $? = 0 ]; then
# yes
else
# no, but is there a root pool?
if [ $rootfs = "zfs" ]; then
# yes, use it
if [ $? = 1 ]; then
fi
fi
fi
fi
export NSCD_OPT
while [ "${command}" != Exit ]; do
zonelist=""
done
NSCD_OPT="Configure per-zone name service"
else
NSCD_OPT="Unconfigure per-zone name service"
fi
zonename=""
topcommand=$(echo $zonelist|zenity --list \
--height=300 \
--width=500 \
)
if [[ ! -n $topcommand ]]; then
command=Exit
exit
fi
if [ "$topcommand" = "$NSCD_OPT" ]; then
continue
elif [ "$topcommand" = "Manage Network Interfaces..." ]; then
continue
elif [ "$topcommand" = "Exit" ]; then
command=Exit
exit
elif [ "$topcommand" = "Create a new zone..." ]; then
if [[ ! -n $zonename ]]; then
continue
fi
zcfg="
create -t SUNWtsoldef
set zonepath=/zone/$zonename
commit
"
# Now, go to the singleZone menu, using the global
# variable zonename, and continue with zone creation
continue
elif [ "$topcommand" = "Create LDAP Client..." ]; then
command=LDAPclient
continue
fi
# if the menu choice was a zonename, pop up zone menu
done