Fixing Synergy and Mac OS X Lion (Mouse works but keyboard doesn’t work)

June 4th, 2012

I’ve just installed synergy on my Mac OS X Lion. I found that my mouse works, but my keyboard doesn’t. This is a known bug documented here. The fix is targeted for version 1.4.9, which as of the time of this writing, is not yet available.

The workaround: downgrade to synergy 1.3.1 on both the client and the server. Downloadable here.

How to Install Synergy 1.3.1 with Homebrew Package Manager

0) Make sure you have Homebrew installed.  If you don’t, instructions are here.  Note: homebrew is a very nice package manager, but it takes some effort to install.  If you don’t want to go through the hassle, try installing synergy directly.  Or try synergyKM, which has a GUI for Mac and uses Synergy 1.3.1 under the hood.

1) Get the Homebrew formula on your synergy server for version 1.3.1.  Open a terminal (Finder > Applications > Utilities > Terminal). Check out the formula using git.

Ryans-MacBook-Pro$ cd /usr/local && brew versions synergy
1.3.8    git checkout da29cdc Library/Formula/synergy.rb
1.3.6p2  git checkout 2e7cbfe Library/Formula/synergy.rb
1.3.7    git checkout 86c5ddb Library/Formula/synergy.rb
1.3.6    git checkout c7139db Library/Formula/synergy.rb
1.4.2    git checkout e46d519 Library/Formula/synergy.rb
1.3.1    git checkout 6144260 Library/Formula/synergy.rb
Ryans-MacBook-Pro $ git checkout 6144260 Library/Formula/synergy.rb

2) Verify that you’re now pointing to synergy 1.3.1.

Ryans-MacBook-Pro:local$ brew info synergy
synergy 1.3.1
http://sourceforge.net/projects/synergy2/
Not installed
https://github.com/mxcl/homebrew/commits/master/Library/Formula/synergy.rb

3) Install synergy

Ryans-MacBook-Pro:local$ brew install synergy
==> Downloading http://downloads.sourceforge.net/project/synergy2/Binaries/1.3.1/synergy-1.3.1-1.OSX.tar.gz
######################################################################## 100.0%
/usr/local/Cellar/synergy/1.3.1: 5 files, 2.8M, built in 24 seconds

4) Revert your homebrew formula back to the lastest, using git.

Ryans-MacBook-Pro:local$ git checkout master Library/Formula/synergy.rb

5) Repeat steps 0-4 on your client machine.

6) Follow the official documentation to configure and run synergy.  The steps are basically:
a) Create the synergy.conf file on your server. (Read the documentation or search youtube for detailed instructions)
b) Start the synergy server with this command: $ synergys -f –config /path/to/synergy.conf
c) Start the synergy client with this command: $ synergyc -f Ryans-iMac.technotes.twosmallcoins.com #of course, use your server’s hostname instead

Building an RPM using an Existing Spec File

November 18th, 2010

An Example with R Statistical Software

Sometimes the repos have fairly old RPMs.  If you want a newer version of the software, you can either compile it from source.  Or create your own (newer) RPM.  This process is pretty easy if you can utilize someone else’s existing work.  It just takes some time and persistence.

In this example, I’m building an RPM for R-2.11.1.  The currently published RPMs are for R-2.10.0.  I’m using Centos 5.3.

1) Get the src.rpm file, available from Berkeley (Go Bears!) here.  Also download the source code, which is in tar.gz format.

2) Make sure you have the correct RPM build package on your server.

CentOS5# yum install rpm-build

3) Install the src.rpm file

CentOS5# rpm -i R-2.10.0-2.el5.src.rpm

4) Redhat places the build files in /usr/src/redhat.  Examine the R.spec file located in /usr/src/redhat/SPECS.  In this case, we only need to edit the Version number. Change

Version: 2.10.0

to

Version: 2.11.1

5)  Copy the R-2.11.1.tar.gz source file to /usr/src/redhat/SOURCES.

6) Run the build. And resolve the errors.

CentOS5# rpmbuild -ba /usr/src/redhat/SPECS/R.spec

error: Failed build dependencies:
tetex-latex is needed by R-2.10.0-2.x86_64
texinfo-tex is needed by R-2.10.0-2.x86_64
readline-devel is needed by R-2.10.0-2.x86_64
tcl-devel is needed by R-2.10.0-2.x86_64…

7)   Sigh.  Perform a yum install of the needed packages and try again.

CentOS5# yum install tetex-latex texinfo-tex readline-devel …

CentOS5# rpmbuild -ba /usr/src/redhat/SPECS/R.spec

8)  Got an error indicating that a number of files located in library/survival/noweb/ were not packaged.  Addressed this by adding this line in R.spec:

%{_libdir}/R/library/survival/noweb

Specifically, I placed it below the core files section:

%files
# Metapackage

%files core
%defattr(-, root, root, -)

%{_libdir}/R/etc
%{_libdir}/R/lib
%{_libdir}/R/library/survival/noweb

9)  Ran the build command again.  This time I got it to run successfully. The resultant RPMS are located in /usr/src/redhat/RPMS

Matching Values in a Perl Array

April 5th, 2010

Here’s some code to search for the existence of a value (in this case “ryan”) in a Perl array.

#!/usr/bin/perl

@array=("ryan","was","here");
print ryan_in_array(@array); 

sub ryan_in_array { ($_ eq "ryan") && return 1 for @_; 0 }

The subroutine is modified from http://perldoc.perl.org/List/Util.html.

Discussion:

In this “trivial” code, Graham Barr, uses a few tricks: (1) The && effectively works as an “if true” statement. Hence, if $_ is equal to ryan, then we perform the command “return 1″. (2) The “; 0″ works as an “else” statement. Our subroutine will return “0″, unless, of course, we successfully match “ryan”. Then it’s superseded by the “return 1″ call.

How to Create SNMP Test Trap on Linux

October 19th, 2009

I wanted to test Nagios‘ ability to alarm on an SNMP trap.  So I needed a good way to trigger an SNMP trap without, say… turning on and off a Cisco switch.

This document basically stitched together an example from the Net-SNMP tutorial and the Net-SNMP FAQs to create a step-by-step guide.  SNMP has a lot of technical jargon, but this how-to should work without knowing too many terms.

Creating the SNMP Trap

You’ll need root access to at least one Linux server (preferably two servers for proper testing) to complete this exercise.  Enjoy!

1) Install Net-SNMP and its tools, start the daemon and make sure it works

CentOS_5# yum install net-snmp-utils
CentOS_5# /etc/init.d/snmpd start
CentOS_5#snmpwalk -v 2c -c public localhost system

The last line should spew out a number of lines that look like this:

NMPv2-MIB::sysORDescr.1 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.3 = STRING: The MIB module for managing IP and ICMP implementations

2)  Create your MIB definition.  Drop this file into your MIBs directory, likely in /usr/share/snmp/mibs.

CentOS_5# cat /usr/share/snmp/mibs/TRAP-TEST-MIB.txt

TRAP-TEST-MIB DEFINITIONS ::= BEGIN
IMPORTS ucdExperimental FROM UCD-SNMP-MIB;

demotraps OBJECT IDENTIFIER ::= { ucdExperimental 990 }

demo-trap TRAP-TYPE
STATUS current
ENTERPRISE demotraps
VARIABLES { sysLocation }
DESCRIPTION "This is just a demo"
::= 17

END

3) Load the MIB.
CentOS_5# export MIBS=+TRAP-TEST-MIB

4) Run the snmptrap command to send a trap to your monitoring host. (Replace monitoring_host with the appropriate hostname).

CentOS_5# snmptrap -v 1 -c public monitoring_host TRAP-TEST-MIB::demotraps localhost 6 17 '' SNMPv2-MIB::sysLocation.0 s "Ryan was just here"

How to Verify your SNMP Trap

1) Run tcpdump on your monitoring host to see whether you’re seeing the host.  Note that an aggressively filtering firewall or SELinux may prevent your packet from showing up.

monitoring_host# tcpdump host CentOS_5
13:49:03.914746 IP CentOS_5.twosmallcoins.com.56970 > monitoring_host.snmptrap:  Trap(64)  E:2021.13.990 127.0.0.1 enterpriseSpecific s=17 33361154 [|snmp]

2)  Save the file and look at it in Wireshark (formerly known as Ethereal), to see the detailed packet.

mointoring_host# tcpdump -w ryan_test.dmp -s 0 host CentOS_5

This command will save it to the ryan_test.dmp file, so you can analyze it later.  If you look closely, you can see the part of the packet that says “Ryan was just here”.

How to Convert MySQL from MyISAM to InnoDB Using a Script

September 10th, 2009

Okay.  So I need to convert MySQL database using the default MyISAM engine to the InnoDB engine.  The command is simple:

ALTER TABLE table_name ENGINE = InnoDB;

However, this command needs to be done for EVERY table.  Yes, it’s a pain in the rear…  so here’s a way to do it by scripting.

Scripting a MySQL InnoDB Engine Conversion

0) Backup your database. You should probably be doing this already.  Now’s a good time to make sure that your backups ran.

1) Create the script. You’ll need the correct permissions to query the database. Here’s the command.  Be sure to change <DATABASE_NAME> as it fits.

Linux$ mysql -p -e "show tables in <DATABASE_NAME>;" | tail --lines=+2 | xargs -i echo "ALTER TABLE {} ENGINE=INNODB;" > alter_table.sql

2) Run the script.

Linux $ mysql --database=<DATABASE_NAME> -p < alter_table.sql

3) Verify it by running this command in mysql:

mysql> show table status;

Discussion (If You’re Interested)

The script is simply a bunch of ALTER TABLE commands for each of your tables in the database of question.

The mysql -p -e “show tables in <DATABASE_NAME>” command gets a list of the tables.  This list has a header that looks like “Tables_in_DATABASE”.  The tail command drops that first header line.  Now you have a clean list of tables.  The xargs -i echo command creates the ALTER TABLE command, inserting the table name where the squiggly braces {} are placed.   It’s now stored in alter_table.sql.

Step two simply runs the script that we stored in alter_table.  Both mysql commands will prompt for a password, based on the -p flag.

389 Directory Server Install Error: Exception in thread “main” java.lang.Error: Probable fatal error:No fonts found

September 9th, 2009

I just installed the open source LDAP software, 389 Directory Server, on a CentOS 5.3 server by following these very good instructions.  However, the last line stated

CentOS# 389-console -x nologo

     Exception in thread "main" java.lang.Error: Probable fatal error:No fonts found.
     at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1088)
     at sun.font.FontManager.initialiseDeferredFont(FontManager.java:960)
     at sun.font.FontManager.findOtherDeferredFont(FontManager.java:899)
     at sun.font.FontManager.findDeferredFont(FontManager.java:916)
     at sun.font.FontManager.findFont2D(FontManager.java:1904)
     at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1071)
     at sun.font.FontManager.initialiseDeferredFont(FontManager.java:960)
     at sun.font.FontManager.findOtherDeferredFont(FontManager.java:899)
     at sun.font.FontManager.findDeferredFont(FontManager.java:916)
     at sun.font.FontManager.findFont2D(FontManager.java:1904)
     ...

Dozens of un-informative commands continued.  (Dear Java programmer:  do we really need such verbose error messages?  Really?)

The Solution

Fortunately the solution for me was relatively easy.  I had installed CentOS in text mode, without X-server.

1) Installed X-server.  On CentOS, installing X is quite easy:

CentOS# yum groupinstall “X Window System”

Followed the prompts.

2) Logged off,  SSH’ed back in with X forwarding, and launched GUI.

Cygwin$ ssh -X root@CentOS
Warning: No xauth data; using fake authentication data for X11 forwarding.
CentOS# 389-console -x nologo

3) Celebrated with a cup o’ java. Hehe.  Okay… it’s really not that funny.

How to Upgrade Sun Grid Engine (SGE) and Migrate to New Server

August 26th, 2009

Sometimes you want to upgrade software and migrate hardware at the same time. If you want to do that with SGE, then you’re looking in the right place.

My architecture: old server SGE 6.1u2 on CentOS 5, migrating to SGE 6.2u3 on CentOS 5.3.

Upgrade Procedure

1) Download SGE onto the new server. If you’re feeling farsighted, fill out the Planning Checklist.

2) Unzip, untar, an set $SGE_ROOT to your untar’ed folder.

OldCentOS# export SGE_ROOT=/directory/to/sge/

Note: You may consider putting SGE root in an NFS directory in case you want to create a “high availability” fail-over environment. NFS may very well slow you down.

3) Find save_sge_config.sh and copy it over to the old host.

4) Create a copy of your configuration using save_sge_config.sh

OldCentOS# mkdir sge_config_folder
OldCentOS# /path/to/save_sge_config.sh sge_config_folder

5) Copy over your config folder

6) Edit save_config_folder/cell/qmaster and change the old hostname (OldCentOS) to the new hostname (NewCentOS). Otherwise you’ll get an error like this:

Upgrade must be started on a qmaster host!

7) Run upgrade

NewCentOS# $SGE_ROOT/inst_sge -upd

8) Follow prompts. This is when you should reach for that planning checklist from step 1.

9)  Be patient. Depending on the size your configuration, certain portions might take a long time.

10) Check your install

NewCentOS# ps -ef | grep sge
NewCentOS# qstat -f

How to Prepare AIX 6.1 for Oracle Install

June 22nd, 2009

First off, I’m not an Oracle DBA. But here are some of the things I did upon my DBA’s request, so that he can install Oracle.

1) Add user oracle and group dba. Edited the following files:

  • /etc/passwd
  • /etc/group
  • /etc/security/passwd

2) Edited the default ulimit and associated parameters.  In /etc/security/limits:

default:
fsize = -1
core = 2097151
cpu = -1
data = -1
rss = 65536
stack = 65536
nofiles = 20000

root:
fsize=-1
stack=-1
rss=-1

oracle:
fsize=-1
stack=-1
rss=-1

Hmm… I guess I am really trusting of the DBA.  At least this box is dedicated to Oracle.

3) Edit the kernel parameters. In /etc/tunables/nextboot, added the following:

vmo:
minfree = “1500″
maxfree = “2100″
minperm% = “5″
lru_file_repage = “0″

ioo:
j2_maxRandomWrite = “128″
j2_nPagesPerWriteBehindCluster = “128″
j2_nRandomCluster = “32″

4) Installed rsync.

5) Expanded /tmp and /oracle/home as needed.

AIX61# df | grep mnt

My /tmp file system was using /dev/hd3. Look at it and extend if needed. Here I extend by 1 physical partition (PP), which is 128 MB. Then I extend the /tmp file system too.

AIX61# lslv hd3
AIX61# extendlv hd3 1
AIX61# chfs -a size=+128M /tmp

6) Installed the fileset, rstc.basic, which is required by Oracle 11g.  Mounted AIX6.1 DVD on /mnt and ran this installp command:

AIX61# installp -ag -d /mnt/installp/ppc/ rsct.basic

How to install SSH on AIX 6.1 and turn off telnet

June 14th, 2009

One of my biggest gripes about AIX is how security un-conscious it is.  SSH now “comes with” AIX, but it’s on a separate cd.  Anyway, enough griping.  Here are the procedures.

Installing OpenSSH on AIX 6.1

1) Obtain the files. It’s downloadable here: http://sourceforge.net/projects/openssh-aix/.  Or you can find it on the expansion CD.  Or the Linux toolkit for AIX CD.

2)  Install.  If you’re using a CD, follow my directions for installing lsof from here (of course, replace openssh with lsof).  Otherwise, I have some installp examples here.

3) Start your SSH.

AIX61# startsrc -g ssh

4) Edit your /etc/hosts.allow file. Otherwise you’ll see an error that says this:

ssh_exchange_identification: Connection closed by remote host

5) Test it out.

Linux# ssh AIX61

How to Disable Telnet on AIX 6.1

1) Comment out telnet from /etc/inetd.conf.

2) Reload the configuration file

AIX61# refresh -s inetd

3) Test. You should get a nice error message like this:

Linux# telnet AIX6.1
Trying 10.1.1.10…
telnet: connect to address 10.1.1.10: Connection refused
telnet: Unable to connect to remote host: Connection refused