Friday, 18 May 2012

Need a Super key for Openbox?

This happened to me on Crunchbang Linux, but would for any desktop using Openbox. I had just installed Crunchbang on an old machine. When I started using the desktop I reached for the Super key (normally the Windows key) and found it missing. Oops, I have a very old keyboard on this machine. Openbox uses the Super key extensively. What to do?


The right Control key is seldom used so I decided to remap this to Super. A perusal of the xmodmap command showed the sequence of commands required.


First remove the control modifier from Control_R:


remove control = Control_R


Next assign it the mod4 qualifier, which is Super:


add mod4 = Control_R


Putting it all together in one command:


xmodmap -e 'remove control = Control_R' -e 'add mod4 = Control_R'


Put this command at the end of ~/.config/openbox/autostart.sh and it will be run at login.


Alternatively you can put those two commands in ~/.Xmodmap as described here. The step with keycode described on that page and many similar ones isn't necessary though.

Tuesday, 15 May 2012

Installing Flash Player plugin on Precise Pangolin behind a proxy

You may find that the installation of the package flashplugin-installer fails if you are behind a proxy. Even though you may have instructed apt to use a proxy using a stanza like this:



Acquire {
        http {
                Proxy "http://proxy.example.com:8080/";
        };
};


the download fails. This is because the fetch script doesn't know about apt proxy settings. To fix this, do:


HTTP_PROXY=http://proxy.example.com:8080/
export HTTP_PROXY
apt-get --reinstall install flashplugin-installer


Another method is, when it fails, you will see the URL of the plugin tarball in the error messages. Download the tarball by other means and then do:


dpkg-reconfigure flashplugin-installer


Give it the directory where you have downloaded the plugin tarball to and it will unpack the tarball.

Thursday, 10 May 2012

Force yum to determine the fastest mirrors again

We are going to ship this CentOS machine overseas where the fastest mirrors will be different. We want yum to work that out on deployment there. A quick search of the files in the package yum-fastestmirror found the cache file: /var/cache/yum/timedhosts.txt


Just delete or rename this file and yum will do a speed test the next time it is run.


The plugin yum-fastestmirror appears to be an EPEL addon, so may not be installed by default on RHEL or Fedora.

Wednesday, 9 May 2012

Downloading updates to openSUSE during off-peak times using zypper

You might, like me, have an ISP that has peak and off-peak quotas. I prefer to consume off-peak quota whenever possible to leave more for waking hours.


My openSUSE installation gets regular package updates. Since I want every update in any case I looked for a way to download the packages ahead of time during off-peak. It turned out to be quite easy, as root I just created a file in /etc/cron.d/zypper-offpeak containing one line:



6 6 * * * root zypper -n up -l -d > /dev/null 2>&1


See man crontab for an explanation of the fields. This runs at 0606 in the morning. The -n allows it to run non-interactively, the -l auto-agrees with licenses (usually Adobe Reader plugin), and -d is the magic, meaning download only.


The packages go into the normal package cache, and next time you do a zypper up, they will install straight away. This makes for faster updates and the savings can be considerable for kernel-source and VirtualBox packages.


This has already been blogged here citing a different motivation. The correct answer is in one of the comments, apparently -d or --download-only was not in old versions of zypper.

Saturday, 5 May 2012

Building openconnect for RHEL 5

This blog entry is of historical interest now. If you just want openconnect ready to run for RHEL/CentOS/clones, you can get openconnect 4.0 from EPEL now, thanks to David Woodhouse. (2012-07-26)

Openconnect is an open source client that can connect to Cisco's AnyConnect SSL VPN. There are packages for Fedora but none for RHEL 5. I needed one (actually for CentOS 5) so I set myself the task of building it from the latest Fedora 18 source RPM.


First of all install mock from the EPEL repo. You will need to track down the latest version of Mock 1.0, as Mock 1.1 has Python 2.5 constructs which won't work on RHEL 5.


You can't just do a mock rebuild right away. The Fedora SRPM has an MD5 sum which causes an error when extracting on RHEL 5. In any case we need to make some edits to the spec file. So first extract the Fedora 18 openconnect SRPM in the standard RHEL area, /usr/src/redhat:


rpm -i --nomd5 openconnect-...src.rpm


Now edit the spec file and remove the dependency on libproxy and change vpnc-script to vpnc. Also change the openssl dependency to the latest available for RHEL 5. RedHat keeps the version number the same while backporting fixes so it's ok that the required version decreases.


Create a new SRPM with


rpmbuild -bs openconnect.spec


Do the mock build on the new SRPM


mock openconnect-...src.rpm


You will encounter missing dependencies, so use tell mock to install those in the fakeroot and try again. Eventually you will get a binary RPM in /var/lib/mock/epel-5-x86_64/result (i386 for 32-bit of course).


Unfortunately the associated NetworkManager-openconnect cannot be ported to RHEL 5 due to requiring higher versions of X libraries. However it isn't too unfriendly to run openconnect from the command line (with root privilege, as it configures a TUN device):


openconnect ip_address_of_gateway


and it will prompt you for the username and password. You may want to look at command line options of openconnect to see what else is needed.


Probably the best you can do to make it user friendly is to use sudo to run it, and then create a GNOME or KDE launcher to run a terminal running it.

Wednesday, 2 May 2012

Car MP3 player cares about partition type

In my previous adventure I used a USB stick to attempt to install Crunchbang Linux. After that I returned the USB stick to its normal duty. I am not sophisticated enough to have an iPod dock in my car, but the CD/MP3 player in my old bomb can accept USB sticks, so I use it to carry music for car trips.


But when I inserted the stick the player showed NO FILE or ERROR. What had I done?! Had I destroyed the stick?


Wait a moment. When I reformatted the USB stick for installing Crunchbang, it had changed the partition ID to Linux instead of FAT16. Neither the Linux kernel nor the system utilities cared that the partition ID was not DOS, they happily mounted the DOS filesystem or displayed the contents. But the car player did check the ID.


A quick edit of the partition ID with fdisk and the stick worked again. Phew!