Home Forums Software InstaDMG set Computer & Local Hostname with firstboot script

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #380510
    solca
    Participant

    Hi

    I was trying to extend the firstboot script with the function “set Computer & Local Hostname” as you can see in the script below.

    [code]#Script to change Computer & Local Hostname
    # ConsoleMessage
    echo “set Computer & Local Hostname”

    ip=`ifconfig en0 inet | grep inet | sed ‘s/.*inet *//; s/ .*//’`
    echo “$ip”

    ip4=`echo $ip | sed ‘s/\./-/g’`
    echo “$ip4”

    scutil –set ComputerName “stud $ip”
    scutil –set LocalHostName “stud$ip4″[/code]

    After creating an image with InstaUp2Date and distribute it with DeployStudioServer the imaged machine produces the following error message

    3/4/11 2:01:45 PM ch.uzh.ifi.firstboot[52] set Computer & Local Hostname
    3/4/11 2:01:45 PM ch.uzh.ifi.firstboot[52] 2011-03-04 14:01:45.418 writeconfig[225:903] *** -[NSMachPort handlePortMessage:]: dropping incoming DO message because the connection or ports are invalid
    3/4/11 2:01:45 PM ch.uzh.ifi.firstboot[52] ifconfig: interface en0 does not exist

    If I test “ifconfig en0” after reboot it works as expected.

    Any idea how to solve this?

    thanks enrico

    #380513
    Allister Banks
    Participant

    Which version of DS? What’s calling the firstboot script?
    There are workflow options in DS to name the computer for you, but your issue is the fact your script is running before the network interfaces are initialized, which is why it works after a reboot. Instead of a LaunchDaemon you may want to use a LaunchAgent and have it rename the machine after first user login/some other trigger that relies on networking.

    Allister

    #380515
    knowmad
    Participant

    you can also, if you dont want to do it after user login, do one of two other things:
    Have your script check for IP address and if its not there, kill itself and respawn after 30 seconds.
    OR
    create a file as counter.
    If the file is not there, create the file and reboot the machine
    If the file is there, set the computer and host name
    done
    If you need examples on how to do this stuff, i can go drag it up from wherever I last left it all.

    #380519
    foilpan
    Participant

    you might also try adding a “networksetup -detectnewhardware” and a short sleep interval before attempting to set the name.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Comments are closed