squisher

Mar 242013
 

I couldn’t find a good guide for running teamspeak3 inside of a chroot. And that’s the only way I’d be running it, given that it is a binary blob… This guide is for a Debian system, should probably work for Ubuntu, but it shouldn’t be hard to adjust to other distributions.

  1. Install jailkit. It’s not in Debian, but it provides a working packaging script that you just have to use to build the package yourself:
    # USE REGULAR USER
    apt-get install build-essential fakeroot
    # download jailkit, see the link above. Extract it.
    cd jailkit-2.15
    dpkg-buildpackage -uc -uc -rfakeroot
    sudo dpkg -i ../jailkit*.deb
    
  2. Configure the chroot, and install teamspeak 3 in it. Note that I’m assuming amd64 here.
    # AS ROOT
    mkdir -p /var/chroot/ts3
    cd /var/chroot/ts3
    
    cat << EOF >> start.sh
    #!/bin/bash
    exec ./ts3server_startscript.sh start
    EOF
    chmod +x start.sh
    
    tar xavf $TEAMSPEAKTARGZ # Replace with where you stored the teamspeak download
    adduser --system --home /var/chroot/ts3/./teamspeak3-server_linux-amd64 \
            --disabled-password --group --shell /start.sh ts3
    mkdir teamspeak3-server_linux-amd64/logs
    chown ts3:ts3 teamspeak3-server_linux-amd64 teamspeak3-server_linux-amd64/logs
    
    jk_jailuser -j $PWD ts3
    cat << EOF >> /etc/jailkit/jk_init.ini
    [ts3]
    devices = /dev/null, /dev/random, /dev/urandom, /dev/zero
    paths = /usr/lib/libstdc++.so.6, /etc/localtime
    users = root
    groups = root
    includesections = uidbasics, netbasics, basicshell
    EOF
    jk-init -v -j $PWD ts3
    
  3. Boot script:

    cat << 'EOF' >> /etc/init.d/teamspeak3
    #!/bin/bash
    ### BEGIN INIT INFO
    # Provides:          teamspeak3
    # Required-Start:    $local_fs $remote_fs $network $named
    # Required-Stop:     $local_fs $remote_fs $network $named
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # X-Interactive:     false
    # Short-Description: Start/stop teamspeak 3 server
    ### END INIT INFO
    
    shm=/var/chroot/ts3/dev/shm
    pidfile=/var/chroot/ts3/teamspeak3-server_linux-amd64/ts3server.pid
    
    case "$1" in
    	start)
    		mount -t tmpfs tmpfs $shm
    		su ts3
    		;;
    	stop)
    		echo -n "Stopping the TeamSpeak 3 server"
    		if ( kill -TERM $(cat $pidfile) 2> /dev/null ); then
    			c=1
    			while [ "$c" -le 300 ]; do
    				if ( kill -0 $(cat $pidfile) 2> /dev/null ); then
    					echo -n "."
    					sleep 1
    				else
    					break
    				fi
    				c=$((++c)) 
    			done
    		fi
    		if ( kill -0 $(cat $pidfile) 2> /dev/null ); then
    			echo "Server is not shutting down cleanly - killing"
    			kill -KILL $(cat $pidfile)
    		else
    			echo "done"
    		fi
    		rm $pidfile
    		umount $shm
    		;;
    	*)
    		echo "Usage: $0 {start|stop}"
    		;;
    esac
    EOF
    chmod +x /etc/init.d/teamspeak3
    insserv teamspeak3
    
  4. Recommended: Block outside access to server query, since it’s a telnet based protocol (unencrypted)
    iptables -A INPUT -p tcp ! -s 127.0.0.1 --dport 10011 -j REJECT
    

The point of this guide is to never run the server outside of the chroot. Also I noticed that if the environment wasn’t set up correctly, and the server ran but had strange error messages in the log and didn’t actually work, I had to delete the database file (ts3server.sqlite) and start from scratch.

That’s it, you’re ready to go. Let me know if I missed something.

Mar 112013
 

I recently started using the awesome window manager again. Running into some issues, I wanted to try out the git master version, but not replace my stable installation.

The recipe is:

  1. Build it for installation in $HOME and install it.
    cmake -DCMAKE_INSTALL_PREFIX:PATH=$HOME/opt/awesome
    make install
    
  2. Create a testing wrapper script awesome-xephyr and put it into $PATH:
    #!/bin/bash
    
    if [ -z "$AWESOME" ]; then
    AWESOME=awesome
    fi
    
    $AWESOME -k "$@" || exit 1
    
    Xephyr :1 -ac -br -noreset -screen 1152x720 &
    xephyr_pid=$!
    
    sleep 1
    
    DISPLAY=:1.0 $AWESOME "$@" &
    awesome_pid=$!
    
    echo "Press ENTER to kill Xephyr"
    read a
    kill $awesome_pid
    kill $xephyr_pid
    
  3. Run it
    #!/bin/bash
    
    # ;; means the default lua search path
    export AWESOME_PREFIX=$HOME/opt/awesome
    export RC=$HOME/.config/awesome/git.lua  # copied from .build.../awesomerc.lua and adjust the beautiful.init theme path
    
    LUA_PATH=";;$AWESOME_PREFIX/share/awesome/lib/?.lua;$AWESOME_PREFIX/share/awesome/lib/?/init.lua" \
    AWESOME=$AWESOME_PREFIX/bin/awesome \
    exec awesome-xephyr -c $RC
    

P.S. You can possibly tweak this to work without the make install directly from the .build directory.

Dec 142012
 

Working on refraction: This is the first attempt which just scattered the ray randomly when leaving the object (image uses 500 samples);

Ok this is as far as I got by the deadline… which is kind of a sad state of affairs. When leaving the object I am doing the same refraction equation again with no randomness involved but unfortunately it still looks very wrong (50 samples):

I will render a higher sample picture over night:

Dec 032012
 

Putting another sphere into the scene revealed that sometimes the reflections were wrong because a negative cos was calculated. The issue was that the change of basis was done incorrectly for transforming the samples. Now it looks sane:

 

But you can still see a strange highlight at the top of the bottom sphere. My reflectance just based on the cos term, using a real material property, like stainless steel, results in a normal looking bottom sphere (1000 samples):

Nov 262012
 

Reducing the size of the light source resulted in an even darker image since now fewer rays found their way into the light source. Adding a back wall behind the camera did not seem to help much.

Now using the cos density sampling, and increasing samples to 100 it gets almost worse:

 

 

Nov 212012
 

In the picture above I am visualizing the normals of each hit. It is using multisampling and purely diffuse material so that some rays get scattered inte space (the box is missing one side). Note that the back wall is missing — the rectangle had the points stored in incorrect order so that the normal was pointing out the opposite side. The fixed back wall can be seen below.

Now that I can scatter and have material properties, I can do actual path tracing. The image below uses essential lambertian surfaces, hence the absorption is relative to $cos(\phi)$ and it uses only diffuse scattering. I increased the number of samples from 20 to 50 which turns out to make the image darker since more more rays end up in space without hits.