2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # T2 SDE: package/.../vserver/stone_mod_vserver.sh
6 # Copyright (C) 2004 - 2006 The T2 SDE Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
15 # [MAIN] 40 vserver Linux VServer Manager
20 [ -r $1 ] && head -n 1 $1 ||
echo "N/A"
25 [ -f $2 ] && value
="$( cat $2 )"
26 if gui_input
"Enter value for '$1' ($2):" "$value" value
; then
34 gui_edit_deleteable
() {
36 [ ! -s $2 ] && rm -f $2
40 [ -s $1 ] ||
echo '[N/A]'
43 vserver_conf_manage
() {
44 local server
="$1" errno
=0
45 local vdir=$CONFDIR/$server
47 while [ $errno -eq 0 ]; do
50 options
="$options 'Name ......: $( oneliner $vdir/name )' ''"
51 options
="$options 'Context ID.: $( oneliner $vdir/run )' ''"
52 options
="$options 'Directory .: $( readlink -f $vdir/vdir )' ''"
53 options
="$options 'Context ...: $( oneliner $vdir/context )' \
54 'gui_edit_oneliner context $vdir/context'"
55 options
="$options 'Namespace .: $( oneliner $vdir/namespace )' \
56 'gui_edit_oneliner namespace $vdir/namespace'"
58 options
="$options '' ''"
60 2.4*) options
="$options 'System Capabilities $( flag_if_empty $vdir/capabilities )' \
61 'gui_edit_deleteable capabilities $vdir/capabilities'"
63 *) options
="$options 'System Capabilities $( flag_if_empty $vdir/bcapabilities )' \
64 'gui_edit_deleteable bcapabilities $vdir/bcapabilities'"
67 options
="$options 'Context Capabilities $( flag_if_empty $vdir/ccapabilities )' \
68 'gui_edit_deleteable ccapabilities $vdir/ccapabilities'"
69 options
="$options 'Flags $( flag_if_empty $vdir/flags )' \
70 'gui_edit_deleteable flags $vdir/flags'"
71 options
="$options 'Personalities $( flag_if_empty $vdir/personality )' \
72 'gui_edit_deleteable personality $vdir/personality'"
73 options
="$options 'Scheduler Parameters $( flag_if_empty $vdir/schedule )' \
74 'gui_edit_deleteable schedule $vdir/schedule'"
76 options
="$options '' ''"
77 options
="$options 'Nice Level ...: $( oneliner $vdir/nice )' \
78 'gui_edit_oneliner nice $vdir/nice'"
79 options
="$options 'Default Shell : $( oneliner $vdir/shell )' \
80 'gui_edit_oneliner shell $vdir/shell'"
82 options
="$options '' ''"
83 options
="$options '==> uname (uts)' 'vserver_conf_uts_manage $server'"
85 2.4*) options
="$options '==> Resource Limits' 'vserver_conf_ul_manage $server'" ;;
86 *) options
="$options '==> Resource Limits' 'vserver_conf_rl_manage $server'" ;;
88 options
="$options '==> Network Interfaces' 'vserver_conf_if_manage $server'"
89 options
="$options '==> Applications' 'vserver_conf_apps_manage $server'"
90 options
="$options '==> Scripts' 'vserver_conf_sc_manage $server'"
92 options
="$options '' ''"
93 options
="$options 'mtab $( flag_if_empty $appsdir/init/mtab )' \
94 'gui_edit_deleteable init_mtab $vdir/apps/init/mtab'"
95 options
="$options 'fstab $( flag_if_empty $vdir/fstab )' \
96 'gui_edit fstab $vdir/fstab'"
97 options
="$options 'fstab.remote $( flag_if_empty $vdir/fstab.remote )' \
98 'gui_edit_deleteable fstab_remote $vdir/fstab.remote'"
100 eval "gui_menu vserver_conf 'VServer \`$server\` Configuration' $options"
105 vserver_conf_uts_manage
() {
106 local server
="$1" errno
=0
107 local utsdir
=$CONFDIR/$server/uts
109 while [ $errno -eq 0 ]; do
112 options
="$options 'Context Name .: $( oneliner $utsdir/context )' 'gui_edit_oneliner context $utsdir/context'"
113 options
="$options 'Node Name ....: $( oneliner $utsdir/nodename )' 'gui_edit_oneliner machine $utsdir/nodename'"
114 options
="$options 'Domain Name ..: $( oneliner $utsdir/domainname )' 'gui_edit_oneliner domainname $utsdir/domainname'"
115 options
="$options 'Machine Type .: $( oneliner $utsdir/machine )' 'gui_edit_oneliner machine $utsdir/machine'"
116 options
="$options 'Sysname ......: $( oneliner $utsdir/sysname )' 'gui_edit_oneliner machine $utsdir/sysname'"
117 options
="$options 'OS Release ...: $( oneliner $utsdir/release )' 'gui_edit_oneliner machine $utsdir/release'"
118 options
="$options 'OS Version ...: $( oneliner $utsdir/version )' 'gui_edit_oneliner machine $utsdir/version'"
120 eval "gui_menu vserver_conf_uts 'VServer \`$server\` uname Configuration' $options"
125 vserver_conf_apps_manage
() {
126 local server
="$1" errno
=0
127 local appsdir
=$CONFDIR/$server/apps
129 while [ $errno -eq 0 ]; do
131 options
="$options '$server/apps/init/' ''"
132 options
="$options ' - style ..........: $( oneliner $appsdir/init/style )' \
133 'gui_edit_oneliner init_style $appsdir/init/style'"
134 options
="$options ' - mark ...........: $( oneliner $appsdir/init/mark )' \
135 'gui_edit_oneliner init_mark $appsdir/init/mark'"
136 options
="$options ' - tty ............: $( readlink -f $appsdir/init/tty 2> /dev/null )' ''"
137 options
="$options ' - runlevel .......: $( oneliner $appsdir/init/runlevel )' \
138 'gui_edit_oneliner init_runlevel $appsdir/init/runlevel'"
139 options
="$options ' - runlevel.start .: $( oneliner $appsdir/init/runlevel.start )' \
140 'gui_edit_oneliner init_runlevel_start $appsdir/init/runlevel.start'"
141 options
="$options ' - runlevel.stop ..: $( oneliner $appsdir/init/runlevel.stop )' \
142 'gui_edit_oneliner init_runlevel_stop $appsdir/init/runlevel.stop'"
144 options
="$options '' ''"
145 options
="$options ' * depends $( flag_if_empty $appsdir/init/depends )' \
146 'gui_edit_deleteable init_depends $appsdir/init/depends'"
147 options
="$options ' * killseq $( flag_if_empty $appsdir/init/killseq )' \
148 'gui_edit_deleteable init_killseq $appsdir/init/killseq'"
150 options
="$options ' * cmd.prepare $( flag_if_empty $appsdir/init/cmd.prepare )' \
151 'gui_edit_deleteable init_prepare $appsdir/init/cmd.prepare'"
152 options
="$options ' * cmd.start $( flag_if_empty $appsdir/init/cmd.start )' \
153 'gui_edit_deleteable init_start $appsdir/init/cmd.start'"
154 options
="$options ' * cmd.stop $( flag_if_empty $appsdir/init/cmd.stop )' \
155 'gui_edit_deleteable init_stop $appsdir/init/cmd.stop'"
157 if [ -e $appsdir/init
/sync
]; then
158 options
="$options ' * cmd.start-sync $( flag_if_empty $appsdir/init/cmd.start-sync )' \
159 'gui_edit_deleteable init_start_sync $appsdir/init/cmd.start-sync'"
160 options
="$options ' * cmd.stop-sync $( flag_if_empty $appsdir/init/cmd.stop-sync )' \
161 'gui_edit_deleteable init_stop_sync $appsdir/init/cmd.stop-sync'"
164 eval "gui_menu vserver_conf_uts 'VServer \`$server\` Applications Configuration' $options"
169 vserver_conf_rl_manage
() {
170 local server
="$1" errno
=0
171 local rldir
=$CONFDIR/$server/rlimits
173 while [ $errno -eq 0 ]; do
175 options
="$options 'resource $( flag_if_empty $rldir/resource )' \
176 'gui_edit_deleteable resource $rldir/resource'"
177 options
="$options 'resource.min $( flag_if_empty $rldir/resource.min )' \
178 'gui_edit_deleteable resource $rldir/resource.min'"
179 options
="$options 'resource.hard $( flag_if_empty $rldir/resource.hard )' \
180 'gui_edit_deleteable resource $rldir/resource.hard'"
181 options
="$options 'resource.soft $( flag_if_empty $rldir/resource.soft )' \
182 'gui_edit_deleteable resource $rldir/resource.soft'"
183 eval "gui_menu vserver_conf_rl 'VServer \`$server\` (2.6) Resource Limits Configuration' $options"
188 vserver_conf_ul_manage
() {
189 local server
="$1" errno
=0
190 local rldir
=$CONFDIR/$server/ulimits
192 while [ $errno -eq 0 ]; do
194 options
="$options 'resource $( flag_if_empty $rldir/resource )' \
195 'gui_edit_deleteable resource $rldir/resource'"
196 options
="$options 'resource.hard $( flag_if_empty $rldir/resource.hard )' \
197 'gui_edit_deleteable resource $rldir/resource.hard'"
198 options
="$options 'resource.soft $( flag_if_empty $rldir/resource.soft )' \
199 'gui_edit_deleteable resource $rldir/resource.soft'"
200 eval "gui_menu vserver_conf_ul 'VServer \`$server\` (2.4) Resource Limits Configuration' $options"
205 vserver_conf_sc_manage
() {
206 local server
="$1" errno
=0
207 local scdir
=$CONFDIR/$server/scripts
209 while [ $errno -eq 0 ]; do
211 eval "gui_menu vserver_conf_uts 'VServer \`$server\` uname Configuration' $options"
216 vserver_conf_if_manage
() {
217 local server
="$1" errno
=0
218 local ifdir
=$CONFDIR/$server/interfaces
220 while [ $errno -eq 0 ]; do
221 local options
= iface
=
222 options
="$options 'default broadcast ..: $( oneliner $ifdir/bcast )' 'gui_edit_oneliner bcast $ifdir/bcast'"
223 options
="$options 'default device .....: $( oneliner $ifdir/dev )' 'gui_edit_oneliner device $ifdir/dev'"
224 options
="$options 'default netmask ....: $( oneliner $ifdir/prefix )' 'gui_edit_oneliner prefix $ifdir/prefix'"
225 options
="$options 'default scope ......: $( oneliner $ifdir/scope )' 'gui_edit_oneliner scope $ifdir/scope'"
226 for iface
in $
( cd $ifdir; ls -1 ); do
227 if [ -d $ifdir/$iface/ ]; then
228 options
="$options '' ''"
229 if [ -e $ifdir/$iface/disabled
]; then
230 options
="$options 'interface/$iface: DISABLED' 'rm -f $ifdir/$iface/disabled'"
232 options
="$options 'interface/$iface: ENABLED' 'touch $ifdir/$iface/disabled'"
234 options
="$options ' broadcast ..: $( oneliner $ifdir/$iface/bcast )' \
235 'gui_edit_oneliner bcast $ifdir/$iface/bcast'"
236 options
="$options ' device .....: $( oneliner $ifdir/$iface/dev )' \
237 'gui_edit_oneliner dev $ifdir/$iface/dev'"
238 options
="$options ' ip .........: $( oneliner $ifdir/$iface/ip )' \
239 'gui_edit_oneliner ip $ifdir/$iface/ip'"
240 options
="$options ' netmask ....: $( oneliner $ifdir/$iface/prefix )' \
241 'gui_edit_oneliner prefix $ifdir/$iface/prefix'"
242 options
="$options ' scope ......: $( oneliner $ifdir/$iface/scope )' \
243 'gui_edit_oneliner scope $ifdir/$iface/scope'"
246 options
="$options '' ''"
247 options
="$options 'Add new interface' 'vserver_if_new $server'"
249 eval "gui_menu vserver_conf_uts 'VServer \`$server\` Network Interfaces Configuration' $options"
257 gui_input
"Enter a name for the new interface" '' iface
258 if [ "$iface" ]; then
259 mkdir
-p "$CONFDIR/$server/interfaces/$iface"
263 local server
= action
= errno
=
264 gui_input
"Enter a name for the new vserver" '' server
265 if [ "$server" ]; then
266 action
="vserver '$server' build -m skeleton --initstyle plain"
267 eval "$action"; errno
=$?
268 if [ $errno -eq 0 ]; then
269 vserver_conf_manage
"$server"
271 gui_message
"\"$action\" failed."
279 local servers
= server
=
281 while [ $errno -eq 0 ]; do
283 for server
in $
( ls -1 $CONFDIR); do
284 [ -d $CONFDIR/$server ] && servers
="$servers 'vserver: $server' 'vserver_conf_manage $server'"
287 [ "$servers" ] && servers
="$servers '' ''"
288 eval "gui_menu vserver 'Linux VServer Manager' $servers 'Create a new vserver' 'vserver_new'"