zone_console.sh
Purpose
zone_console is a script to start or stop screen sessions for one, some
or all defined zones on a machine.
Back
to top
License
# CDDL HEADER START
#
# The contents of this file and the script are subject to the terms of
the
# Common Development and Distribution License, Version 1.0 only
# (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
# or http://www.opensolaris.org/os/licensing.
# 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
Back
to top
History
Version
|
Releasedate
|
Description
|
1.00
|
09/05/2009
|
initial release
|
|
|
|
|
|
|
Back
to top
Operating system
Solaris 10 and newer
Back
to top
Language / type
Kornshell Script
Back
to top
Prerequisites
Solaris Zone support must be installed
screen must be installed
The screen home page is: http://www.gnu.org/software/screen/
Back
to top
Usage
root@sol10:/tools/scripts# zone_console -h
[zone_console] Usage: /tools/scripts/zone_console [start {zone1 ...
zone#}|stop {zone1 ... zone#}|status {zone1 ...zone#}|{console} zone]
Back
to top
Examples
# retrieve the zone console screen session
status
root@sol10:/tools/scripts# zoneadm list -cv
ID
NAME
STATUS
PATH
BRAND IP
0
global
running
/
native shared
1 backupserver
running
/zones/backupserver
ipkg excl
2 dnsserver
running
/zones/dnsserver
ipkg excl
3 dhcpserver
running
/zones/dhcpserver
ipkg excl
4 installserver
running
/zones/installserver
ipkg excl
5 cvsserver
running
/zones/cvsserver
ipkg excl
- templatezone001 installed
/zones/templatezone001
ipkg excl
- compileserver installed
/zones/compileserver
ipkg excl
- mailserver
installed
/zones/mailserver
ipkg excl
- testserver
installed
/zones/testserver
ipkg excl
- developserver installed
/zones/developserver
ipkg excl
root@sol10:/tools/scripts# zone_console status
[zone_console] The screen session for the console of the zone
"backupserver" is NOT running
[zone_console] The screen session for the console of the zone
"dnsserver" is NOT running
[zone_console] The screen session for the console of the zone
"dhcpserver" is NOT running
[zone_console] The screen session for the console of the zone
"installserver" is NOT running
[zone_console] The screen session for the console of the zone
"cvsserver" is NOT running
[zone_console] The screen session for the console of the zone
"templatezone001" is NOT running
[zone_console] The screen session for the console of the zone
"compileserver" is NOT running
[zone_console] The screen session for the console of the zone
"mailserver" is NOT running
[zone_console] The screen session for the console of the zone
"testserver" is NOT running
[zone_console] The screen session for the console of the zone
"developserver" is NOT running
# start one screen session
root@sol10:/tools/scripts# zone_console start dnsserver
[zone_console] Starting the screen session for the console of the zone
"dnsserver" ...
root@sol10:/tools/scripts# zone_console status
[zone_console] The screen session for the console of the zone
"backupserver" is NOT running
[zone_console] The screen session for the console of the zone
"dnsserver" is running
[zone_console] The screen session for the console of the zone
"dhcpserver" is NOT running
[zone_console] The screen session for the console of the zone
"installserver" is NOT running
[zone_console] The screen session for the console of the zone
"cvsserver" is NOT running
[zone_console] The screen session for the console of the zone
"templatezone001" is NOT running
[zone_console] The screen session for the console of the zone
"compileserver" is NOT running
[zone_console] The screen session for the console of the zone
"mailserver" is NOT running
[zone_console] The screen session for the console of the zone
"testserver" is NOT running
[zone_console] The screen session for the console of the zone
"developserver" is NOT running
root@sol10:/tools/scripts# screen -list
There is a screen on:
2911.dnsserver_console (Detached)
1 Socket in /root/.screen.
# connect to a screen session with a
running zone console
root@sol10:/tools/scripts# zone_console dnsserver
[Connected to zone 'dnsserver' console]
dnsserver console login:
# start a screen session and connect to the
console
root@sol10:/tools/scripts# zone_console backupserver
[zone_console] Starting the screen session for the console of the zone
"backupserver" ...
[detached]
[Connected to zone 'backupserver' console]
backupserver console login:
# start the remaining screen session for
all zone consoles
root@sol10:/tools/scripts# zone_console status
[zone_console] The screen session for the console of the zone
"backupserver" is running
[zone_console] The screen session for the console of the zone
"dnsserver" is running
[zone_console] The screen session for the console of the zone
"dhcpserver" is NOT running
[zone_console] The screen session for the console of the zone
"installserver" is NOT running
[zone_console] The screen session for the console of the zone
"cvsserver" is NOT running
[zone_console] The screen session for the console of the zone
"templatezone001" is NOT running
[zone_console] The screen session for the console of the zone
"compileserver" is NOT running
[zone_console] The screen session for the console of the zone
"mailserver" is NOT running
[zone_console] The screen session for the console of the zone
"testserver" is NOT running
[zone_console] The screen session for the console of the zone
"developserver" is NOT running
root@sol10:/tools/scripts# zone_console start
[zone_console] Screen session for the console of the the zone
"backupserver" is already running
[zone_console] Screen session for the console of the the zone
"dnsserver" is already running
[zone_console] Starting the screen session for the console of the zone
"dhcpserver" ...
[zone_console] Starting the screen session for the console of the zone
"installserver" ...
[zone_console] Starting the screen session for the console of the zone
"cvsserver" ...
[zone_console] Starting the screen session for the console of the zone
"templatezone001" ...
[zone_console] Starting the screen session for the console of the zone
"compileserver" ...
[zone_console] Starting the screen session for the console of the zone
"mailserver" ...
[zone_console] Starting the screen session for the console of the zone
"testserver" ...
[zone_console] Starting the screen session for the console of the zone
"developserver" ...
root@sol10:/tools/scripts# zone_console status
[zone_console] The screen session for the console of the zone
"backupserver" is running
[zone_console] The screen session for the console of the zone
"dnsserver" is running
[zone_console] The screen session for the console of the zone
"dhcpserver" is running
[zone_console] The screen session for the console of the zone
"installserver" is running
[zone_console] The screen session for the console of the zone
"cvsserver" is running
[zone_console] The screen session for the console of the zone
"templatezone001" is running
[zone_console] The screen session for the console of the zone
"compileserver" is running
[zone_console] The screen session for the console of the zone
"mailserver" is running
[zone_console] The screen session for the console of the zone
"testserver" is running
[zone_console] The screen session for the console of the zone
"developserver" is running
# stop some screen sessions
root@sol10:/tools/scripts# zone_console stop mailserver compileserver
[zone_console] Stoping the screen session for the console of the zone
"mailserver" ...
[zone_console] Stoping the screen session for the console of the zone
"compileserver" ...
root@sol10:/tools/scripts# zone_console status
[zone_console] The screen session for the console of the zone
"backupserver" is running
[zone_console] The screen session for the console of the zone
"dnsserver" is running
[zone_console] The screen session for the console of the zone
"dhcpserver" is running
[zone_console] The screen session for the console of the zone
"installserver" is running
[zone_console] The screen session for the console of the zone
"cvsserver" is running
[zone_console] The screen session for the console of the zone
"templatezone001" is running
[zone_console] The screen session for the console of the zone
"compileserver" is NOT running
[zone_console] The screen session for the console of the zone
"mailserver" is NOT running
[zone_console] The screen session for the console of the zone
"testserver" is running
[zone_console] The screen session for the console of the zone
"developserver" is running
# stop all running screen sessions
root@sol10:/tools/scripts# zone_console stop
[zone_console] Stoping the screen session for the console of the zone
"backupserver" ...
[zone_console] Stoping the screen session for the console of the zone
"dnsserver" ...
[zone_console] Stoping the screen session for the console of the zone
"dhcpserver" ...
[zone_console] Stoping the screen session for the console of the zone
"installserver" ...
[zone_console] Stoping the screen session for the console of the zone
"cvsserver" ...
[zone_console] Stoping the screen session for the console of the zone
"templatezone001" ...
[zone_console] The screen session for the console of the zone
"compileserver" is NOT running
[zone_console] The screen session for the console of the zone
"mailserver" is NOT running
[zone_console] Stoping the screen session for the console of the zone
"testserver" ...
[zone_console] Stoping the screen session for the console of the zone
"developserver" ...
root@sol10:/tools/scripts# zone_console status
[zone_console] The screen session for the console of the zone
"backupserver" is NOT running
[zone_console] The screen session for the console of the zone
"dnsserver" is NOT running
[zone_console] The screen session for the console of the zone
"dhcpserver" is NOT running
[zone_console] The screen session for the console of the zone
"installserver" is NOT running
[zone_console] The screen session for the console of the zone
"cvsserver" is NOT running
[zone_console] The screen session for the console of the zone
"templatezone001" is NOT running
[zone_console] The screen session for the console of the zone
"compileserver" is NOT running
[zone_console] The screen session for the console of the zone
"mailserver" is NOT running
[zone_console] The screen session for the console of the zone
"testserver" is NOT running
[zone_console] The screen session for the console of the zone
"developserver" is NOT running
Back
to top
Notes
The name for the screen session used is in the format
<zonename>_console
e.g.
root@sol10:/tools/scripts# zoneadm list -cv
ID
NAME
STATUS
PATH
BRAND IP
0
global
running
/
native shared
1 backupserver
running
/zones/backupserver
ipkg excl
2 dnsserver
running
/zones/dnsserver
ipkg excl
3 dhcpserver
running
/zones/dhcpserver
ipkg excl
4 installserver
running
/zones/installserver
ipkg excl
5 cvsserver
running
/zones/cvsserver
ipkg excl
- templatezone001 installed
/zones/templatezone001
ipkg excl
- compileserver installed
/zones/compileserver
ipkg excl
- mailserver
installed
/zones/mailserver
ipkg excl
- testserver
installed
/zones/testserver
ipkg excl
- developserver installed
/zones/developserver
ipkg excl
root@sol10:/tools/scripts# screen -list
There are screens on:
3576.dnsserver_console (Detached)
3632.mailserver_console (Detached)
3603.cvsserver_console (Detached)
3594.installserver_console
(Detached)
3585.dhcpserver_console (Detached)
3623.compileserver_console
(Detached)
3567.backupserver_console
(Detached)
3612.templatezone001_console
(Detached)
3654.developserver_console
(Detached)
3645.testserver_console (Detached)
10 Sockets in /root/.screen.
Back
to top
Download
Download
zone_console
Back
to top