Monday, July 30, 2012

Mountain Lion PreCheck for DeployStudio

A quick and dirty version that checks if the Mac you're deploying is Mountain Lion compatible.



#!/bin/bash

# Mountain Lion prereq checker

modelId=$(system_profiler SPHardwareDataType | grep "Model Identifier" | awk -F': ' '{print $2}')
#modelId=Macmini1,1
modelName=$(echo $modelId | awk -F',' '{print $1}' | tr -d '[[:digit:]]' | tr -d ',')
modelIdMajor=$(echo $modelId | awk -F',' '{print $1}' | tr -cd '[[:digit:]]')
modelIdMinor=$(echo $modelId | awk -F',' '{print $2}')

approvedModelsMajor=( 'iMac7' 'MacBook5' 'MacBookPro3' 'MacBookAir2' 'Macmini3' )

if [ "$modelName" = "iMac" ]; then
if [ "$modelIdMajor" -ge "7" ]; then
echo "------ ML PREREQ: This $modelName can run ML"
exit 0
else
echo "------ ML PREREQ: This $modelName cannot run ML"
exit 1
fi
fi

if [ "$modelName" = "MacBook" ]; then
if [ "$modelIdMajor" -ge "5" ]; then
echo "------ ML PREREQ: This $modelName can run ML"
exit 0
else
echo "------ ML PREREQ: This $modelName cannot run ML"
exit 1
fi
fi

if [ "$modelName" = "MacBookPro" ]; then
if [ "$modelIdMajor" -ge "3" ]; then
echo "------ ML PREREQ: This $modelName can run ML"
exit 0
else
echo "------ ML PREREQ: This $modelName cannot run ML"
exit 1
fi
fi

if [ "$modelName" = "MacBookAir" ]; then
if [ "$modelIdMajor" -ge "2" ]; then
echo "------ ML PREREQ: This $modelName can run ML"
exit 0
else
echo "------ ML PREREQ: This $modelName cannot run ML"
exit 1
fi
fi

if [ "$modelName" = "Macmini" ]; then
if [ "$modelIdMajor" -ge "3" ]; then
echo "------ ML PREREQ: This $modelName can run ML"
exit 0
else
echo "------ ML PREREQ: This $modelName cannot run ML"
exit 1
fi
fi

echo "------ ML PREREQ: Model not found"

exit 1

Thursday, May 31, 2012

Fix for iPhone Yellow Screen of Death (YSoD)

My iPhone 3GS on jailbroken iOS 4.3.5 just "died" and showed a yellow screen when trying to charge it or turn it on. I found some solutions on the web, but none of them worked. Here is what worked for me:

1. Connect the iPhone to your computer
2. Open iTunes
3. Put the iPhone in DFU mode (if you don't how to that, google it)
4. Let it charge for about 15 minutes
5. Go to iTunes and restore the iPhone

Done!

Hope this will help someone...

Friday, February 17, 2012

Temporary fix for SAMBA-printing in Lion

It seems like the "AuthInfoRequired" fix is working. At least were I work... Yesterday, when I went to bed, I came up with something!
What if I create a LaunchDaemon that triggers on changes to /etc/cups/printers.conf and that LaunchDaemon then runs a script that fixes the faulty settings in printers.conf?

Said and done, here are the result (sorry for the formatting, blame blogger):

The LaunchDaemon (located in /Library/LaunchDaemons)

<?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>Label</key>
<string>se.lnu.cupsfix</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Scripts/cupsfix.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>/private/etc/cups/printers.conf</string>
</array>
</dict>
</plist>
The script (/Library/Scripts/cupsfix.sh)
#!/bin/bash
# cupsfix.sh by Marcus Jaensson
# Must be run as root
### VARIABLES
PRINTERLIST=`lpstat -p | awk '{print $2}'`
LOGF="/var/log/lnu_cupsfix.log"

### FUNCTIONS
function log()
{
echo -e "[`date "+%y%m%d %H.%M.%S"`]\t$1"
echo -e "[`date "+%y%m%d %H.%M.%S"`]\t$1" >> $LOGF
}

### SCRIPT
for printer in $PRINTERLIST; do
if [[ -z `lpoptions -p $printer | grep "auth-info-required=username,password"` ]]; then
log "Printer $printer has faulty settings, will now correct this"
lpadmin -p "$printer" -o auth-info-required=username,password
else
log "Printer $printer has the correct settings, have nothing to do"
fi
done
exit 0


Provided "as is"... 

Monday, February 6, 2012

[Swedish] "Spela in" från SVT Play med rtmpdump

Länge sedan sist, har varit mitt uppe i ett projekt att införa Windows 7...

Så här kommer en liten uppdatering, har inget med deployment att göra, men jag ville ändå tipsa om det!

Om du tex vill se "Hårdrockens historia" eller "Äkta människor" på vägen till jobbet, men har taskig mottagning längs vägen, kan du i förväg "spela in" det du vill se med hjälp av "rtmpdump"!

1. Ladda ner och installera rtmpdump (för OS X 10.7) här: http://trick77.com/2011/07/30/rtmpdump-2-4-binaries-for-os-x-10-7-lion/

2. Gå till det program du vill spela in i tex Chrome.

3. Välj att visa källkoden

4. Sök efter "rtmpe"

5. Du hittar nu fyra URLer som är i princip likadana. Leta upp den bitraten du vill ladda hem. (2400 är 720p). Kopiera URLen, till och med .mp4, alltså inte med ",bitrate:2400".

6. Öppna terminalen och skriv: rtmpdump -r rtmpe://[URL] -o ~/Desktop/[OUTPUT.mp4]

7. Nu börjar den ladda hem!

8. För att kunna se den i QuickTime eller iPhone, konvertera med tex Handbrake (http://handbrake.fr/) I VLC kan du se på filen direkt.

Tuesday, October 18, 2011

DeployStudio rc129 and new MacBook Airs

The new Air shipped with a custom built 10.7.1, but now 10.7.2 supports these systems.
DeployStudio rc129 (latest stable) isn't capable of doing NetBoot sets from a 10.7.2 system, but the latest nightly is (111010). So how would you do to be able to NetBoot Airs with a DeployStudio NetBoot set and still use the latest stable release on the server?

Simple. Create a NetBoot set with the latest nightly on a 10.7.2 install (preferably in Fusion or Parallels). Take a copy of DeployStudio Admin (rc129) and copy into the NetBoot set and replace the one installed (111010).

Done! Now enable the NetBoot set on the server, and NetBoot the Air. Of course you have to have an 10.7.2 image to apply. Just download Lion from Mac App Store and extract the InstallESD.dmg and run InstaDMG or similar.

Thursday, October 6, 2011

Apple Warranty Info script

Made a quick bash-script to check warranty information for a specific serial number.

Usage: warrantyinfo.sh OR warrantyinfo.sh

If you do not specify a serial number as an argument, the script will use the serial number from the machine that it is run on.

UPDATE: Made it compatible with iPhones. I do not own an iPad and therefor no iPad serial number, so I haven't tested it with iPads.

#!/bin/bash

# Check warranty
# Usage: $0 serialnumber OR just $0

INFOF="/tmp/warranty.info"
INFOF2="/tmp/warranty_lines.info"

if [ -z "$1" ]; then
 echo "No serial number specified, assuming it's the local machine's serial"
 SN=$(system_profiler SPHardwareDataType | grep "Serial Number" | awk -F': ' '{print $2}')
else
 SN="$1"
fi

if [ -z "$SN" ]; then
 printf "No serial number specified and no serial number automatically found\n"
 printf "Exiting\n\n"
 exit 1
fi

# Get raw info
printf "Getting warranty info from Apple"
curl --silent https://selfsolve.apple.com/warrantyChecker.do?sn=$SN -o "$INFOF"

# Checking if it's an iPhone
IPHONESTAT=$(cat "$INFOF" | awk -F'IS_IPHONE' '{print $2}' | awk -F'"' '{print $3}')

if [ "$IPHONESTAT" = "Y" ]; then
 # This is an iPhone, check iPhone-specific data
 PRODUCT=$(cat "$INFOF" | awk -F'PROD_DESCR' '{print $2}' | awk -F'"' '{print $3}')
 PARTDESCR=$(cat "$INFOF" | awk -F'PART_DESCR' '{print $2}' | awk -F'"' '{print $3}')
 ICCID=$(cat "$INFOF" | awk -F'ICCID' '{print $2}' | awk -F'"' '{print $3}')
 REGISTERED=$(cat "$INFOF" | awk -F'IS_REGISTERED' '{print $2}' | awk -F'"' '{print $3}')
 ACTIVATED=$(cat "$INFOF" | awk -F'ACTIVATION_STATUS' '{print $2}' | awk -F'"' '{print $3}')
 IMEI=$(cat "$INFOF" | awk -F'AP_IMEI_NUM' '{print $2}' | awk -F'"' '{print $3}')
 WARRANTY=$(cat "$INFOF" | awk -F'HW_COVERAGE_DESC' '{print $2}' | awk -F'"' '{print $3}')
 CARRIER=$(cat "$INFOF" | awk -F'CARRIER' '{print $2}' | awk -F'"' '{print $3}')
 PURCHDATE=$(cat "$INFOF" | awk -F'PURCHASE_DATE' '{print $2}' | awk -F'"' '{print $3}')
 
 # Make it nicer
 if [ "$REGISTERED" = "Y" ]; then
  REGISTERED=Yes
 else
  REGISTERED=No
 fi
 
 if [ "$ACTIVATED" = "Y" ]; then
  ACTIVATED=Yes
 else
  ACTIVATED=No
 fi
 
 # Display data
 clear
 printf "\033[1mWarranty Information\033[m\n\n"
 printf "Product:\t\033[1m$PRODUCT\033[m\n"
 printf "Description:\t\033[1m$PARTDESCR\033[m\n"
 printf "Serial Number:\t\033[1m$SN\033[m\n"
 printf "ICCID:\t\t\033[1m$ICCID\033[m\n"
 printf "IMEI:\t\t\033[1m$IMEI\033[m\n"
 printf "Purchase Date:\t\033[1m$PURCHDATE\033[m\n"
 printf "Warranty:\t\033[1m$WARRANTY\033[m\n"
 printf "Registered:\t\033[1m$REGISTERED\033[m\n"
 printf "Activated:\t\033[1m$ACTIVATED\033[m\n"
 printf "Carrier:\t\033[1m$CARRIER\033[m\n\n\n"
else
 # This is a Mac, check Mac data
 # Get product description first as it may contain comma (,) 
 PRODUCT=$(cat "$INFOF" | awk -F'PROD_DESCR' '{print $2}' | awk -F'"' '{print $3}')
 DAYSREM=$(cat "$INFOF" | awk -F'DAYS_REM_IN_COV' '{print $2}' | awk -F'"' '{print $3}')
 PURCHDATE=$(cat "$INFOF" | awk -F'PURCHASE_DATE' '{print $2}' | awk -F'"' '{print $3}')
 ENDDATE=$(cat "$INFOF" | awk -F'COV_END_DATE' '{print $2}' | awk -F'"' '{print $3}')

 # Display data
 clear
 printf "\033[1mWarranty Information\033[m\n\n"
 printf "Product:\t\033[1m$PRODUCT\033[m\n"
 printf "Serial Number:\t\033[1m$SN\033[m\n"
 printf "Purchase Date:\t\033[1m$PURCHDATE\033[m\n"
 printf "End Date:\t\033[1m$ENDDATE\033[m\n"
 printf "Days remaining:\t\033[1m$DAYSREM\033[m\n"

 printf "\n\n"
fi

exit 0



Thursday, August 25, 2011

rpcclient is gone from Lion

Just discovered that rpcclient is gone from Lion. I guess this is because Apple got rid of SAMBA. But does anyone know if there are any other tool that does the same thing as rpcclient?