1252995Sdteske#!/bin/sh 2252995Sdteske#- 3252995Sdteske# Copyright (c) 2012-2013 Devin Teske 4252995Sdteske# All rights reserved. 5252995Sdteske# 6252995Sdteske# Redistribution and use in source and binary forms, with or without 7252995Sdteske# modification, are permitted provided that the following conditions 8252995Sdteske# are met: 9252995Sdteske# 1. Redistributions of source code must retain the above copyright 10252995Sdteske# notice, this list of conditions and the following disclaimer. 11252995Sdteske# 2. Redistributions in binary form must reproduce the above copyright 12252995Sdteske# notice, this list of conditions and the following disclaimer in the 13252995Sdteske# documentation and/or other materials provided with the distribution. 14252995Sdteske# 15252995Sdteske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16252995Sdteske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17252995Sdteske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18252995Sdteske# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19252995Sdteske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20252995Sdteske# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21252995Sdteske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22252995Sdteske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23252995Sdteske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24252995Sdteske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25252995Sdteske# SUCH DAMAGE. 26252995Sdteske# 27252995Sdteske# $FreeBSD$ 28252995Sdteske# 29252995Sdteske############################################################ INCLUDES 30252995Sdteske 31252995SdteskeBSDCFG_SHARE="/usr/share/bsdconfig" 32252995Sdteske. $BSDCFG_SHARE/common.subr || exit 1 33252995Sdteskef_dprintf "%s: loading includes..." "$0" 34252995Sdteskef_include $BSDCFG_SHARE/dialog.subr 35252995Sdteskef_include $BSDCFG_SHARE/mustberoot.subr 36252995Sdteskef_include $BSDCFG_SHARE/startup/rcconf.subr 37252995Sdteske 38252995SdteskeBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="140.startup" 39252995Sdteskef_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 40252995Sdteske 41263791Sdteskef_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm && 42263791Sdteske pgm="${ipgm:-$pgm}" 43252995Sdteske 44252995Sdteske############################################################ GLOBALS 45252995Sdteske 46252995Sdteske# 47252995Sdteske# Options 48252995Sdteske# 49252995Sdteske# Inherit SHOW_DESC value if set, otherwise default to 1 50252995Sdteske[ "${SHOW_DESC+set}" ] || SHOW_DESC=1 51252995Sdteske 52252995Sdteske############################################################ FUNCTIONS 53252995Sdteske 54252995Sdteske# dialog_menu_main 55252995Sdteske# 56252995Sdteske# Display the dialog(1)-based application main menu. 57252995Sdteske# 58252995Sdteskedialog_menu_main() 59252995Sdteske{ 60252995Sdteske local prompt= 61252995Sdteske local menu_list=" 62252995Sdteske '1' '$msg_add_from_list' 63252995Sdteske '2' '$msg_add_custom' 64252995Sdteske " # END-QUOTE 65252995Sdteske local hline="$hline_arrows_tab_enter" 66252995Sdteske 67252995Sdteske local height width rows 68252995Sdteske eval f_dialog_menu_size height width rows \ 69252995Sdteske \"\$DIALOG_TITLE\" \ 70252995Sdteske \"\$DIALOG_BACKTITLE\" \ 71252995Sdteske \"\$prompt\" \ 72252995Sdteske \"\$hline\" \ 73252995Sdteske $menu_list 74252995Sdteske 75252995Sdteske local menu_choice 76252995Sdteske menu_choice=$( eval $DIALOG \ 77252995Sdteske --title \"\$DIALOG_TITLE\" \ 78252995Sdteske --backtitle \"\$DIALOG_BACKTITLE\" \ 79252995Sdteske --hline \"\$hline\" \ 80252995Sdteske --ok-label \"\$msg_ok\" \ 81252995Sdteske --cancel-label \"\$msg_cancel\" \ 82252995Sdteske --menu \"\$prompt\" \ 83252995Sdteske $height $width $rows \ 84252995Sdteske $menu_list \ 85252995Sdteske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 86252995Sdteske ) 87252995Sdteske local retval=$? 88252995Sdteske f_dialog_menutag_store -s "$menu_choice" 89252995Sdteske return $retval 90252995Sdteske} 91252995Sdteske 92252995Sdteske############################################################ MAIN 93252995Sdteske 94252995Sdteske# Incorporate rc-file if it exists 95252995Sdteske[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" 96252995Sdteske 97252995Sdteske# 98252995Sdteske# Process command-line arguments 99252995Sdteske# 100252995Sdteskewhile getopts h$GETOPTS_STDARGS flag; do 101252995Sdteske case "$flag" in 102252995Sdteske h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;; 103252995Sdteske esac 104252995Sdteskedone 105252995Sdteskeshift $(( $OPTIND - 1 )) 106252995Sdteske 107252995Sdteske# 108252995Sdteske# Initialize 109252995Sdteske# 110252995Sdteskef_dialog_title "$msg_add_startup_directive" 111252995Sdteskef_dialog_backtitle "${ipgm:+bsdconfig }$pgm" 112252995Sdteskef_mustberoot_init 113252995Sdteske 114252995Sdteske# 115252995Sdteske# Launch application main menu 116252995Sdteske# 117252995Sdteskewhile :; do 118252995Sdteske dialog_menu_main || f_die 119252995Sdteske f_dialog_menutag_fetch mtag 120252995Sdteske 121252995Sdteske case "$mtag" in 122252995Sdteske 1) # Add From List 123252995Sdteske # Loop to allow adding multiple variables quickly 124252995Sdteske defaultitem= 125252995Sdteske while :; do 126252995Sdteske f_dialog_input_rclist "$defaultitem" || f_die 127252995Sdteske f_dialog_menutag_fetch mtag 128252995Sdteske defaultitem="$mtag" 129252995Sdteske 130252995Sdteske [ "$mtag" = "X $msg_exit" ] && break 131252995Sdteske 132252995Sdteske # Anything else is a directive 133252995Sdteske 134252995Sdteske $BSDCFG_LIBE/$APP_DIR/rcedit ${USE_XDIALOG:+-X} \ 135252995Sdteske "${mtag# }" 136252995Sdteske done 137252995Sdteske ;; 138252995Sdteske 2) # Add Custom 139252995Sdteske f_dialog_input_rcvar || continue 140252995Sdteske $BSDCFG_LIBE/$APP_DIR/rcedit ${USE_XDIALOG:+-X} "$rcvar" 141252995Sdteske ;; 142252995Sdteske esac 143252995Sdteskedone 144252995Sdteske 145252995Sdteskeexit $SUCCESS 146252995Sdteske 147252995Sdteske################################################################################ 148252995Sdteske# END 149252995Sdteske################################################################################ 150