2009-07-27

Debian Mirror Howto

Today I will show you how to setup your own Debian repository.

Step 1: Install the apt-mirror package
# aptitude install apt-mirror

Step 2: Edit the configuration file /etc/apt/mirror.list

set base_path /var/spool/apt-mirror
set mirror_path $base_path/mirror
set skel_path $base_path/skel
set var_path $base_path/var

set defaultarch i386
set _tilde 0

# lenny's section
deb http://ftp.debian.org/debian lenny main contrib non-free
deb-amd64 http://ftp.debian.org/debian lenny main contrib non-free
deb-src http://ftp.debian.org/debian lenny main contrib non-free

# Cleaning section
clean http://ftp.de.debian.org/

skip-clean http://ftp.debian.org/doc/
skip-clean http://ftp.debian.org/tools/
skip-clean http://ftp.debian.org/debian-cd/
skip-clean http://ftp.debian.org/debian-minicd/
skip-clean http://ftp.debian.org/debian/dists/lenny/main/installer-i386/
skip-clean http://ftp.debian.org/debian/doc/
skip-clean http://ftp.debian.org/debian/tools/
skip-clean http://ftp.debian.org/debian/project/

Step 3: Install a cron job for regular mirror updates

For this create the file /etc/cron.d/apt-mirror:

#
# Regular cron jobs for the apt-mirror package
#
0 5 * * * apt-mirror /usr/bin/apt-mirror \
> /var/spool/apt-mirror/var/cron.log

Step 4: Add some lines to your Apache configuration

Alias /mirror-debian/ /var/www/mirror-debian/
<directory>
AllowOverride None
Options -MultiViews FollowSymLinks Indexes
Order allow,deny
Allow from all
</directory>

Step 5: Start initial download

# su - apt-mirror -c apt-mirror

Step 6: Configure your clients to use the new repository

deb http://your.hostname/mirror-debian/debian/ lenny main contrib non-free
deb-src http://your.hostname/mirror-debian/debian/ lenny main contrib non-free

deb http://security.debian.org/ lenny/updates main contrib non-free
deb-src http://security.debian.org/ lenny/updates main contrib non-free

Thats all!

Automatic VLC Start at System Boot Time

Last week we installed a machine with VLC for centralized music playback in our room. Now, everybody can start or stop music streams via the build-in HTTP interface of VLC.

To start VLC automatically at boot time we wrote the following start script:

#!/bin/sh
# Start/stop the vlc daemon.
#

PLAYLIST="/usr/share/vlc/playlist.pls"

case "$1" in
start)
PROC=$(ps -ef|grep "vlc -I http"|grep -v grep|wc -l)
if [ $PROC -eq 0 ]
then
sudo -u vlc /usr/bin/vlc -I http --http-host 0.0.0.0:8000 $PLAYLIST 1>/dev/null 2>&1 &
echo "VLC started"
else
echo "There is still a vlc process running..."
exit 1
fi
;;

stop)
PROC=$(ps -ef|grep "vlc -I http"|grep -v grep|awk '{print $2}')
for TMP in $PROC
do
logger "Killed VLC - PID $TMP"
kill -9 $TMP 1>/dev/null 2>&1
done
echo VLC killed
;;

restart)
$0 stop
$0 start
;;

reload|force-reload)
$0 stop
$0 start
;;
*) log_action_msg "Usage: /etc/init.d/vlc {start|stop|restart|reload|force-reload}"
exit 2
;;
esac
exit 0


For security reasons we run VLC as a non-root user. To change the user id we are using sudo inside the start script.