From 569281b60a664213fc60ab34fadd7bcdfe47b03c Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Mon, 22 Oct 2007 15:58:35 -0700 Subject: add 'config_dev' and 'config_path' kernel command-line options to allow a user to specify the device and path of the startup configuration file, e.g., '... config_dev=sda1 config_path=/config.boot'. --- etc/init.d/vyatta-ofr | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/etc/init.d/vyatta-ofr b/etc/init.d/vyatta-ofr index f8782ec..6492b59 100755 --- a/etc/init.d/vyatta-ofr +++ b/etc/init.d/vyatta-ofr @@ -95,6 +95,32 @@ try_floppy () { fi } +get_config () { + declare config_mount=/opt/vyatta/etc/config-mnt + declare -a boot_args=($( cat /proc/cmdline )) + declare config_dev='' + declare config_path='' + for arg in ${boot_args[@]}; do + case "$arg" in + config_dev=*) eval "$arg";; + config_path=*) eval "$arg";; + *) ;; + esac + done + if [ -z "$config_dev" ]; then + return 1 + fi + [ -n "$config_path" ] || config_path='/config.boot' + mkdir -p $config_mount + mount -t ext2 /dev/$config_dev $config_mount -o sync 2>/dev/null + test $? -eq 32 && mount -t vfat /dev/$config_dev $config_mount 2>/dev/null + if [ ! -f ${config_mount}${config_path} ]; then + return 1 + fi + BOOTFILE=${config_mount}${config_path} + return 0 +} + # if necessary, provide initial config init_bootfile () { if [ ! -f $BOOTFILE ] ; then @@ -131,7 +157,9 @@ load_bootfile () start () { log_daemon_msg "Starting Vyatta Router" - try_floppy + if ! get_config; then + try_floppy + fi init_bootfile migrate_bootfile for s in ${subinit[@]} ; do -- cgit v1.2.3