Relative paths in configuration profiles

Apple wants you to use configuration profiles for setting up your client preferences. And because I don’t want to fight the fruity company I decided that this year I was moving (most) of my first boot scripts and custom plists to config profiles.

One issue I faced and that could not get my head around is that, if you want to set up the users’ Dock with no merging (that is getting rid of Apple default apps) you loose the ability to add user folders. Including the always-useful Downloads folder.

I tried all the combinations with no luck and even though very seriously on going back to fighting the fruit company and keep using non-standard ways of setting the Dock.

Then I found this key

bash-3.2$ defaults read /System/Library/CoreServices/Dock.app/Contents/Resources/en.lproj/default.plist persistent-others
(
        {
        "tile-data" =         {
            arrangement = 2;
            "home directory relative" = "~/Downloads";
            showas = 1;
        };
        "tile-type" = "directory-tile";
    }
)

It was like “home directory relative… Whaaaat?!” (insert your favourite meme)

Correct. That “just works” and looks like it is the official fruity way that has been around since 10.5 and I had absolutely no clue.

Here is the bottom of my Dock.mobileconfig which works perfectly fine

        <key>static-others</key>
        <array>
          <dict>
            <key>mcx_typehint</key>
            <integer>2</integer>
            <key>tile-type</key>
            <string>directory-tile</string>
            <key>tile-data</key>
            <dict>
              <key>arrangement</key>
              <integer>2</integer>
              <key>home directory relative</key>
              <string>~/Downloads</string>
              <key>showas</key>
              <integer>1</integer>
            </dict>
            <key>tile-type</key>
            <string>directory-tile</string>
          </dict>
        </array>
      </dict>
    </array>
  </dict>
</plist>

As one last addition to the post I want to add that if you try to edit a configuration profile you downloaded from your MDM by hand, to do things like this or any similar thing, you will see that the .mobileconfig is 4 lines and is not indented. I did open a bug for this but it was closed because it doesn’t affect functionality. Yeah! it only makes admins their tasks a bit more difficult :S

In case you want to automatically indent the file without breaking the plist just paste the content on this free XML parser from the App Store. It has been a time saver for me

Posted in IT and stuff Tagged with: , ,

Backup and restore Munkireport-php

Here’s a little tip of how I backup my mr-php MySQL database

mysqldump -u root -p munkireport | bzip2 -c > ${HOME}/dbdump_`date +%d-%m-%Y`.bz2

This command will prompt for the MySQL root password and generate a compressed backup of the database in your home folder.

For restoring it, this command will uncompress it and restored to the munkireport database.

bzcat ~/dbdump_21-07-2014.bz2 | mysql -u root munkireport

Note that these are just examples. You can use any user account that has access to the database and your database might not be called munkireport

Posted in IT and stuff Tagged with: , , ,

Script: loop sites and get http response

Brief post from the iPad to post a script to check the response of a website and display the http codes in colored output.

#!/bin/sh
 
#gets the exit codes for 2x website builds
#.2026 seems to be the first valid build for 11.1 version

BUILDLOWER="2026"
BUILDHIGHER="2200"

while [[ ${BUILDLOWER} < ${BUILDHIGHER} ]]; do
	RESULT=`curl -s -o /dev/null -w "%{http_code}" http://www.2x.com/downloads/builds/applicationserver/11.1.${BUILDLOWER}/`
	if [[ ${RESULT} == "200" ]]; then
		#200 --> OK
		echo "http://www.2x.com/downloads/builds/applicationserver/11.1.${BUILDLOWER}/ --> `echo $'\e[36m' '200' $'\e[0m'`"
		curl -s http://www.2x.com/downloads/builds/applicationserver/11.1.${BUILDLOWER}/ --list-only | grep pkg
	elif [[ ${RESULT} == "300" ]]; then
 		#300 --> Multiple Choices
 		echo "http://www.2x.com/downloads/builds/applicationserver/11.1.${BUILDLOWER}/ --> `echo $'\e[31m' '300' $'\e[0m'`"
 	elif [[ ${RESULT} == "301" ]]; then
 		#301 --> Moved Permanently
 		echo "http://www.2x.com/downloads/builds/applicationserver/11.1.${BUILDLOWER}/ --> `echo $'\e[32m' '301' $'\e[0m'`"
	fi
	BUILDLOWER=$[$BUILDLOWER+1]
done 

echo "Finish!"
 
exit 0
Posted in IT and stuff