Tuesday, December 3, 2013

Quick and dirty social media links

If you're looking for a quick way to get a few social media sharing links on your site without messing with JavaScript and remotely hosted widgets, here is a simple solution.  Below are some HTML snippets and images you can throw together in just a few minutes.

Sample link bar:
     

Facebook code:
<a href="http://www.facebook.com/sharer.php?u=http://blog.slor.net" target="_blank" title="Share on Facebook"><img src="http://www.slor.net/images/facebook.png" /></a>

Twitter code:
<a href="http://twitter.com/share?text=An%20interesting%20blog&url=http://blog.slor.net" target="_blank" title="Share on Twitter"><img src="http://www.slor.net/images/twitter.png" /></a>

Google+ code:
<a href="https://plus.google.com/share?url=http://blog.slor.net" target="_blank" title="Share on Google+"><img src="http://www.slor.net/images/googleplus.png" /></a>

Thursday, September 26, 2013

Turning your Raspberri Pi into a wireless bridge

I recently found myself in need of a wireless bridge.  Having also recently purchased a Raspberry Pi and not wanting to spend money on a dedicated bridge (costing as much or more than the Pi), I decided I'd figure out how to make my Pi serve that function for me.  It took a little searching and piecing together of web articles to find the simplest formula to get there, and it works pretty well.

Here's what you need to get started:
- Raspberry Pi (duh) - I recommend model B revision 2.0.
- MicroUSB power supply - The more mA the better.
- USB wireless network adapter - Mine happens to be a generic RTL8192CU-based unit that came as part of a starter kit with my Pi.
- USB keyboard.
- HDMI or video monitor.
- Pi case (optional).
- 4 GB or larger SDHC card - I used a Wintec 16 GB MicroSDHC with adapter.
- Raspbian distribution image - The latest raw image can be obtained from the Raspberry Pi website.
- A way to write Pi images to the SD card - For Windows, Win32 Disk Imager is a great choice.


Step 1: Copy Raspbian image to SD card

If you own a Raspberry Pi, you probably already know how to do this.  Using Win32 Disk Imager, it is a simple matter of browsing to the downloaded Raspbian image file, making sure the correct device is selected to write to, and then clicking the Write button.


Assuming no errors during the write process, you should now have a bootable SD card to put in your Pi.


Step 2: Hook up your system and set up Raspbian

It doesn't get much easier than this.  If you own a Pi, you certainly already know how to hook up your peripherals and power it up.  At the end of first boot, you'll be presented with the raspi-config screen and can do any customization you need there.  I recommend at least using the first item to expand your file system to fill available space.  Once you're done, you'll be able to log into the terminal session.


Step 3: Enable both network interfaces

You'll need to update your network configuration so that both the wired and wireless interfaces are enabled automatically at boot time.  First file to edit (as superuser) is /etc/wpa_supplicant/wpa_supplicant.conf.  Assuming your wireless access point uses WPA2 pre-shared keys, replace the contents of the file with this:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="Your SSID Here"
    proto=RSN
    key_mgmt=WPA-PSK
    pairwise=CCMP TKIP
    group=CCMP TKIP
    psk="YourPresharedKeyHere"
}

Make sure you use your own SSID and pre-shared key where appropriate.  If you are not using WPA2, you'll need to find and use the correct parameters for your access point.  Next file you need to mess with is /etc/network/interfaces.  Replace the contents of the file with this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Before moving on, you should test this configuration to make sure the wireless is connecting properly.  Run these two commands:

# sudo ifdown wlan0
# sudo ifup wlan0

You'll likely see three ioctl warnings during the ifup command.  Those are ok and can be ignored.  From there, you can use the "ifconfig" command to check on status of both eth0 and wlan0 or "iwconfig" command to get detailed status for wlan0.  Finally, if you want to make sure things will be enabled properly at boot time, this is a good time to reboot the Pi and see.


Step 4: Create the bridge

Run the following commands to install bridge-utils and create the bridge br0 between wlan0 and eth0:

# sudo apt-get install bridge-utils
# sudo brctl addbr br0
# sudo brctl addif br0 wlan0 eth0

After making a backup copy of /etc/network/interfaces, update its contents to this:

auto lo
iface lo inet loopback

iface eth0 inet manual

auto wlan0
iface wlan0 inet manual

auto br0
iface br0 inet dhcp
   bridge_ports wlan0 eth0
   bridge_stp off
   bridge_maxwait 5

wpa-iface wlan0
wpa-bridge br0
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

That should do it.  With the wpa-bridge line, you don't need to mess with ebtables or anything to spoof mac incoming and outgoing MAC addresses for the wireless side.


Step 5: Make it so

If you have your wireless and wired ports currently hooked up to the same LAN, unplug the wired connection now.  Reboot.  Once your system reboots, you should have a Raspberry Pi bridge running in your environment.  You can plug a single machine or switch into the wired ethernet port, and anything there will be bridged through the wireless access point on the other side.

Hope this helps someone.  If it doesn't, though, don't blame me.

Tuesday, August 20, 2013

Installing Mac OS X Lion 10.7.5 on a Lenovo ThinkPad X61

So you want an Intel-based Mac to play with but all you have laying around are a bunch of old non-Mac PCs.  If one of those happens to be a Lenovo ThinkPad X61 laptop, you are in luck.


Disclaimer: Under no circumstances do I guarantee that you will not brick your system by following the instructions below.  You follow this guide at your own risk, I will not be held responsible for any damages resulting from your efforts to build a Hackintosh.  Only YOU can prevent forest fires.  I suggest taking a first pass through the documented instructions to get a feel for the process and also to get some file downloads started before you get to work on the X61.


My target machine's configuration:

- Model: Lenovo ThinkPad X61 laptop
- CPU: 2 GHz Intel Core 2 Duo SV T7300
- Memory: 4 GB PC-5300 RAM
- Disk: Seagate ST500LT012 5400 RPM SATA-II hard drive
- Graphics: Intel GMA X3100
- Sound: Intel High-Definition Audio (SoundMAX AD1981HD)
- Network: Intel 82566MM Gb Ethernet
- Network: Intel PRO/Wireless 3945ABG
- Expansion: ThinkPad X6 UltraBase


What you will need:

- Your X61, with or without UltraBase.
- USB keyboard and mouse for temporary use with the X61.
- Readily accessible PC.  Doesn't really matter what operating system, as long as it can burn .ISO and .DMG files.  For Windows, a great utility for this is TransMac.
- Blank CD and DVD media (one of each).
- USB drive for transferring files.
- A lot of patience.


Step 1: Update your BIOS (optional)

One annoying quirk with the stock X61 BIOS is that it only supports SATA I disk transfer speeds.  The hardware, on the other hand, can support SATA II.  If you have upgraded your internal hard drive like I have, you will benefit from updating to a third party BIOS.  You can read all about the Middleton BIOS here.

- To get started, grab the archive here.
- Burn the included .ISO file to CD-ROM and boot your X61 from it.  The BIOS update will take place immediately without any prompting.  It won't look like it's doing anything for a while, so be patient until you see the notice of completion.
- Reboot your X61 and make sure it still works.  If not, then you're probably done early with this project.


Step 2: Install Lion

You'll need to obtain a copy of the iATKOS L2 installation media.  You can read all about iATKOS L2 here, but we're not going to follow all the instructions listed.

- Grab the .torrent file for the L2 archive here and put your favorite torrent client to work.
- Burn the included .DMG file to DVD-ROM and boot your X61 from it.  The OS X installation procedure will start after a good amount of whirring by the DVD drive.
- Once you get to the Disk Selection page, go to the Utilities menu and run Disk Utility.  This has been known to occasionally lock up the X61.  If that happens, just start this step over and you're likely to succeed the next time.
- In Disk Utility, select the hard drive you want to install OS X onto.
- Click to the Partition section of the right pane.
- In the Partition Layout dropdown list, select 1 Partition.  Multiple partition support is doable but is beyond the scope of this guide.
- Open the Options dialog and select GUID Partition Table for the partition scheme.
- Use Lion for the partition name.  It can be changed later if you like.
- Select Mac OS Extended (Journaled) from the Format list.
- Click Apply, make sure you're about to destroy the correct disk, then click Partition.
- Once partitioning is done, quit Disk Utility.
- In the installer's Disk Selection page, make sure to tag the Lion volume as your installation target.
- Open the Customize dialog.  Most things should be left as default.
- The only change to make is to put a check on Drivers -> Main Hardware -> SATA/IDE -> AHCI SATA.  Then click OK.
- Now you should be ready.  Click Install!
- Kick back and relax.  It will take a while.
- After installation is complete, your X61 will reboot.  You will want to make sure it boots from the hard drive this time.

Did it boot into OS X?  If so, continue on.  If not, repeat this entire step until it does.


Step 3: Update some system files

On first boot, many system devices will be unavailable or not working properly.  This is where that gets fixed.

- Grab a few extras from here.
- And a bunch of .kext files from here.
- And tonymacx86's KextBeast from here.
- Put all of these on a USB drive and plug it into the X61.
- On the X61, extract Extra.zip.
- Copy the two .plist files into /Extra, overwriting the existing files.
- Copy DSDT.aml into /.
- Extract current-SLE.zip.
- Copy all of the .kext files to your Desktop.
- Extract KextBeast.zip.
- Run KextBeast and follow the prompts through completion to install kernel extensions specific to the X61.
- Restart the X61.

Still booting up OK?  You should now be able to use most system devices and unplug the USB keyboard and mouse if you like.  If you do unplug them, you'll want to disable the Bluetooth Assistant in your advanced Bluetooth preferences.  Your machine is now a stable OS X 10.7.2 Hackintosh.  You can pause here to set preferences as desired for networking and other aspects of the system.


Step 4: Update OS to 10.7.5

Do NOT use Software Updater to update your OS.  Instead, you'll want to download the standalone OS X 10.7.5 Combo Update.

- Grab the update from here.
- And a fixer-upper script from here.
- And make sure you still have the .kext files and KextBeast from Step 3.
- Install the 10.7.5 Combo Update, but do NOT restart the machine yet.
- Prior to allowing the updater to restart your machine,
- Extract mac-os-x-lion-10.7.5-update-fixer.zip.
- Open up a Terminal session and change to the directory containing the fixer files.
- Use this command to run the fixer-upper:
sudo ./UpdateFixer.sh
- At this point, you need to put all those .kext files from Step 3 back on the desktop.
- Run KextBeast again to put your X61-specific files extensions where they need to be.
- Now you can Restart you X61.

If it booted back up, you Hackintosh is now updated to OS X version 10.7.5!  If not, I'm afraid you're back to Step 2.


Step 5: Prevent CMOS corruption

There's an issue in the stock AppleRTC extension that will cause corruption in you CMOS settings after allowing your computer to go to sleep.  This is very annoying because it causes all your settings to be set back to default and also turns off your bluetooth device.

- To correct the issue, open a Terminal session on the X61 and use the following command to find and replace the offending bits:
sudo perl -pi -e 's|\x75\x30\x44\x89\xf8|\xeb\x30\x44\x89\xf8|; s|\x75\x3d\x8b\x75\x08|\xeb\x3d\x8b\x75\x08|' /System/Library/Extensions/AppleRTC.kext/Contents/MacOS/AppleRTC
- Reboot your X61.

You should now have a Hackintosh that is safe to put to sleep on occasion.


Step 6: Update the rest of the system software

You can now safely check for system updates using OS X's built-in updater.  Everything should install fine and leave your X61 in a still-working state.  If not, you know where Step 2 starts.


Step 7: Enjoy your Hackintosh!

You are now the proud owner of a Hackintosh X61.  You'll be the envy of all your friends.  Girls won't like you any more than they do now.


Hints:

- If your X61's bluetooth doesn't work or disappears after a future startup, reboot the X61 with a Linux LiveCD like Knoppix.  Once the bluetooth device has been activated in the BIOS, it will be available to OS X again next time it's booted.
- You'll notice the wireless networking, PCMCIA card reader, and SD card reader still do not work.  At this time, I don't have answers for supporting those devices.  This post will be updated if and when I make further progress.
- You'll also notice your Hackintosh is running the OS in 32-bit mode.  You can change it to 64-bit by editing org.Chameleon.boot.plist, but you will lose support for some of the built-in devices such as sound, keyboard, and trackpoint.
- I recommend turning off automatic system updates, just in case something comes along that could cause issues.  Hopefully that isn't likely, but you may want to ability to control the update process and check on any suspicious-looking updates.


Useful tools:

TransMac - A great app for managing Mac disk images on a Windows computer.  I used it to burn my iATKOS install DVD.
Carbon Copy Cloner - Very useful for duplicating disk content on your Hackintosh.  After preparing a second hard drive's boot loader with iATKOS, I use CCC to keep an exact copy of my system drive in case I screw it up and need a quick restore.
Vine VNC - Way better than Lion's built-in VNC server, and it's FREE!
Xcode - I don't know much about developing apps for OS X, but I do know Xcode is an easy way to get GCC and related build tools installed on my Hackintosh.
MacPorts - It can't get any easier to install many of the open source tools I'm used to using on other *nix-based platforms.


Final notes:

I hope this guide has helped someone.  Please purchase your own copy of OS X Lion before attempting your build.  I cannot vouch for the legalities of running OS X on alternative hardware, but I'm pretty sure Apple would like you to pay for any software you use.  No Apple software is, or ever will be, provided by this site.

Thanks to the iATKOS, tonymacx86, and OSx86 teams for making this doable!