- action=$1
- base=`basename $action`
- if [ "${base##*.}" == "disabled" ]; then
- enable="enable";
- else
- enable="disable";
- fi
- while true; do
- menuBox "action menu" "$action $first" \
- main "return to main menu" \
- view "view configuration" \
- xedit "launch external editor" \
- $enable "$enable action" \
- name "change the filename" \
- run "run this action now" \
- test "do a test run" \
- kill "remove this action"
- [ $? = 1 ] && return;
- result="$REPLY"
- case "$result" in
- "view") dialog --textbox $action 0 0;;
- "xedit") do_xedit $action;;
- "disable") do_disable $action; return;;
- "enable") do_enable $action; return;;
- "name") do_rename $action; return;;
- "run") do_run $action;;
- "test") do_run_test $action;;
- "kill") do_rm_action $action; return;;
- "main") return;;
- esac
- done
-}
-
-#####################################################
-## VSERVERS RELATED FUNCTIONS
-
-##
-## If vservers are not enabled, exit silently and set host_or_vservers to 'host'.
-## Else, have the user choose the target he/she wants to perform the backup on:
-## - host system only
-## - some vservers only
-## - both the host system and some vservers
-## Sets, respectively, $host_or_vservers to 'host', 'vservers', or 'both'
-## $host_or_vservers is unset when a new helper is run.
-## Returns 1 if cancelled.
-##
-host_or_vservers_chooser() {
- local title=$1
- # exit silently if vservers are not enabled
- if [ "$vservers" != "yes" ]; then
- host_or_vservers='host'
- return
- fi
- # if there is one, set the previously chosen item as the default
- [ -n "$host_or_vservers" ] && setDefault $host_or_vservers
- menuBox "$title - src" "Do you want to operate on the host system and/or on vservers?" \
- "host" "Host system only" \
- "vservers" "Vservers only" \
- "both" "Host system and Vservers"
- [ $? = 0 ] || return 1
- case $REPLY in
- "host")
- host_or_vservers='host'
- ;;
- "vservers")
- host_or_vservers='vservers'
- ;;
- "both")
- host_or_vservers='both'
- ;;
- esac
-}
-
-##
-## If the argument is the name of a vserver selected for backup (in
-## $vservers_chooser_vsnames), echoes 'on' and returns 0.
-## Else, echoes 'off' and returns 1.
-##
-vserver_is_selected() {
- local vserver=$1
- local vserver_is_selected=1
- local i
- for i in $vservers_chooser_vsnames ; do
- [ "$vserver" == "$i" ] && vserver_is_selected=0
- done
- if [ $vserver_is_selected = 0 ]; then
- echo on