Home Forums Software InstaDMG Post Action Scripts

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #372818
    vogtstev
    Participant

    Just needing a little clarification on some post action scripts. When trying to execute some post actions I’ve read to refer to $3 in my destination paths. In an example I’ve tried something like this to set a login script:

    #!/bin/sh

    cd “$3″/
    defaults write com.apple.loginwindow LoginHook “/Library/Management/scripts/byhostfix-105.pl”

    I wasn’t able to get this to work. It does work if I execute it manually after imaging. Should I actually be putting $3 in my path of the LoginHook?
    I know I could try using MCX records and plan to experiment more with that, but if I don’t get time I know I can use some login scripts I’ve used in the past. Any ideas?

    Thanks for any input!
    Steve

    #372820
    Patrick Fergus
    Participant

    Yep–you’re going to want to direct defaults to write to the plist you want to modify. I think, by default, defaults writes against ~/Library/Preferences. I think. In the case of InstaDMG, you’d be writing to the ~/L/P of root of the startup disk, since root is running InstaDMG.

    This should work:

    [code]#!/bin/sh

    defaults write “$3″/private/var/root/Library/Preferences/com.apple.loginwindow LoginHook “/Library/Management/scripts/byhostfix-105.pl”[/code]

    #372822
    thisgarryhas2rs
    Participant

    Ya, it took me awhile to figure out the same thing. It needs to be directed to the exact location on the volume.

    #372837
    vogtstev
    Participant

    Thanks guys! I was just about to try the new script. I added those lines to another script and made a payload free package. However, I now have another set of lines in question. I tried making this package previously and it did not seem to execute the commands. I’m trying to set the Date & Time and Enable Root. I know I shouldn’t put the root password in the package and I’m hoping to eventually set this up with password hash, but for testing purposes I have the following:

    #!/bin/sh

    cd “$3″/

    # Enable root
    “$3″/usr/sbin/dsenableroot -d -u admin -p adminpassword -r rootpassword

    # Set Time
    “$3″/usr/sbin/systemsetup -settimezone America/Chicago
    “$3″/usr/sbin/systemsetup -setnetworktimeserver time.apple.com
    “$3″/usr/sbin/systemsetup -setusingnetworktime on

    # Setup Login
    defaults write “$3″/private/var/root/Library/Preferences/com.apple.loginwindow LoginHook “/Library/Management/scripts/byhostfix-105.pl”
    defaults write “$3″/private/var/root/Library/Preferences/com.apple.loginwindow DesktopPicture “/Library/Management/backgrounds/crown.jpg”

    Let me know if you see any more problems! Thanks so much!!!

    #372838
    vogtstev
    Participant

    One other thing to add:

    This package runs during the build after the admin accounts are created with the “Create User” packages.

    #372840
    vogtstev
    Participant

    OK, I found one thing myself –
    I accidently put the -d in dsenableroot and i should have put my passwords in ‘password”. It was evaluating the goofy characters.

    Oops

    #372867
    Patrick Fergus
    Participant

    systemsetup isn’t smart enough to address anything but the startup disk.

    dsenableroot might not be smart enough to address anything but the startup disk–I’m not sure.

    – Patrick

    #372876
    knowmad
    Participant

    dsenableroot can be made to do a non-booted volume, but it must be done with a pre-built hash or it will not work.

    #373045
    ewhite
    Participant

    @vogtstev
    Did the script you posted above work? I’m curious because I’m trying to setup something similar right now…
    The first go around, my script (below) screwed up permissions and I no longer had access to anything in my home folder… I’m re-building right now using something based on your script above. (This time I’ll cd into “$3” and pre-pend “$3” instead of $3).

    [code]#!/bin/bash

    # Show Full directory path in Finder Windows
    defaults write $3/Users/osxadmin/Library/Preferences/com.apple.finder _FXShowPosixPathInTitle -bool YES[/code]

    #373052
    Patrick Fergus
    Participant

    The reason your home was messed up is that defaults appears to build folder structures if they don’t exist, so if:
    [code]”$3″/Users/osxadmin/Library/Preferences/[/code]
    doesn’t exist, defaults builds it. Except defaults builds it as owned by root (which is to be expected, root is executing the command).
    [code]pfergus:~ root# defaults write /Users/osxadmin/Library/Preferences/\
    com.apple.finder _FXShowPosixPathInTitle -bool YES
    pfergus:~ root# ls -al /Users/osxadmin/
    total 0
    drwx—— 3 root admin 102 Jun 10 11:50 .
    drwxrwxr-t 9 root admin 306 Jun 10 11:50 ..
    drwx—— 3 root admin 102 Jun 10 11:50 Library[/code]
    Make sure when you finish modifying the home directory that you chown appropriately (using the uid you’ve set for osxadmin, in this example I’ll use 501):
    [code]chown -R 501 /Users/osxadmin[/code]
    – Patrick

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

Comments are closed