Linux Administration at WML
We use Linux in-house for development and to provide web based services. When we find a way to do something which was a little hard to find on the internet, it goes here for our own reference and to help someone else who might have the same trouble.Running Apt-cacher to serve both Ubuntu and Debian clients
Apt-cacher is a useful tool to save your bandwidth. http://www.debuntu.org/how-to-set-up-a-repository-cache-with-apt-cacher gives an overview.If you set the paths list in apt-cacher.conf to so that you can serve packages on your LAN both to Debian AND Ubuntu clients, then you'll quickly run into trouble. You'll see apt-get or aptitude displaying a "Waiting for headers" message which will timeout, with no evidence of what is wrong in the apt-cacher debug logs. The problem (I think) is down clashes between package names on the different distros.
The solution is to run two instances of apt-cacher; one for debian, the other for ubuntu.
The instructions here reflect the fact that we run apt-cacher(s) on a Debian (Etch) machine, serving other Debian instances and also serving Ubuntu clients. The "original" apt-cacher is for the Debian machines, the duplicate serves Ubuntu.
Copy the /etc/apt-cacher directory and its contents to /etc/apt-cacher-ubuntu. Edit /etc/apt-cacher-ubuntu/apt-cacher.conf replacing the log and cache paths /var/log/apt-cacher -> /var/log/apt-cacher-ubuntu and /var/cache/apt-cacher -> /var/cache/apt-cacher-ubuntu. Create the new log and cache directories (including the subdirectories in /var/cache/apt-cacher-ubuntu). Make sure the directories have the correct ownership and permissions.
Edit the daemon_port in /etc/apt-cacher-ubuntu/apt-cacher.conf to be different from the one in /etc/apt-cacher/apt-cacher.conf; for example:
daemon_port=3143
Now replace /etc/init.d/apt-cacher with this script, which will start two instances of apt-cacher, instead of the usual one.
#! /bin/sh
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Apt-Cacher"
NAME=apt-cacher
DAEMON=/usr/sbin/$NAME
PIDFILE=/var/run/$NAME.pid
PIDFILE_UBUNTU=/var/run/$NAME-ubuntu.pid
SCRIPTNAME=/etc/init.d/$NAME
# EXTRAOPT comes from /etc/defaults/apt-cacher
EXTRAOPT_UBUNTU=" -c /etc/apt-cacher-ubuntu/apt-cacher.conf"
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
# Read config file if it is present.
if [ -r /etc/default/$NAME ]
then
. /etc/default/$NAME
fi
#
# Function that starts the daemon/service.
#
d_start()
#
# Function that stops the daemon/service.
#
d_stop()
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
force-reload|reload)
echo -n "Reloading configuration of $DESC: $NAME"
pid=`cat $PIDFILE`
if test -z "$pid" ; then
echo ", DEFAULT DEBIAN APT-CACHER NOT RUNNING"
else
kill -HUP $pid
fi
pid=`cat $PIDFILE_UBUNTU`
if test -z "$pid" ; then
echo ", UBUNTU APT-CACHER NOT RUNNING"
else
kill -HUP $pid
fi
echo "."
;;
*)
# echo "Usage: $SCRIPTNAME " >&2
echo "Usage: $SCRIPTNAME " >&2
exit 1
;;
esac
exit 0
Now re-start apt-cacher and you should be ready to edit the /etc/apt/sources.list of your Ubuntu clients to point to the Ubuntu version at your-server:3143 as well as using your-server:3142 for the Debian clients.
Getting file creation permissions right in Gnome
We have a simple group to which all of our staff belong. It's easy to make sure that all newly created files have the right group permissions - that is group-readable and group-writable - as long as you're in the command line.To do that, just set umask to 002 by putting the line
umask 002
in /etc/profile, or whatever file your shell reads when it starts.
However, this doesn't help you with files which are created in Nautilus, the Gnome file browser. To achieve the right behaviour here, you can set the umask used by Nautilus to
umask 002
in ~/.gnomerc or ~/.xsession
But that works only for a single user. To make this the system wide behaviour for all users, create a file in /etc/X11/Xsession.d/
On Debian/Ubuntu systems put this:
# If we are running the GNOME session, set umask
BASESTARTUP=`basename "$STARTUP" | cut -d\ -f1`
if [ "$BASESTARTUP" = gnome-session -o \
\( "$BASESTARTUP" = x-session-manager -a \
"`readlink /etc/alternatives/x-session-manager`" = \
/usr/bin/gnome-session \) ]; then
umask 002
fi
In /etc/X11/Xsession.d/54gnome-umask, which gets called before 55gnome-session_gnomerc. Job done. Other distros will likely be similar.
