[Vserver] Delete method for vserver command

2006-02-09 Thread Thomas Champagne
HiI added a delete method to the vserver command. To test it, patch the script vserver with this diff.@@ -43,6 +43,7 @@ restart ... restarts the specified vserver; this is the subsequent execution of a synchronized 'stop' and a 'start'
 condrestart ... restarts the vserver when it is running already+ delete ... deletes the vserver suexec user shell-command args* ... executes a command as the specified user in the vserver
 exec shell-command args*@@ -96,6 +97,21 @@ exit 0}+function delete()+{+ if test -z $OPTION_SILENT ; then+ read -p Are you sure to delete the vserver $vserver (y/N)  deleteok
+ if [[ ${deleteok} != [Yy] ]] ; then+ exit 2+ fi+ fi++ isVserverRunning $VSERVER_DIR + [EMAIL PROTECTED] $OPTION_SILENT --sync $vserver stop
++ rm -rf `readlink -f $VSERVER_DIR/vdir` $VSERVER_DIR+}+function suexec(){ . $__PKGLIBDIR/vserver.suexec@@ -203,7 +219,7 @@ shift 2 . $__PKGLIBDIR/vserver.$cmd
 ;;- (suexec|restart)+ (suexec|restart|delete) shift 2 $cmd $@ ;;During the developpement, I detect a bug for the method condrestart. The test, checking if the vserver runs, doesn't work and returns the following error : 
isVserverRunning: unary operator expected. So, the vserver is always started. I suggest this to correct it : -test ! isVserverRunning $VSERVER_DIR || restart+isVserverRunning $VSERVER_DIR  restart
Thomas

___
Vserver mailing list
Vserver@list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver


Re: [Vserver] Completion for vserver

2006-02-06 Thread Thomas Champagne
HiSo, the first line of the completion :have vserver-info  {: ${UTIL_VSERVER_VARS:=$(vserver-info - SYSINFO |grep prefix: | awk '{ print $2}')/lib/util-vserver/util-vserver-vars}
test -e $UTIL_VSERVER_VARS  {
. $UTIL_VSERVER_VARS. $_LIB_FUNCTIONS.Why the scripts vserver, vapt-get, vyum, vrpm, vserver-copy and others maybe, don't use this method to test the path of util-vserver-vars ?
Thomas2006/2/6, Andreas John

Hi Thomas!Well, you have the deeper insight in your script but would vote forreplacing this line: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}whith something based on
echo $(vserver-info - SYSINFO |grep prefix: | awk '{ print $2}')lib/util-vserver/util-vserver-varsWhat do you think? This way you would get all pathes as long asvserver-info is in the path (that should be always the case on running
hosts).rdds,AndreasP.S. You can replace the awk stuff by bash's internal regex handling.This was like ... eh ... ${i/foo/bar},${i/foo#bar} and such. Too busyto look it up now ...

Thomas Champagne wrote: Hi Andreas To test if the util-vserver command is installed, I've just copied the test at the beginning of the script vserver. I don't know if it is

 the good way to do it !! But this test is written in hard in the source code in the script vserver. What do we do ? Use this test or use the command vserver-info ?

 Thomas 2006/2/5, Andreas John Hi Thomas!Thomas Champagne wrote:After a weekend of shopping, I'm come back.
So, I create a page in the wiki :http://linux-vserver.org/Vserver+Completion
And I create a link in the home page.
If you want others completions for others commands, tell it me.ThomasWell, I would prefer if you would use vserver-info - SYSINFO to figure out where 'util-vserver-vars' resides, 
e.g. in my case it's not on/usr/lib/util-vserver/util-vserver-vars, but/usr/local/lib/util-vserver/util-vserver-vars.Rgds,AndreasP.S. Nice work anyway! I use it in production!
--Andreas Johnnet-lab GmbHLuisenstrasse 30b63067 OffenbachTel: +49 69 85700331
http://www.net-lab.net


___
Vserver mailing list
Vserver@list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver


Re: [Vserver] Completion for vserver

2006-01-23 Thread Thomas Champagne
After a weekend of shopping, I'm come back.So, I create a page in the wiki :http://linux-vserver.org/Vserver+CompletionAnd I create a link in the home page.
If you want others completions for others commands, tell it me.Thomas2006/1/20, Herbert Poetzl 
[EMAIL PROTECTED]:
On Fri, Jan 20, 2006 at 05:04:52PM +0100, Thomas Champagne wrote: Hi To learn bash, I decided to create the completion for vserver's commands.great! So, I send you the first release here because I don't know
 where I can post it.that's the right place, and if you can, it might makesense to put it up somewhere and link it from thewiki (if not, just let me know and I'll put it somewhere) This release support only the command vserver.
 For test it, push the source in your .bashrc or put it in the file /etc/bash_completion.d/vserver (Debian).thanks,Herbert In waiting of your comments. Thomas



___
Vserver mailing list
Vserver@list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver


[Vserver] Completion for vserver

2006-01-20 Thread Thomas Champagne
Hi To learn bash, I decided to create the completion for vserver's commands. So, I send you the first release here because I don't know where I can post it.This release support only the command vserver.
For test it, push the source in your .bashrc or put it in the file /etc/bash_completion.d/vserver (Debian).In waiting of your comments.Thomas--# Completion for the vserver command. Source this file (or on some systems
# add it to ~/.bash_completion and start a new shell) and bash's completion# mechanism will know all about vserver's options!# Known to work with bash 2.05a with programmable completion and extended# pattern matching enabled (use 'shopt -s extglob progcomp' to enable
# these if they are not already enabled).: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}test -e $UTIL_VSERVER_VARS  {. $UTIL_VSERVER_VARS. $_LIB_FUNCTIONS
_vserver(){ local cur cmds cmdOpts helpCmds names names_pipe func COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} # find available v-servers: # call function getAllVservers in vserver library
 getAllVservers names names_pipe=`echo [EMAIL PROTECTED] | sed 's/ /|/g'` # available commands cmds='start stop restart condrestart suexec exec enter chkconfig\ running status build unify pkg apt-get apt-config apt-cache\
 rpm pkgmgmt' # options (long and short name) cmdOpts='--help --version --debug --defaulttty -s --sync -v \ --verbose --silent --' # if the previous option is a single option
 helpCmds='--help|--version' if [[ ${COMP_WORDS[1]} == @($helpCmds) ]] ; then return 0 fi # search a verser's name for (( i=0; i  [EMAIL PROTECTED]; i++ )); do
 if [[ ${COMP_WORDS[i]} == @($names_pipe) ]]; then # it's found break fi done if (( $i  [EMAIL PROTECTED] )) ; then
 case ${COMP_WORDS[i+1]} in start) COMPREPLY=( $( compgen -W --rescue --rescue-cmd -- $cu r ) ) ;;
 # No completion for apt-config stop|restart|condrestart|enter|running|status|apt-config) ;; suexec) # I don't know how to do
 COMPREPLY=( $( compgen -W -- $cur ) ) ;; exec) # I don't know how to do COMPREPLY=( $( compgen -W  -- $cur ) )
 ;; build) COMPREPLY=( $( compgen -W  -- $cur ) ) ;; unify) COMPREPLY=( $( compgen -W -R -- $cur ) )
 ;; apt-get|apt-cache) func=${COMP_WORDS[i+1]//-/_} COMP_WORDS=( [EMAIL PROTECTED]:$((i+1))} ) COMP_CWORD=$((COMP_CWORD-i-1))
 _${func} ;; *) COMPREPLY=( $( compgen -W $cmds -- $cur ) ) ;; esac
 return 0 else COMPREPLY=( $( compgen -W [EMAIL PROTECTED] $cmdOpts -- $cur ) ) return 0 fi return 0}complete -F _vserver -o default vserver
}
___
Vserver mailing list
Vserver@list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver