Hi
I 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" &&
+ "${SELF[@]}" $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
Received on Thu Feb 9 10:45:09 2006