Commit b7270d1e authored by Vitaly Lipatov's avatar Vitaly Lipatov

add help

parent c8c8a6dc
...@@ -33,10 +33,61 @@ load_helper() ...@@ -33,10 +33,61 @@ load_helper()
load_helper evz-sh-functions load_helper evz-sh-functions
check_tty check_tty
phelp()
{
echo "$Descr
$Usage
Commands:
$(get_help HELPCMD)
Options:
$(get_help HELPOPT)
Examples:
# evz start ID ID ID
"
}
print_version()
{ {
echo "$*" echo "Etersoft vzctl wrapper version @VERSION@"
echo "Copyright (c) Etersoft 2017"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
} }
progname="${0##*/}"
Usage="Usage: $progname [options] [<command>] [params]..."
Descr="evz - vzctl wrapper"
progname="${0##*/}"
force=''
target=''
verbose=--verbose
case "$1" in
-h|--help|help) # HELPOPT: this help
phelp
exit
;;
-V|--version) # HELPOPT: print version
print_version
exit
;;
-q|--quiet) # HELPOPT: be silent
verbose=
shift
;;
-f|--force) # HELPOPT: override target
force=-f
shift
;;
esac
list_all() list_all()
{ {
vzlist -1 vzlist -1
...@@ -47,10 +98,12 @@ list_ALL() ...@@ -47,10 +98,12 @@ list_ALL()
vzlist -1 -a vzlist -1 -a
} }
# TODO: add all support for all cases
CMD=$1 CMD=$1
shift shift
case $CMD in case $CMD in
off) off) # HELPCMD: stop container(s) and disable start on boot
for i in "$@" ; do for i in "$@" ; do
info "Stopping $i ..." info "Stopping $i ..."
vzctl stop $i vzctl stop $i
...@@ -58,7 +111,7 @@ case $CMD in ...@@ -58,7 +111,7 @@ case $CMD in
vzctl set $i --onboot no --save vzctl set $i --onboot no --save
done done
;; ;;
on) on) # HELPCMD: enable start on boot and start container(s)
for i in "$@" ; do for i in "$@" ; do
info "Starting $i ..." info "Starting $i ..."
# TODO: check if enabled # TODO: check if enabled
...@@ -66,34 +119,37 @@ case $CMD in ...@@ -66,34 +119,37 @@ case $CMD in
vzctl start $i vzctl start $i
done done
;; ;;
status) status) # HELPCMD: print container(s) status
info "Do $CMD for $* ..." info "Do $CMD for $* ..."
for i in "$@" ; do for i in "$@" ; do
vzctl $CMD $i vzctl $CMD $i
done done
;; ;;
compact) compact) # HELPCMD: do named operation on container(s)
for i in "$@" ; do for i in "$@" ; do
info "Do $CMD on $i ..." info "Do $CMD on $i ..."
vzctl $CMD $i vzctl $CMD $i
done done
;; ;;
stop) stop) # HELPCMD: stop container(s)
for i in "$@" ; do for i in "$@" ; do
info "Stopping $i ..." info "Stopping $i ..."
vzctl stop $i vzctl stop $i
done done
;; ;;
start) start) # HELPCMD: start container(s)
for i in "$@" ; do for i in "$@" ; do
info "Starting $i ..." info "Starting $i ..."
vzctl start $i vzctl start $i
done done
;; ;;
list) list) # HELPCMD: list avaiable container(s)
# TODO -q for just id list
# TODO -a support
# https://bugs.etersoft.ru/show_bug.cgi?id=12016
vzlist "$@" vzlist "$@"
;; ;;
exec) exec) # HELPCMD: execute command by list (all for all containers)
INCMD="$1" INCMD="$1"
shift shift
LIST="$*" LIST="$*"
...@@ -106,7 +162,7 @@ case $CMD in ...@@ -106,7 +162,7 @@ case $CMD in
vzctl exec $i "$INCMD" vzctl exec $i "$INCMD"
done done
;; ;;
info) info) # HELPCMD: print containers(s) info (vzlist like)
LIST="$*" LIST="$*"
[ "$1" = "all" ] && LIST="$(list_all)" [ "$1" = "all" ] && LIST="$(list_all)"
[ "$1" = "ALL" ] && LIST="$(list_ALL)" [ "$1" = "ALL" ] && LIST="$(list_ALL)"
...@@ -119,7 +175,7 @@ case $CMD in ...@@ -119,7 +175,7 @@ case $CMD in
vzlist $LIST -o ctid,ip,hostname,diskspace vzlist $LIST -o ctid,ip,hostname,diskspace
#done #done
;; ;;
destroy) destroy) # HELPCMD: destroy container(s) by list
echo "You request to destroy follow containers:" echo "You request to destroy follow containers:"
vzlist "$@" vzlist "$@"
#local response #local response
...@@ -133,6 +189,6 @@ case $CMD in ...@@ -133,6 +189,6 @@ case $CMD in
done done
;; ;;
*) *)
fatal "Unknow command '$CMD'" fatal "Unknow command '$CMD'. Use --help to get help."
;; ;;
esac esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment