Wednesday, November 18, 2009

Netwok Gotcha While Upgrading To openSUSE 11.2

Upgraded my machine from openSUSE 11.1 to 11.2. And bumped royally into bnc#546575. There's a typo in /etc/udev/rules/70-persistent-net.rules (an apparent holdout from openSUSE 10.x). So if your machine has a manually configured IP address, check /etc/udev/rules/70-persistent-net.rules before you update. If it contains the string ATTRS{address}, edit it so that it becomes ATTR{address}. Now the network configuration will be preserved after the upgrade.

Monday, November 02, 2009

SSH Works, SCP/SFTP Fails? Check all login scripts

Gaah! Some fool snuck an unconditional echo statement in a global profile. Surefire way to get scp and sftp to stop working. Lines that produce output, or exec statements should be conditionally placed in shell startup scripts. It's best not to have these lines take effect for non-interactive shells. I like to test "$0" to see if it begins with a '-' to determine if a shell is a login shell, and process the rest of the script accordingly. In bash:
case $0 in
-*) # Login shell
    ;;
 *) # non-interactive shell
    ;;
esac
In csh:
switch ($0)
       case -*:
          # login shell stuff

          breaksw
       default:
          # non-interactive stuff
          breaksw
endsw

Wednesday, August 26, 2009

bash {2..4} Variable Indirection

Bash v4 uses new quoting syntax, $"...", to do locale-specific string translation. Some scripts of mine that used bash-1.14 style variable indrection need to change. I was doing something like this to get the value of a variable whose name is the value of a second variable:
eval var2=$"$var1"
Turns out a variable indirection feature has been around since bash 2! Sheesh!
var2=${!var1}
is the official way to do this. Alternately this should also do:
eval var2=\$${var1}

Monday, June 29, 2009

HOWTO Check if a user or group already exists

Dont directly check with /etc/passwd, or /etc/group for existence of a user or group. This wont look up NIS database entries. A better way is to use getent, part of glibc. Lookup database entry for an existing user:
getent passwd username1 [username2 ...]
Lookup database entry for an existing group:
getent group groupname1 [groupname2 ...]

Identifying Linux distributor and version

The Linux Standard Base makes it really easy to identify the Linux distributor and version for LSB compliant. If the lsb package is installed (redhat-lsb, lsb, asianux-lsb, ...), just run:
lsb_release -i -d
or
lsb_release -a

Tuesday, January 06, 2009

KDM and XDMCP

After installing OpenSuse 11.1, I wanted to configure my favorite handcrafted WoW login theme, darkportal. The problem was I couldn't preview it without logging off. No problem - I just need to fire up Xephyr and check. So I enabled XDMCP thru the /etc/sysconfig editor, and ran:
xephyr -query localhost -screen 1280x1024 :1
Got a blank screen for my efforts. Grrrr... I ran:
netstat -aunp | grep ":177"
only to figure that kdm was listening at port 177 over IPv6! Recalling an old KDE bug, I edited /etc/X11/xdm/Xaccess to read:
LISTEN 0.0.0.0
and restarted kdm. That did the trick - phew!