Category: Software

Headless uTorrent Linux server in OpenVZ

By , 2010-06-13 21:10

Yes, I know, another Linux post. What can I say, this is what I do these days.

I’ve been running a Windows server in a kvm VM just to be able to run uTorrent. This was overkill, had a crazy amount of overhead, and was unstable (downloading to a share on my Samba server). Today I decided to attempt a more efficient solution: uTorrent in Wine. (Yes, there are other BitTorrent clients, and even… NATIVE Linux clients, but I’ve found none of them match the speed of uTorrent for my connection except for kTorrent. However, I don’t have an Android and/or iPhone app to remote control kTorrent.) Wine is a supported platform, according to the uTorrent website, however I wanted to run it on a headless OpenVZ container, and not on a standard desktop Linux distro. Should still be pretty simple, but knowing me, I might forget something next time I try and set this up, so I’ll document it here.

  1. Create a fresh VZ container. I used the Proxmox Debian 6.0 (squeeze) – standard i386 template.
  2. Edit /etc/apt/sources.list to point to a fast mirror in Canada (iweb!)
    deb http://debian.mirror.iweb.ca/debian squeeze main contrib non-free
    deb http://debian.mirror.iweb.ca/debian-security squeeze/updates main contrib non-free
  3. run an apt-get update && apt-get upgrade
  4. apt-get install wine sudo xterm openbox tightvncserver
  5. adduser matt
  6. add google repo: http://www.google.com/linuxrepositories/apt.html
  7. install Google Chrome
  8. wget http://download.utorrent.com/2.0.2/utorrent.exe
  9. From another PC: ssh -Y matt@openvz-container
  10. wine winecfg
  11. run vncserver and set a password.
  12. run wine utorrent.exe
  13. Enable Web UI

Next steps:

  1. Set up Dropbox for easy adding of torrents: http://wiki.dropbox.com/TipsAndTricks/TextBasedLinuxInstall
  2. Make uTorrent and VNC server run on container startup*
  3. Create a VZ mount script so that torrents download outside of /vz area.

* For this I used a cool script obtained from http://www.abdevelopment.ca/blog/start-vnc-server-ubuntu-boot :

  1. Modify your ~/.vnc/xstartup to start the programs you want (gnome-session, lxde-session, utorrent, etc.)
  2. Save the following script as /etc/init.d/vncserver. Change
    export USER="mythtv"

    to the user you want to run the VNC session for.

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          vncserver
# Required-Start:    networking
# Default-Start:     3 4 5
# Default-Stop:      0 6
### END INIT INFO
 
PATH="$PATH:/usr/X11R6/bin/"
 
# The Username:Group that will run VNC
export USER="mythtv"
#${RUNAS}
 
# The display that VNC will use
DISPLAY="1"
 
# Color depth (between 8 and 32)
DEPTH="16"
 
# The Desktop geometry to use.
#GEOMETRY="x"
#GEOMETRY="800x600"
GEOMETRY="1024x768"
#GEOMETRY="1280x1024"
 
# The name that the VNC Desktop will have.
NAME="my-vnc-server"
 
OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
 
. /lib/lsb/init-functions
 
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
 
stop)
log_action_begin_msg "Stopping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
 
restart)
$0 stop
$0 start
;;
esac
 
exit 0

For more info, see the source link.

Setting up Samba on Debian

By , 2010-06-05 10:30

Trying to set up Samba on a Debian server so that shares can be browsed as a guest, and user-authentication is optional. IIRC this is the default behaviour on Ubuntu.
After hours of messing around, I finally decided to grab the /etc/samba/smb.conf from and ubuntu machine and replace the debian one. And what do you know, it works.

seems the key directive is

usershare allow guests = yes

Ubuntu:

#======================= Global Settings =======================

[global]
 log file = /var/log/samba/log.%m
 passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
 obey pam restrictions = yes
 map to guest = bad user
 encrypt passwords = true
 passwd program = /usr/bin/passwd %u
 passdb backend = tdbsam
 dns proxy = no
 server string = %h server (Samba)
 unix password sync = yes
 unix extensions = no
 workgroup = WORKGROUP
 os level = 20
 syslog = 0
 panic action = /usr/share/samba/panic-action %d
 usershare allow guests = yes
 max log size = 1000
 pam password change = yes

Debian:

#======================= Global Settings =======================

[global]
 log file = /var/log/samba/log.%m
 passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
 obey pam restrictions = yes
 null passwords = yes
 encrypt passwords = yes
 public = yes
 passdb backend = tdbsam
 passwd program = /usr/bin/passwd %u
 unix extensions = no
 dns proxy = no
 server string = %h server
 unix password sync = yes
 workgroup = WORKGROUP
 os level = 20
 security = user
 syslog = 0
 panic action = /usr/share/samba/panic-action %d
 max log size = 1000
 pam password change = yes

Simple fix for Mac OS X 10.6.3 Samba Write Access problem – OS X Daily

By , 2010-06-02 21:53

Simple fix for Mac OS X 10.6.3 Samba Write Access problem – OS X Daily.

Why this hasn’t been fixed yet is beyond me.

Macfusion: The world in your Finder

By , 2010-03-22 20:41

Macfusion: The world in your Finder.

A handy gui to MacFUSE – user-space filesystem for Mac OS X

Enabling ATSC & QAM in Canada for Windows 7 RTM – Peter Near’s Blog

By , 2010-02-12 18:16

Enabling ATSC & QAM in Canada for Windows 7 RTM – Peter Near’s Blog.

Today, I wanted to PVR the Vancouver 2010 opening ceremonies in HD, but was dismayed to find that Windows Media Center does NOT support ATSC if your region is set to Canada. Fortunately resourceful users have found a workaround patch. See link above.

Snow Leopard on Dell Inspiron 640m/e1405 UPDATED

By , 2010-01-18 09:38

Update 3: For anyone looking for it: 10.6.2-IONDRVSupport.kext

Update 2: My Inspiron worked great, but took FOREVER to boot because it was “Waiting for DSMOS”. Today I finally took the time to do a quick google and found the solution:

in terminal, type “sudo chown root:wheel /” and restart

It seems the owner of the root somehow gets messed up, probably after Chameleon install (just a wild guess).
Thanks to bertmannaustria @ InsanelyMac! (Original thread)

Update: For anyone who is having problems, I have a new kext package. This is a zip of my /Extra folder that I’m using right now on my Inspiron 640m. 640mExtra-Updated Also my system is 32-bit only, so I can’t guarantee this will work in 64-bit mode.

After much trial and error, I finally found the proper procedure for installing Snow Leopard onto my Inspiron 640m. For reasons that I cannot fathom, I was unable to perform the chameleon cdboot/swap to boot from the retail Snow DVD. It might be my DVD drive, or some other cause, but I didn’t bother finding out; I just took the hard drive out of my laptop and connected it via USB to my iMac.

Here’s the procedure that I followed yesterday to install Mac OS X 10.6.0 on my Inspiron 640m. It’s tested, working and stable, everything is great except that this laptop does NOT wake from sleep. It goes to sleep just fine, just won’t wake. Here goes:

  1. Remove hard drive from the Inspiron. Connect it using a hard drive dock or USB to SATA enclosure/adapter.
  2. Put Mac OS X Snow Leopard DVD into existing Mac (Hackintosh or real mac, doesn’t matter).
  3. Using Disk Utility, partition your Inspiron’s drive as you like, using a GUID Parition table.
  4. With your Snow Leopard DVD mounted, in Finder, choose Go to folder. In the box that comes up type “/Volumes/Mac OS X Install DVD/System/Installation/Packages”.
  5. This will open a folder with a lot of install pkgs. Find OSInstall.mpkg and double-click it.
  6. Follow the steps to install Snow Leopard, making sure to pick the proper drive for installation.
  7. Once the installation is done, eject your USB drive and put the hard drive back in your Inspiron.
  8. Download the Inspiron6400.iso and burn it to a CD.
  9. Power up your Inspiron and boot from the CD
  10. From the Chameleon menu, use the arrow keys to select the hard drive.
  11. Type the following boot arguments: -v cpus=1
  12. Your Inspiron should boot into Snow Leopard. Congratulations!
  13. Download my 2 Inspiron kext packages: Inspiron640mExtensions Inspiron640mExtra
  14. In the Inspiron640mExtensions, you will find kext helper. Run it, and drag AppleBCM440XEthernet.kext, VoodooBattery.kext and VoodooHDA.kext onto it, enter password and install.
  15. You will also find the Chameleon RC4 installer. Run it, but DON’T reboot at the end.
  16. Extract the Inspiron640mExtra.zip. Copy the contents of the extracted Extra folder to /Extra.
  17. Remove the Inspiron6400 CD and reboot. hopefully your laptop should boot fine from the hard drive.

Just a few notes:

  • I cannot get the laptop to wake from sleep. As such, the SleepEnabler.kext is not included. I also included the InsomniaX app which you might choose to install to prevent your laptop from sleeping.
  • This method seems to be update-safe. I just updated to 10.6.2 using Software Update and all is ok.
  • When the clamshell display is closed, the Dell BIOS or something blanks the screen. Mac OS cannot re-enable the screen and you’ll be stuck staring at a black LCD. To circumvent this, set one of your screen corners in Expose prefs to put the display to sleep. If ever you find yourself with a black screen, move the cursor to that corner to force the display to sleep, then wake it up again.
  • The Intel PRO 3945 ABG wireless card that came with my Inspiron (and all Inspirons that are branded “Centrino”) does NOT work with Mac OS X. I swapped mine for a Dell 1505 Draft-N card (cheap on eBay) that works perfectly out-of-the-box.
  • The Broadcom 440x ethernet card seems to work fine, I tested it briefly with some light web browsing. However, the original thread says that the driver occasionally drops connections, so YMMV.
  • Finally, a quick thanks to all the OSX86 devs. None of the kexts found here are made by me, all credit goes to the original authors. I found all the necessary info over at the InsanelyMac forum.

How to extract uniq IPs from apache via grep, cut, and uniq

By , 2010-01-10 19:35

grep ‘Googlebot’ access.log | cut -d' ' -f1 | sort | uniq

Fantastic little command.

via » How to extract uniq IPs from apache via grep, cut, and uniq Dan Collis-Puro.

No wireless networks and no IP detected on Windows

By , 2009-12-22 10:42

Today I booted up my Windows Server 2003 laptop. All seemed OK, but I couldn’t get an IP address on my wired connection and my wireless card didn’t detect any APs. I thought i would have to reimage my machine, but a quick google brought up this page:

Tech Support Guy Forums – View Single Post – Solved: Wireless networks detected – no wireless networks found.

In a command prompt window,
Reset TCP/IP stack to installation defaults, type: netsh int ip reset reset.log

Reset WINSOCK entries to installation defaults, type: netsh winsock reset catalog

And it works!

Converting Adium XML chat logs to HTML format

By , 2009-12-18 11:39

http://trac.adium.im/ticket/6569

XSLT could be used to transform the .chatlog files to HTML. Attached is an XSLT stylesheet that I have written to do this. The libxslt library is present on all versions of Mac OS X since 10.2, and its command-line tool can be invoked in a sub-shell using system(3):

xsltproc -o 'foobar (2007-03-08T09.19.11-0700).html' format-html.xsl \
            'foobar (2007-03-08T09.19.11-0700).chatlog'

Rooting the PBX

By , 2009-12-14 21:44

My home PBX was installed and working well. However, today I discovered that my VoIP provider started blocking outgoing calls from the Asterisk user agent. The fix is to edit /etc/asterisk/sip.conf and change the useragent line. However, the distro I chose was very much a PBX appliance. No SSH, no shell, only Web UI access. But, I knew it was a Linux box, probably CentOS or RHEL based. So i decided I’d try my hand at retaking control of the system.

First step was to boot into single-user mode. This was quite easy. Just interrupt GRUB and add “single” to the kernel options.

Once at the shell prompt, you might want to add a regular user.

adduser matt

Then, try changing the root password.

passwd root

Unfortunately this does not work. It fails with “Authentication Token Manipulation Error”. To fix this, use pwconv. (Thanks to mohammedz)

Then try passwd root again, it should work this time.

Next, enable ssh. Run chkconfig sshd on.

Now, edit /etc/asterisk/sip.conf and change the useragent. 🙂

Custom theme by me. Based on Panorama by Themocracy