Scripting Auto Login

mscottblake
Valued Contributor

I have some kiosk machines that need to automatically login on boot, but I can't seem to get my package to work properly at imaging time even though it works once I'm logged into the machine.

I created a package that contains the kcpassword file (permissions are correct) and this postinstall script.

#!/bin/sh
/usr/sbin/jamf createAccount -username ***** -realname ***** -password ***** –home /Users/***** –shell /bin/bash
/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow.plist autoLoginUser *****
/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow.plist autoLoginUserUID ###

This package works as anticipated when pushed through Casper Remote, but not from Casper Imaging, even when deployed at first boot. Anyone have an idea why?

1 ACCEPTED SOLUTION

mscottblake
Valued Contributor

I found that everything was working perfectly except the loginwindow.plist changes. Although I was trying to move away from MCX and keep it self contained, I had to move that change into MCX and it started working. For some reason, defaults write wasn't working properly.

Thank you for help in getting this working. If anyone has any idea how to do it without using MCX, I'm all ears.

View solution in original post

7 REPLIES 7

bentoms
Release Candidate Programs Tester

Do you have any applications that require "installing on the boot volume @ imaging time"?

mscottblake
Valued Contributor

I have some, yes, however, I can't get this to work even when I'm just pushing a base setup of only the OS, setregproptool, domain binding, and scripts to enable spotlight and hide Recovery HD.

tlarkin
Honored Contributor

Hello Everyone,

Here is part of an old script I used before my days at JAMF. I had it run post image, because some software installers required a user environment. Since then JAMF has also put out JAMF Helper which is a command line binary that will log in a faux user and install packages post imaging. There is currently a check box in Casper Admin that allows you to do this by simply checking the box that the package needs to be installed to the boot volume after imaging.

I basically used Applescript in a bash script that ran at first boot and would simulate a log in.

/usr/bin/osascript <<AppleScript
   tell application "System Events" 
      keystroke "$local_stushort" 
      keystroke return 
      delay 3.0 
      keystroke "$local_stupasswd" 
      delay 3.0 
      keystroke tab 
      keystroke return 
  end tell
AppleScript

I had variables that created a local user for this earlier in the script. Just remember to test it out and to be very careful putting passwords in scripts. For me the account was a temporary one that got deleted later on anyway. You can also look at the JAMF Helper binary located here:

/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS

and use it to accomplish similar things:

./jamfHelper -help

JAMF Helper Help Page

Usage: jamfHelper -windowType [-windowPostion] [-title] [-heading] [-description] [-icon] [-button1] [-button2] [-defualtButton] [-cancelButton] [-showDelayOptions] [-alignDescription] [-alignHeading] [-alignCountdown] [-timeout] [-countdown] [-iconSize] [-lockHUD] [-startLaunchd] [-fullScreenIcon] [-kill]

-windowType [hud | utility | fs]
    hud: creates an Apple "Heads Up Display" style window
    utility: creates an Apple "Utility" style window
    fs: creates a full screen window the restricts all user input
        WARNING: Remote access must be used to unlock machines in this mode

-windowPosition [ul | ll | ur | lr]
    Positions window in the upper right, upper left, lower right or lower left of the user's screen
    If no input is given, the window defaults to the center of the screen

-title "string"
    Sets the window's title to the specified string

-heading "string"
    Sets the heading of the window to the specified string

-description "string"
    Sets the main contents of the window to the specified string

-icon path
    Sets the windows image filed to the image located at the specified path

-button1 "string"
    Creates a button with the specified label

-button2 "string"
    Creates a second button with the specified label

-defaultButton [1 | 2]
    Sets the defualt button of the window to the specified button. The Default Button will respond to "return"

-cancelButton [1 | 2]
    Sets the cancel button of the window to the specified button. The Cancel Button will respond to "escape"

-showDelayOptions "int, int, int,..."
    Enables the "Delay Options Mode". The window will display a dropdown with the values passed through the string

-alignDescription [right | left | center | justified | natural]
    Aligns the description to the specified alignment

-alignHeading [right | left | center | justified | natural]
    Aligns the heading to the specified alignment

-alignCountdown [right | left | center | justified | natural]
    Aligns the countdown to the specified alignment

-timeout int
    Causes the window to timeout after the specified amount of seconds
    Note: The timeout will cause the the defualt button, button 1 or button 2 to be selected (in that order)

-countdown
    Displays a string notifying the user when the window will time out

-iconSize pixels
    Changes the image frame to the specified pixel size

-lockHUD
    Removes the ability to exit the HUD by selecting the close button
-startlaunchd
    Starts the JAMF Helper as a launchd process
-kill
    Kills the JAMF Helper when it has been started with launchd
-fullScreenIcon
    Scales the "icon" to the full size of the window
    Note: Only available in full screen mode


Return Values: The JAMF Helper will print the following return values to stdout...
    0 - Button 1 was clicked
    1 - The Jamf Helper was unable to launch
    2 - Button 2 was clicked
    3 - Process was started as a launchd task
    XX1 - Button 1 was clicked with a value of XX seconds selected in the drop-down
    XX2 - Button 2 was clicked with a value of XX seconds selected in the drop-down
    239 - The exit button was clicked
    240 - The "ProductVersion" in sw_vers did not return 10.5.X, 10.6.X or 10.7.X
    243 - The window timed-out with no buttons on the screen
    250 - Bad "-windowType"
    254 - Cancel button was select with delay option present
    255 - No "-windowType"

I hope this helps you all out.

Thanks,
Tom

mscottblake
Valued Contributor

Like I said before, I am checking that box in Casper Admin. It doesn't work at imaging time, even on first boot. However, I can run it from Casper Remote. I can't think of what could cause that, let alone knowing where to look for a fix.

bentoms
Release Candidate Programs Tester

From what I've found, the JAMF "adobeinstall" account breaks this for me.

It edits the loginwindow & the kcpassword file.

What I've done, is install apps @ 1st boot & I have a policy that runs off a custom trigger that contains a createuser.pkg from https://github.com/MagerValp/CreateUserPkg

(Well I think that was the steps. I can verify it Monday).

Hope it at least helps a little.

mscottblake
Valued Contributor

Editing the kcpassword file could definitely cause this... I'll have to play. Thanks Ben.

mscottblake
Valued Contributor

I found that everything was working perfectly except the loginwindow.plist changes. Although I was trying to move away from MCX and keep it self contained, I had to move that change into MCX and it started working. For some reason, defaults write wasn't working properly.

Thank you for help in getting this working. If anyone has any idea how to do it without using MCX, I'm all ears.