Mounting network shares on my macbook pro based on location

6 03 2009

Here’s how I do it on my MacBook Pro (thanks smanek from this hint):

  1. Install sleepwatcher and install it so that it runs during bootup
  2. Create .wakeup file in home directory. Sleepwatcher’s /etc/rc.sleep and /etc/rc.wakeup will execute whatever is in the user’s /home/.wakeup or /home/.sleep files whenever the Mac goes to sleep or wakes up. Here’s what I have in my .wakeup file which will mount my home network shares ONLY if I am at home:

$ cat .wakeup
#!/bin/sh
# Wait for network
/bin/sleep 10
status_wifi=$(/sbin/ifconfig en1 | /usr/bin/grep status | /usr/bin/awk ‘{print $6}’)
status_ethernet=$(/sbin/ifconfig en0 |/usr/bin/grep status| /usr/bin/awk ‘{print $6}’)

#Check if wifi is up
if [ "$status_wifi" == "inactive" ]; then
 echo “No Wifi”
else
 echo “Got Wifi”
 broadcastnet_wifi=$(/sbin/ifconfig en1 | /usr/bin/grep inet |/usr/bin/grep broadcast | /usr/bin/awk ‘{print $6}’| tr “.” ” “)
 oct1_wifi=$(echo $broadcastnet_wifi | /usr/bin/awk ‘{print $1}’ )
 oct2_wifi=$(echo $broadcastnet_wifi | /usr/bin/awk ‘{print $2}’)
 #Check if Wifi is on home network
 if [ "$oct1_wifi" -eq "192" ] && [ "$oct2_wifi" -eq "168" ]; then
  echo “Wifi is on home network”
  echo “Mounting SMB Shares”
  /sbin/mount_smbfs //(username):(password)@(server)/(share) /Users/echua/media
  /sbin/mount_smbfs //(username):(password)@(server)/(share) /Users/echua/download
  echo “Mounting NFS Shares”
  /sbin/mount (server):(path-to-share) /Users/echua/pics
  exit
 else
  echo “Wifi isn’t on home network”
 fi
fi

#check if ethernet is up
if [ "$status_ethernet" == "inactive" ]; then
 echo “No Ethernet”
 unset status_ethernet
else
 echo “Got Ethernet”
 broadcastnet_ethernet=$(/sbin/ifconfig en0 | /usr/bin/grep inet|/usr/bin/grep broadcast | /usr/bin/awk ‘{print $6}’| tr “.” ” “)
 oct1_ethernet=$(echo $broadcastnet_ethernet | /usr/bin/awk ‘{print $1}’ )
 oct2_ethernet=$(echo $broadcastnet_ethernet | /usr/bin/awk ‘{print $2}’)
 if [ "$oct1_ethernet" -eq "192" ] && [ "$oct2_ethernet" -eq "168" ]; then
  echo “Ethernet is on home network”
  echo “Mounting SMB Shares”
  /sbin/mount_smbfs //(username):(password)@(server)/(share) /Users/echua/media
  /sbin/mount_smbfs //(username):(password)@(server)/(share) /Users/echua/download
  echo “Mounting NFS Shares”
  /sbin/mount (server):(path-to-share) /Users/echua/pics
 exit
 else
  echo “Ethernet isn’t on home network”
  exit
 fi
fi





Time Machine disk filled up, then got corrupted

19 11 2008

I got an error msg saying that the Time Machine disk was full. Under normal circumstances TM is supposed to just overwrite the oldest backup. But in my case I started getting all kinds of errors from “The backup disk could not be mounted” to “The backup volume is read only”. I tried running Disk Utility to repair the sparse bundle, but to no avail (it kept reporting the invalid sibling link error). I even tried using Disk Warrior to repair (rebuild) the sparse bundle backup directory, but that also did not work. The last resort was to use the solution found here. While TM was mounted and while I could see the backup disk, I disabled TM and ran the following:

hdiutil attach -nomount -readwrite (server-name)_(mac-address).sparsebundle

This command took a while to return, but when it did it showd:

/dev/disk1            BackupOf(server-name)

I then ran

fsck_hfs -rf /dev/disk1

And this took a few hours (not sure how long exactly, I just let it run overnight). This produced the following:

** /dev/disk1**
Checking Journaled HFS Plus volume.**
Detected a case-sensitive catalog.**
Checking Extents Overflow file.**
Checking Catalog file.**
Rebuilding Catalog B-tree.**
Rechecking volume.**
Checking Journaled HFS Plus volume.**
Detected a case-sensitive catalog.**
Checking Extents Overflow file.**
Checking Catalog file.Incorrect number of thread records(4, 13716)**
Checking multi-linked files.**
Checking Catalog hierarchy.
Invalid directory item count(It should be 0 instead of 1)
Invalid directory item count(It should be 3 instead of 4)
Incorrect folder count in a directory (id = 3795486)(It should be 0 instead of 1)**
Checking Extended Attributes file.**
Checking multi-linked directories.**
Checking volume bitmap.**
Checking volume information.
Invalid volume free block count(It should be 37267681 instead of 37310834)
Volume Header needs minor repair(2, 0)**
Repairing volume.**
Rechecking volume.**
Checking Journaled HFS Plus volume.**
Detected a case-sensitive catalog.**
Checking Extents Overflow file.**
Checking Catalog file.**
Checking multi-linked files.**
Checking Catalog hierarchy.**
Checking Extended Attributes file.**
Checking multi-linked directories.**
Checking volume bitmap.**
Checking volume information.**
The volume Backup of Bhaal was repaired successfully.

At this point I re-enabled TM and initiated a backup. Voila! It worked! Here’s the oldest backup to date:





Configuring HP C6180 All-In-One priter on CentOS

13 10 2008

From Gnome:

  1. Go to System->Administration->Printing
  2. New Printer->Type a printer name->Forward
  3. Select ‘Other’
  4. Use ‘hp:/net/Photosmart_C6100_series?ip=(ipaddress)’ as the Device URI, replacing (ipaddress) with your printer’s ipaddr
  5. Click Forward and select the appropriate driver (I used Photosmart 7150)




Disabling Slow iPhone Automatic Backups

23 08 2008

I got tired of iTunes automatically doing a backup of my iPhone everytime I plugged it in. I just want it to do a regular sync and I will back it up manually. Since I added so many apps the backups are just taking too long to complete. Here’s what I did to disable the automatic backups:

(From http://klauskjeldsen.dk/2008/08/05/iphone-3g-disable-slow-itunes-backup-mac-and-windows/)

Mac users:

  1. Quit iTunes.
  2. Open a Terminal (Applications > Utilities > Terminal)
  3. Type or copy the following command:
    defaults write com.apple.iTunes AutomaticDeviceBackupsDisabled -bool true
  4. Open iTunes.
  5. Connect the iPhone.
  6. Syncs without backing up.

To enable automatic backup in iTunes again use this command instead:

defaults write com.apple.iTunes AutomaticDeviceBackupsDisabled -bool false

Note: If you previously have used the command line option that entirely disables the backup feature, then type this command as well to enable to backup process:

defaults write com.apple.iTunes DeviceBackupsDisabled -bool false

Recommendation: If you choose to disable the automatic backup process, it would be a good idea to manually making a backup it once a while to get a safe copy of text messages, call log and like (just right-click your iPhone icon in iTunes).





Installing VMWare Server 1.0.6 on Fedora 9i

13 08 2008

Steps I took to install VMWare Server 1.0.6 on Fedora 9:

$ yum install kernel-devel xinetd make gcc libXtst perl-devel perl-ExtUtils-Embed
$ rpm -iv VMware-server-1.0.6-91891.i386.rpm







Follow

Get every new post delivered to your Inbox.