Home Forums Software InstaDMG Postflight script doesn’t run?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #375002
    typofonic
    Participant

    Hi,

    I’ve tried to make a postflight script package using Iceberg, because I want it to run some scripts after installation. However it’s doesn’t seem to run the script.

    I’ve simply created a new package in Iceberg, made an empty text file that I install in /private/var and then selected my settings.sh script below (put together from helpful posts on this forum) as the postflight script.

    Also I’ve chmod’ed the settings.sh script to that it is executable.

    Any ideas why it doesn’t run?

    This is my sh file:
    #!/bin/sh

    ###Set correct permissions on /Applications
    sudo chmod -R 775 /Applications

    ###Recreate and fix trash (logout and in to recreate)
    rm -rf ~/.Trash
    rm -rf ~/Desktop

    systemsetup -setcomputername typofonic-com

    defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup 1
    defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup 0

    ###Postflight script to set time zone and start NTP (Leopard)

    ###Set variables
    systemSetupLocation=”/usr/sbin/systemsetup”
    timeZone=”Europe/Copenhagen”
    networkTimeServer=”time.euro.apple.com”

    ###Set time zone, set time server, start NTP
    $systemSetupLocation -settimezone $timeZone
    $systemSetupLocation -setnetworktimeserver $networkTimeServer
    $systemSetupLocation -setusingnetworktime on

    #Rename the startup disk to “os x”
    /usr/sbin/diskutil rename / “os x”

    /usr/bin/defaults write /Library/Preferences/.GlobalPreferences AppleLanguages “da”
    /usr/bin/defaults write /Library/Preferences/.GlobalPreferences AppleLocale “da_DK”
    /usr/bin/defaults write /Library/Preferences/.GlobalPreferences Country “da_DK”

    #375012
    Rusty Myers
    Participant

    I would guess that it’s running the commands on the local system, not the Image. You have to preface the commands to point to the InstaDMG Image. Use a $3 to specify the image.

    See this thread:
    https://www.afp548.com/forum/viewtopic.php?forum=45&showtopic=22379&highlight=$3

    OR, run the script at first boot of the image with a launchd item.

    #375033
    typofonic
    Participant

    Hi thespider,

    Thanks for your reply!

    [QUOTE][u]Quote by: thespider[/u][p]I would guess that it’s running the commands on the local system, not the Image. You have to preface the commands to point to the InstaDMG Image. Use a $3 to specify the image.

    See this thread:
    https://www.afp548.com/forum/viewtopic.php?forum=45&showtopic=22379&highlight=$3%5B/QUOTE%5D


    Ok, so I guess I change it from this:

    defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup 1
    defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup 0

    to this:

    defaults write $3/com.apple.TimeMachine DoNotOfferNewDisksForBackup 1
    defaults write $3/Library/Preferences/com.apple.TimeMachine AutoBackup 0


    But what do I do with a line like this:
    systemsetup -setcomputername typofonic-com

    As far as I’ve understood, from the post you link to a command like the one above can only be run after startup? See below

    [QUOTE]
    OR, run the script at first boot of the image with a launchd item.[/p][/QUOTE]

    How do I exactly do that? It seems that it would be much easier to run all the scripts on first boot of the image so they don’t have to be modified?

    Thanks

    Anders, Denmark

    #375036
    Rusty Myers
    Participant

    I actually find it easier to run the scripts at first boot. I use Launchd and shell scripts. Lingon is a GUI for creating launchd items. Use a test machine and run a simple script at boot. Create a shell script with this code:

    [code]
    #!/bin/bash

    osascript -e ‘tell app “System Events” to display dialog “This starts at boot.” buttons “OK” default button 1 with title “Boot” with icon stop’
    [/code]

    Use Lingon to create a launchd item that will run the script. I think the best way is to type in this code:

    [code]
    sh /path/to/script/[/code]

    Now package both the launchd item and script. That’s about it!

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

Comments are closed