Tag Archives: Mac OS X

Your photo Library has been migrated to Photos

iphoto_to_photos__6
I ran into a weird issue the other day when switching a user to a new laptop. Part of the process is transferring data, usually via target disk mode. In this case an old iPhoto library from a OS X 10.9 Mavericks machine to Photos on an OS X 10.11 El Captain machine. This has been seamless in the past, as you just move the iPhoto library into the Pictures folder and double-click on it. Photos opens and automatically converts the library to a new “Photos” library.

This time something strange happened, I’m not even sure what. I suspect the user created a new Photos library by importing photos from his phone. Then dragged the iPhoto library in and tried to double-click it. Either way, the user got an error message, “Your Photo Library has been migrated to Photos”. But on opening “Photos”, only the new photos imported from his phone were there.

This lead to a cycle of deleting the “Photo” library and trying to double-click the iPhoto library over and over. Now “Photos” complained that the it can’t find the Systems Photo Library. Which means you have to make a new Library that’s empty, which leads back to the iPhoto Library already being migrated.

iphoto_to_photos__7

After deleting every preference file, cache, container, group container, and application support folder I thought might apply … I still had the same issue.

That’s when I decided to look in the Pictures folder for a hidden file, something to do with “migrated”. To my surprise, I noticed the extension of the iPhoto library had been changed to .migratedphotolibrary. I figured if I changed the extension to .photoslibrary, Maybe Photos would migrate library again.

iphoto_to_photos__16

Sure enough on changing the extension, the icon changes from the old iPhoto to the new Photos.

iphoto_to_photos__16  >  iphoto_to_photos__17

On a double click. “Photos” open and re-migrates the library.

iphoto_to_photos__22

Creating A Custom OS X Puppet Installer

puppet_installer_icon

Getting puppet on OSX is getting better and simpler. You now have 3 packages to install, the puppet user is created for you and it just works … for the most part. In my environment, I have a couple extra steps. Like installing the Launch Daemon when I also install the packages, and adding my puppet master to the hosts file on each client. Instead of  touching each client 5 to 6 times to get puppet setup. I rolled it into a custom package.

I’m using PackageMaker but certainly you could use any flavor of package management (packages, iceberg, etc) and my client machines are on OSX 10.9.5.

01I downloaded Facter, Hiera, and Puppet from the puppetlabs website and pulled out the pkgs. Then added them to my PackageMaker project.

_ _ _ _

02
I created the com.puppetlabs.puppet.plist Launch Daemon and added the file to the project. Just make sure to change the “Destination” to “/Library/LaunchDaemons”

For good measure, here’s the com.puppetlabs.puppet.plist. Just copied from the website.

<!--?<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.puppetlabs.puppet</string>
        <key>OnDemand</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/bin/puppet</string>
                <string>agent</string>
                <string>--no-daemonize</string>
                <string>--logdest</string>
                <string>syslog</string>
                <string>--color</string>
                <string>false</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>ServiceDescription</key>
        <string>Puppet agent service</string>
        <key>ServiceIPC</key>
        <false/>
</dict>
</plist>

_ _ _ _

03I also added a Postinstall script to handle a few extra things like installing some dependencies, making root the owner of the Launch Daemon, setting the permission on the Launch Daemon, and then adding my puppet server to the hosts file.

#!/bin/sh

#need for property_list_key
gem install CFPropertyList -v 2.2.6

#need for managedmac
gem install sqlite3

#change owner and permissions of puppet launchdaemon
sudo chown root:wheel /Library/LaunchDaemons/com.puppetlabs.puppet.plist
sudo chmod 644 /Library/LaunchDaemons/com.puppetlabs.puppet.plist

#edit hosts file with puppet server IP. Change xxx to match your server IP.
echo "\nxxx.xxx.xxx.xxx    puppet" >> /etc/hosts

Next … build package and go forth and puppetize!

Check OSX Mavericks Powersettings With Shell Script

Instead of using puppet or profiles to check and set the OS X energy settings. I also wrote a simple script that checks the current status of “Computer Sleep”. If it’s set to anything other then “Never” go to sleep, it runs my pmset command and sets the machine to my desired settings.

#!/bin/sh
#version 1.0

#checks the curret status of "Computer Sleep", if it's not set to 0(never sleep), then it runs the pmset command
# sets display sleep to 30 minutes
# sets computer sleep = never
# sets hard drive sleep - never
# sets wake for network access = true
# sets autorestart after power failure = true


if [[ `pmset -g | grep -w sleep |awk '{print $2}'` -gt 0 ]]; then
    
    echo "Changing Power Settings"
    pmset -c displaysleep 30 sleep 0 disksleep 0 womp 1 autorestart 1

    else
        echo "Settings are correct"
    fi

Manage OS X Firewall with Puppet

MAC OS X FIrewall

With the help of glarizza’s module, Property_List_Key, I’m testing managing OS X plist with Puppet. This turns the built-in firewall on and ensures it stays on. Tested on OS X 10.9.5

 property_list_key { 'globalstate':
      ensure => present,
      path   => '/Library/Preferences/com.apple.alf.plist',
      key    => 'globalstate',
      value  => '1',
      value_type    => 'integer',
    }

This get’s me thinking all sorts of creative things that can be managed and enforced in a lab setting, where user’s might have admin rights and make undesirable changes.

Using Puppet to manage Java auto updates on Mac OS X

I’ve been toying with a virtual setup of puppet open source over the last week. My Puppet Master is Ubuntu 12.04, my Puppet Agent is Mac OS X 10.9.

I’ve been looking at puppet for over two years and have tried twice in the past to stand up a virtual machine and make it do something!!!. It usually ends with some crisis being more important and by the time I come back to puppet … I’m lost. I get frustrated and delete the VM’s. Rinse and repeat.

This time I”m up and running and my two big goals, both of which I accomplished, were too manage a local admin account, and install and manage printers for Mac OS X. Two things I can manage in several different ways, but I’d like to see if Puppet’s way is better/different. My thoughts are still out on that. I’m trying to consider how puppet could fit into my current workflows. But it is neat to watch puppet work. Which got me thinking. What kind of creative things can puppet do to manage a Mac OS X desktop?

If one of the things Puppet can manage are file resources, and plist are just formatted xml files. Can puppet manage plist for Mac OS X? So I decided to try something very simple. I want to turn off Java 7’s auto update feature. No matter how many times you turn it off, when you install a new version of Java, it’s re-checked. This is a good test because the plist only contains 1 entry.

Typically to disable auto updates, you can just open terminal and run:

sudo defaults write /Library/Preferences/com.oracle.java.Java-Updater.plist JavaAutoUpdateEnabled -false

But with puppet, I want to make sure of a couple things:

– The file “com.oracle.java.Java-Updater.plist” exist at /Library/Preferences/

– That the mode is set to 644

– The contents of the file contains the entire plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>JavaAutoUpdateEnabled</key>
    <false/>
</dict>
</plist>

so my puppet code looks like this:

Screen Shot 2014-08-15 at 9.06.00 AM

node pup{
        file {'com.oracle.java.Java-Updater.plist':
                path    => '/Library/Preferences/com.oracle.java.Java-Updater.plist',
                ensure  => present,
                mode    => 644,
                content => '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>JavaAutoUpdateEnabled</key>
        <false/>
</dict>
</plist>',
        }

And after I run puppet on my node, I did a restart for good measure and then checked the auto update box. Which appears to have worked.

Screen Shot 2014-08-15 at 9.04.54 AM

Pretty neat for a quick test. It has me thinking what else might Puppet be able to do?

 

Backing Up Minecraft on Mac OS X

My son is supper big into Minecraft, and it always comes up whenever there is a new update … How do I backup my Minecraft folder?

I finally got tired of navigating to the Minecraft folder in the User/Library/Application Support folder. So I made a simpe script that can be run just by double clicking an executable shell script.

Using the Command Line to make the Backup

1. First on the desktop select “Go”, “Go to Folder” from the top menu bar

2. type in “~/Library”, click on “Go”. Navigate to the Application Support/minecraft folder

3. Now create a folder to place your Minecraft backups in. I created one called “MineCraft Backups” on my desktop, just to be easy. Then open the folder. You should have the two folders open like below.

minecraft-02

4. Open the Terminal and run this command. Make sure you substitute your user account name in place of “USER1” in the below command.

ditto -c /Users/USER1/Library/Application\ Support/minecraft /Users/USER1/Desktop/MineCraft\ Backups/minecraft_backup.$(date +%Y%m%d-%H%M%S).zip

If successful you should see a zip file added to your backup folder. Let’s break the command down.

The command is a simple ditto -c “source” “destination” “options”

Example:

ditto -c /Users/USER1/Library/Application\ Support/minecraft /Users/USER1/Desktop/MineCraft\ Backups/minecraft_backup.$(date +%Y%m%d-%H%M%S).zip

Command = ditto
a command that copies directory hierarchies, create and extract archives

options = -c
tells ditto to make an archive

Source = Users/USER1/Library/Application\ Support/minecraft
path of the file or folder that we want to back up

destination = /Users/USER1/Desktop/MineCraft\ Backups/minecraft_backup
path to where we want to put the backup

options: .$(date +%Y%m%d-%H%M%S)
this command is totally optional. It simply appends the year, month, day, hour, minutes, and seconds onto the end of the file name. I like to be detailed and this way no matter how many times I run my script they will always have a different file name and I won’t have to worry about them overwriting each other.

file format to save as: .zip
tells ditto to save the archive as a zip file

minecraft-03

 

Creating A script to run the backup

That’s was pretty easy but we don’t want to have to remember that command everytime we want to make a backup. So let’s make that command a shell script.

1. In Terminal type:

cd ~/desktop
vim Backup_Minecraft

minecraft-04

This is going to create a file on your desktop call “Backup_Minecraft” that we are going to save our command into.

2. It should open a blank window. press “i” to enter insert mode, and paste your command from above into the window.

minecraft-05

3. Then press the ‘esc’ key to exit insert mode.

4. Press :wq to save and close the vim editor.

5. you should now have a new file on your desktop named “Backup_Minecraft”

minecraft-07

6. Now we need to make it executable so we can run the command. Back in terminal type the below command, again make sure to substitute your user account name in place of “USER1”.

chmod u+x /Users/USER1/Desktop/Backup_Minecraft

minecraft-06

7. If it was successful you’ll notice the “Backup_Minecraft” file has changed in appearance.

minecraft-08

8. Now let’s verify that the script works. Double click the “Backup_Minecraft” file. You should get a Terminal window that pops up and a new .zip file added to your backup folder. If everything went well the Terminal window should say “Process Completed”
minecraft-09

Now anytime you want to make a backup of your entire minecraft folder you can simply double click your script.

 

How to automate your backup script

I stopped there, but if you wanted too, you could take this a step forward by creating a launch daemon or crontab. I’ll show you the crontab here.

1. Open Terminal and type the below:

cd ~/desktop
vim backups.sh

2. When the blank terminal windows opens, press “i” to enter insert mode, and paste your command from below into the window. Make sure you substitute your user account name in place of “USER1”.

#! /bin/bash
ditto -c /Users/USER1/Library/Application\ Support/minecraft /Users/USER1/Desktop/MineCraft\ Backups/minecraft_backup.$(date +%Y%m%d-%H%M%S).zip

minecraft-10

3. Then press the ‘esc’ key to exit insert mode.

4. Press :wq to save and close the vim editor.

5. you should now have a new file on your desktop named “backups.sh

minecraft-11

6. Let’s verify the script is working. Open Terminal and type:

cd ~/desktop
./backups.sh

It should create a new backup in your backup folder.

minecraft-12

7. Time to create a crontab which is just a scheduled task. I’m going to set this example up to backup every 2minutes. So we can quickly see if it’s working. Open Terminal and type:

crontabe -e

This will open a blank window so we can create our task.

8. Press “i” to enter insert mode, and paste the command from below into the window. Make sure you substitute your user account name in place of “USER1”

*/2 * * * * /Users/USER1/Desktop/backups.sh

With out going to deep into crontabs, this command tells your computer to run the script backups.sh every two minutes. For more info on crobtabs go here.

9. Then press the ‘esc’ key to exit insert mode.

10. Press :wq to save and close.

11. To check to see if your crontab was saved run this command or wait 2 minutes to see if a new backup is added.

crontab -l

minecraft-16

12. To remove the crontab run this command. Then you can create a new one and adjust the schedule to run every 24 hours, or what every you prefer.

crontab -r

Configuring Munki Clients for Munkiwebadmin

So you have  munki and munkwebadmin setup and now need to make sure your clients are checking in to munkiwebadmin. Here’s how I do it.

1. Install munki tools on client machines.

– Go here and download the munki tools.

http://code.google.com/p/munki/downloads/list

– Either install manually on each machine or push out the installer package with ARD. BE WARNED it will force an immediate restart.

2. Edit URL in Client scripts.

– Go to  /Users/Shared/munkiwebadmin_env/munkiwebadmin/scripts/For Clients on the machine you installed munki on.

– Right click on “post flight” file, select “open with”. I use gedit with a custom theme, Xcode is another good choice, but you can use Text Editor if nothing else.

– Change the first line BASEURL to the IP or DNS name of your munki machine. Make sure to leave the port 8000 . If you choose to use the DNS name make sure you have correct DNS records by doing a forward and reverse lookup.

basaeurl

Example

BASEURL="IP of munki machine:8000"

– Save the file when finished.
– Repeat this step on the “preflight” and “Report_broken_Client” files.

3. Copy scripts to client machine
– Copy the files to the client machine, put them in the /usr/local/munki folder.

– Again, lots of options on how to get them to the client. Manual is fine for testing, in a production environment I would consider an installer package. I’m just using ARD to copy from my machine to the clients.

– Make sure the files copied have a 755 permission set. Without getting too deep the easiest way to make sure they have the right permissions, is to right click the /usr/local/munki folder and say “Get Info”. Select the lock in the bottom right and authenticate as an admin.Then click the gear and select “Apply to enclosed items …”. This will propagate the permission down to the files you just added.

munki755

4 Run Managed Software Update on the client

– Run Manage Software Update was installed by munki tools. You can find it in /Applications/Utilities

– After you run it, open munkiwebadmin

5. Log into munkwebadmin

– Open a web browser and go to your munkiwebadmin IP, in my case it’s 192.168.10.26:8000

– You should see a new client machine has checked in.

munkiwedadmin-client

Install Printers On A Mac From The Command Line

I found myself setting up a mac from scratch this morning. It’s sort of a one off situation so applying one of my standard images didn’t seem to make sense.

Though when it came time to install the printers I realized I was going to have to add them one by one. I decommissioned our aging Mac print server a few months ago and have moved to IP based printing.

I’ve thought about using munki to manage printers and just haven’t got around to it. So I was stuck with manual setups and that thought kind of got under my skin.

So I finally made a script to add my printers all in one swoop. The basic command is below. You’ll need to wrap it in a shell script, or I just pasted the commands into Apple Remote Desktop and ran them as root on my remote machines.

Command:

/usr/sbin/lpadmin -p "name of printer" -E -v lpd://"printer IP or DNS"/"queue name" -P "path to PPD file" -D "description"

Example:

/usr/sbin/lpadmin -p "DC_3FL_PRINT_B&W" -E -v lpd://"192.168.10.99"/"DC_3FL_PRINT_B&W" -P "/Library/Printers/PPDs/Contents/Resources/HP LaserJet 9050.gz" -D "DC_3FL_PRINT_B&W"

This only works of course if you have the print drivers already installed. If they are not, you need to install them a head of time or copy them before you run this command like in the example below. I choose to copy the ppd file and not run an installer since I know exactly what ppd files I need.

The below command copies the ppd from a network share to the clients printer ppd folder. a simple “copy- source-destination”. Then sets up the desired printer.

cp /Volumes/dcfiles/Transfer\ then\ delete/nscott/PRINTERS/CNR3235X1.PPD.gz /Library/Printers/PPDs/Contents/Resources\
/usr/sbin/lpadmin -p "DC_1FL_ARC_COPY_B&W" -E -v lpd://"192.168.10.133"/"DC_1FL_ARC_COPY_B&W" -P "/Library/Printers/PPDs/Contents/Resources/CNR3235X1.PPD.gz" -D "DC_1FL_ARC_COPY_B&W"

SWITCHES
-p : configures said printer
-E : enables printer to accept jobs
-v : Sets printer URL
-P : Specifies a ppd file to use
-D : creates a text description for the printer

If you wanted to remove a printer instead of add you would just replace the first -p, used to configure a printer, with -x, used to delete a printer.

Migrating Jobs In Crashplan PROe

I’m in the middle of setting up a new Crashplan PROe server. My old setup included a powerpc Mac running 10.4 and five external drives. Long story short, that setup didn’t work. I’m as updated as I can get with Crashplan because I can’t upgrade the Java any more on the powerpc Mac. I have several bugs/issues with the Crashplan web ui that can not be resolved unless I upgrade and the external drives occasionally don’t mount on restarts … all of which requires me to spend more time then I want administrating backups.

My new setup is a  HP DL380 G8 with 18TB of internal storage. More more worrying about drives not mounting and I will be able to update to the latest version of Crashplan.

My first task though is migrating all those backup archives off the external drives and onto my HP internal Drive. This is a fairly easy process in the web ui. You log in select “Devices”, select the client name, and from the action menu to the right of the job (the folder/arrow icon) select “Migrate Archive.

cp_migrate-01

This works great for same backup jobs. They migrate over pretty quickly. But for very large backups, like my 3TB’s it’s a pain because there is no progress bar to show if the job is actually migrating over, and nothing writing to the log files.This was a feature in 3.8.2010 Why did Crashplan remove this feature? For administrators, we want to know everything going on about our machines.

That got me to looking at the destination folder on my HP server. Once you turn on hidden folders you’ll see a folder named “.balance.moveguidtomount-109”. Instead I find a folder with the same GUID as the job I was migrating over. If you watch the folder size it slowly gets larger leading me to believe the job is migrating over, just very slowly.

cp_migrate-02

cp_migrate-03

The frustration comes from not being able to find this information anywhere in the web ui. And when I opened a ticket I didn’t get a response for 5 days, and when Crashplan responded, they said “Is this still a problem?” REALLY! that’s how you support paying customers. So I replied back and still have not heard back on the officially ticket. Why do I as the customer have to go snooping around hidden folders to find a piece of simple information.

Why not add a progression bar, verbose log out out, or even a simple ETA on migrated jobs ….. “Migration will be done 28 hours”. That why admins came be assured  action is happening.