Posted on 08-19-2011 09:38 AM
Hey gang,
I'm working on packaging up VirtualBox and have most of it done. At the end of the installation, I need to either register the VM with the VirtualBox Manager or open the .vbox file to start the VM which will auto-register. The VM files will live in the logged in user's Library folder and registering the VM populates the VirtualBox Manager app's list of VMs that opens when VirtualBox is launched.
There is a command line tool with VirtualBox for registering the VM:
VBoxManage registervm "/path/to/VirtualBox/Windows/Windows.vbox"
As I mentioned above, these files will live in the logged in user's Library folder (VBox seems to really prefer this location to function properly). When this script runs at the end of my policy, it's looking to our management account's home folder for the files and throws an error in the log. I'm not a good script writer yet so I'm hoping you guys can share with me a way to have it point to the actual logged in user's home folder instead of the Casper management account's home folder. I tried using the $userName variable from Casper and that didn't seem to work but maybe I didn't do it right.
Thanks and appreciate any guidance.
Tom
-------
Tom Anderson
Apple Network Engineer - Institutional Computing
Shenandoah University
1460 University Drive
Winchester, VA 22601
Posted on 08-19-2011 09:42 AM
Set the current user as a variable and call that variable in the path to the file?
Im not the best coder but it sounds logical to me.
--
Matt Lee, CCA/ACMT/ACPT/ACDT
Senior IT Analyst / Desktop Architecture Team / Apple S.M.E / JAMF Casper Administrator
Fox Networks Group
Posted on 08-19-2011 10:01 AM
Sounds right to me too and that's the part I'm not sure how to do to be
honest. As you can see, I have some learnin' to do.
Tom
Sent from my iPhone
Posted on 08-19-2011 10:07 AM
Tom (good name by the way)
You can do this several ways:
1) Log in hooks ran by casper use $3 as the current user in variables, log in hooks ran by the login window (apple method) will use $1 as the current logged in user
2) Detect ownership of /dev/console to see who is logged in, if owned by root you are at the login window
3) create and deploy user agents, they run as the user from the get go
-Tom
Posted on 12-10-2012 04:37 PM
Here's what I've been using in my scripts...
#Current user
CurrentUser=$(logname)
#Current user home folder
CurrentUserHome=(/Users/"$CurrentUser")
Posted on 12-11-2012 06:53 AM
#Current User
user=`ls -la /dev/console | cut -d " " -f 4`
#Current User home folder - do it this way in case the folder isn't in /Users
userHome=`dscl . -read /users/$user NFSHomeDirectory | cut -d " " -f 2`