Install Sage 5.3 on Debian Squeeze + InitScript

One virtual machine on our private network runs an instance of Sage, which is an open-source alternative to Matlab, Maple or Mathematica. In fact it’s a very powerful framwork using Python as primary language for describing (for example) mathematical, algorithmic or topological problems. It comes handy for practices at university in algorithms or cryptography courses and there’s already a lot of sage related documentation and material outthere.
Still, there’s one problem with distribution packaging to solve to make Sage available to a broader audience. Because Sage consists of various Python libraries and toolkits, which are packed with Sage, it’s difficult to maintain and distribute it, especially if you don’t want to serve one monolithic program instead of seperating the libs as dependency.
Nevertheless, installing Sage (even as a daemon) is easy and here’s a short how-to for Debian Squeeze:

useradd sage
mkdir /home/sage /usr/local/sage # Home-Dir contains all preferences and project-files of Sage
chown -R sage:sage /usr/local/sage /home/sage
su sage
cd /usr/local/sage
aria2c ""
tar xvf sage-5.3.tar --strip-components=1
export MAKE="make -j4"
mkdir /var/log/sage
chown -R sage:sage /var/log/sage
./sage -upgrade
sage: optional_packages()
sage: install_package('openmpi-XXX')
sage: install_package('mpi4py-YYY')

# Provides:          sage
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts sage-mathematics server
# Description:       starts sage-mathematics server using start-stop-daemon

# configuration
SAGE_OPTS="-notebook interface= port=8081"
# commands

sage_start() {
        echo "Starting Sage..."
        start-stop-daemon --start --background --chuid "$USER" --chdir "$SAGE_HOME" --exec $SAGE_HOME/sage -- $SAGE_OPTS # -- $SAGE_LOG
sage_stop() {
        echo "Stopping Sage..."
        kill `ls "/home/$USER/.sage/temp/application/"`
case $1 in
                sleep 5
                echo "Use: $0 {start|stop|restart}"
                exit 1
exit 0

Adjust the variable SAGE_OPTS for the parameters passed to Sage. In most cases “-notebook” should be enough, if you only want to use Sage locally. The sage_stop function is a bit hacky but it works for me.
To autostart the daemon at boot time, run:

chmod +x /etc/init.d/sage
update-rc.d sage defaults 95
/etc/init.d/sage start

You can access Sage with your browser (considering default settings) on

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

* Checkbox GDPR is required


I agree

Hacking replay gain audio normalization into Jellyfin

There is already a feature request for audio normalization in Jellyfin media server. This is important if you want to listen to your music collection while always having the same loudness level. Usually, in different recordings or music genres some tracks are louder and others are more quiet. The standard …

Importing playlists to Jellyfin media server

In the following post I would like to describe a way to import music playlists to Jellyfin media server, for example in case you want to migrate them from a former Plex or Emby installation. Usually, Jellyfin is already able to detect playlist files within the media library. Unfortunately my …

Jellyfin media server on Archlinux ARM

In this post, I want to share some insights on building Jellyfin media server for Archlinux ARM. The PKGBUILD for Jellyfin one can find on the AUR, is specifically made for 64 bit architectures. Nevertheless Microsoft released the dotnet runtime, which Jellyfin relies on instead of Mono, also for Linux …