summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/share/script.subr
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-02-25 19:55:32 +0000
committerdteske <dteske@FreeBSD.org>2013-02-25 19:55:32 +0000
commit1f658c88bed0f72839a6caee6fdc9731cfd3a516 (patch)
treecd0ba840ab0526258652c2740f9e0c046edb8374 /usr.sbin/bsdconfig/share/script.subr
parent66bd226a8bcd9c32e76c9a7c414af10c393e50d8 (diff)
downloadFreeBSD-src-1f658c88bed0f72839a6caee6fdc9731cfd3a516.zip
FreeBSD-src-1f658c88bed0f72839a6caee6fdc9731cfd3a516.tar.gz
Import media selection/preparation framework (sysinstall inspired). Makes
accessing files from various types of media nice and abstracted away from the wet-work involved in preparing, validating, and initializing those types of media. This will be used for the package management system module and other modules that need access to files and want to allow the user to decide where those files come from (either in a scripted fashion, prompted fashion, or any combination thereof). Heavily inspired by sysinstall and even uses the same reserved words so that scripts are portable. Coded over months, tested continuously through- out, and reviewed several times. Some notes about the changes: - Move network-setting acquisition/validation routines to media/tcpip.subr - The options screen from sysinstall has been converted to a dialog menu - The "UFS" media choice is renamed to "Directory" to reflect how sysinstall treats the choice and a new [true] "UFS" media choice has been added that acts on real UFS partitions (such as external disks with disklabels). - Many more help files have been resurrected from sysinstall (I noticed that some of the content seems a bit dated; I gave them a once-over but they could really use an update). - A total of 10 media choices are presented (via mediaGetType) including: CD/DVD, FTP, FTP Passive, HTTP Proxy, Directory, NFS, DOS, UFS, Floppy, USB - Novel struct/device management layer for managing the issue of passing more information than can comfortably fit in an argument list.
Diffstat (limited to 'usr.sbin/bsdconfig/share/script.subr')
-rw-r--r--usr.sbin/bsdconfig/share/script.subr33
1 files changed, 28 insertions, 5 deletions
diff --git a/usr.sbin/bsdconfig/share/script.subr b/usr.sbin/bsdconfig/share/script.subr
index 84d1cab..3ea5dd5 100644
--- a/usr.sbin/bsdconfig/share/script.subr
+++ b/usr.sbin/bsdconfig/share/script.subr
@@ -1,6 +1,6 @@
if [ ! "$_SCRIPT_SUBR" ]; then _SCRIPT_SUBR=1
#
-# Copyright (c) 2012 Devin Teske
+# Copyright (c) 2012-2013 Devin Teske
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,10 @@ if [ ! "$_SCRIPT_SUBR" ]; then _SCRIPT_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
f_dprintf "%s: loading includes..." script.subr
+f_include $BSDCFG_SHARE/device.subr
f_include $BSDCFG_SHARE/variable.subr
+f_include $BSDCFG_SHARE/media/any.subr
+f_include $BSDCFG_SHARE/media/tcpip.subr
############################################################ GLOBALS
@@ -75,11 +78,13 @@ f_dispatch()
local func="$1" resword="${2:-$1}"
f_dprintf "f_dispatch: calling resword \`%s'" "$resword"
eval $func
- local retval=$? _ignore_this_error
- f_getvar $VAR_NO_ERROR _ignore_this_error
- [ $retval -eq $SUCCESS ] ||
+ local retval=$?
+ if [ $retval -ne $SUCCESS ]; then
+ local _ignore_this_error
+ f_getvar $VAR_NO_ERROR _ignore_this_error
[ "$_ignore_this_error" ] || f_die $retval \
- "$msg_command_failed_rest_of_script_aborted" "$resword"
+ "$msg_command_failed_rest_of_script_aborted" "$resword"
+ fi
unset $VAR_NO_ERROR
}
@@ -146,8 +151,26 @@ f_script_load()
#
# Reserved words meant for scripting
#
+f_resword_new deviceRescan f_device_rescan
f_resword_new dumpVariables f_dump_variables
f_resword_new loadConfig f_script_load
+f_resword_new mediaClose f_media_close
+f_resword_new mediaGetType f_media_get_type
+f_resword_new mediaOpen f_media_open
+f_resword_new mediaSetCDROM f_media_set_cdrom
+f_resword_new mediaSetDOS f_media_set_dos
+f_resword_new mediaSetFTP f_media_set_ftp
+f_resword_new mediaSetFTPActive f_media_set_ftp_active
+f_resword_new mediaSetFTPPassive f_media_set_ftp_passive
+f_resword_new mediaSetFTPUserPass f_media_set_ftp_userpass
+f_resword_new mediaSetFloppy f_media_set_floppy
+f_resword_new mediaSetHTTP f_media_set_http_proxy
+f_resword_new mediaSetHTTPProxy f_media_set_http_proxy
+f_resword_new mediaSetNFS f_media_set_nfs
+f_resword_new mediaSetUFS f_media_set_ufs
+f_resword_new mediaSetUSB f_media_set_usb
+f_resword_new optionsEditor f_media_options_menu
+f_resword_new tcpMenuSelect f_dialog_menu_select_tcp
f_dprintf "%s: Successfully loaded." script.subr
OpenPOWER on IntegriCloud