Autostart Pfsense Mandriva 2010 at boot



  • Howzit Guys,

    I have installed Pfsense on Virualbox as a guest, I am fairly new when it comes to Linux commands so if someone can assist me with a script that I can implement that will start my virtual machine when madriva boots.

    I am looking more at using the autostart aplication that Mandriva offers and VIA that add a command / script to start the process…

    Please, any help would be appreciated.



  • here is an init-script I found ad vbox-forums some time ago. as its no longer adjusted to new versions von vbox I modified it on my own working fine with vbox 4.0.8 on ubuntu
    I dunno anything about mandriva but i guess on principle it will work - maybe you will need to do some little changes

    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides: virtualbox_vms
    # Required-Start:    $local_fs $syslog
    # Required-Stop:     $local_fs $syslog
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Control VirtualBox Virtual Machine instances
    ### END INIT INFO
    #
    # Original Version 2008051100 by Jochem Kossen <jochem.kossen@gmail.com>
    # http://farfewertoes.com
    #
    # Released in the public domain
    #
    # This file came with a README file containing the instructions on how
    # to use this script.
    #
    # Modified my Plexus
    #
    
    . /lib/lsb/init-functions
    
    # Are we running from init?
    run_by_init() {
        ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
    }
    
    ################################################################################
    # INITIAL CONFIGURATION
    VBOXDIR="" # path to the file "machines_enabled" including the list of vbox-machine names
    VM_USER="" # user starting the vbox-machines
    
    ################################################################################
    # CHECK CONFIG
    
    export PATH="${PATH:+$PATH:}/bin:/usr/bin:/usr/sbin:/sbin"
    
    if [ ! -f $VBOXDIR/machines_enabled ]; then
        echo "ERROR: $VBOXDIR/machines_enabled does not exist. Exiting."
        exit 1
    fi
    
    SU="su $VM_USER -c"
    VBOXMANAGE="VBoxManage -nologo"
    
    ################################################################################
    # FUNCTIONS
    
    # Check for running machines every few seconds; return when all machines are
    # down
    wait_for_closing_machines() {
        if [ `$SU "$VBOXMANAGE list runningvms" | wc -l` != 0 ]; then
            sleep 2
    	echo -n "."
            wait_for_closing_machines
        fi
    }
    
    ################################################################################
    # RUN
    case "$1" in
        start)
    	cat /etc/virtualbox/machines_enabled | while read VM; do
    		if [ `$SU "$VBOXMANAGE list runningvms" | grep Test | wc -l` != 0 ]; then
    			log_action_msg "Virtual machine $VM already running..."
    		else
    			log_action_msg "Starting VM: $VM ..."
    			#$SU "$VBOXMANAGE startvm $VM --type headless"
    			$SU "screen -m -d -S $VM VBoxHeadless --startvm $VM --vrde=off"
    		fi
    	done
    	;;
        stop)
            # NOTE: this stops all running VM's. Not just the ones listed in the config
            $SU "$VBOXMANAGE list runningvms" | awk '{ print $1; }' | sed -e 's/"//g' | while read VM; do
    		log_action_msg "Shutting down VM: $VM"
    		echo -n "\tWaiting for closing down VM..."
    		$SU "$VBOXMANAGE controlvm $VM acpipowerbutton"
            done
            wait_for_closing_machines
    	echo
            ;;
        start-vm)
            log_action_msg "Starting VM: $2 ..."
            $SU "$VBOXMANAGE startvm \"$2\" --type headless"
            ;;
        stop-vm)
            log_action_msg "Stopping VM: $2 ..."
            $SU "$VBOXMANAGE controlvm \"$2\" acpipowerbutton"
            ;;
        poweroff-vm)
            log_action_msg "Powering off VM: $2 ..."
            $SU "$VBOXMANAGE controlvm \"$2\" poweroff"
            ;;
        status)
    	if [ `$SU "$VBOXMANAGE list runningvms" | wc -l` = 0 ]; then
    		log_action_msg "Currently there are no virtual machines running..."
    	else
    		log_action_msg "The following virtual machines are currently running:"
    		$SU "$VBOXMANAGE list runningvms" | sed -ne 's/[^\"]*\"\([^\"]*\)\"[^\"]*/\1 /p' | while read VM; do
    			echo "\t$VM (`$SU "VBoxManage showvminfo $VM" | grep "Hardware UUID:" | sed -e "s/^Name:\s*//g"`)"
    		done
    	fi
            ;;
        *)
            log_failure_msg "Usage: $0 {start|stop|status|start-vm|stop-vm|poweroff-vm}"
            exit 3
    	;;
    esac
    
    exit 0</jochem.kossen@gmail.com>
    

    of course I will have an sympathetic ear if anyone being well familiar with bash flying over this script has any suggestions to improve…


Locked