Difference between revisions of "Sage"
m |
m |
||
Line 185: | Line 185: | ||
User saged |
User saged |
||
----- |
----- |
||
− | Some notes to enable |
+ | Some notes to enable X11 forwarding with the sage console: |
⚫ | |||
− | |||
⚫ | |||
vi /etc/ssh/sshd_config.conf |
vi /etc/ssh/sshd_config.conf |
||
X11Forwarding yes |
X11Forwarding yes |
||
Line 198: | Line 197: | ||
User saged |
User saged |
||
ForwardX11 yes |
ForwardX11 yes |
||
+ | ----- |
||
+ | Some notes to enable tcl/tk interactive plotting with maxima: |
||
+ | <br>You need X11 forwarding, cf above |
||
+ | apt-get install tk8.4 |
||
Test: |
Test: |
||
ssh sage |
ssh sage |
||
Line 207: | Line 210: | ||
sage: maxima.plot2d('cos(2*x) + 2*cos(x)','[x,0,1]','[plot_format,openmath]') |
sage: maxima.plot2d('cos(2*x) + 2*cos(x)','[x,0,1]','[plot_format,openmath]') |
||
+ | ----- |
||
+ | Some notes to enable octave and gnuplot: |
||
+ | <br>You need X11 forwarding, cf above |
||
+ | |||
+ | apt-get install octave gnuplot |
||
+ | sage -i gnuplotpy-1.7.p3 |
||
+ | Test: |
||
+ | ssh sage |
||
+ | Last login: blabla |
||
+ | ---------------------------------------------------------------------- |
||
+ | | SAGE Version 2.10, Release Date: 2008-01-18 | |
||
+ | | Type notebook() for the GUI, and license() for information. | |
||
+ | ---------------------------------------------------------------------- |
||
+ | |||
+ | sage: octave.de_system_plot(['x+y', 'x-y'], [1, -1], [0,2]) |
Revision as of 20:38, 1 February 2008
Some notes on the installation of Sage in a vserver:
Create a vserver, remove tmpfs /tmp in /etc/vservers/sage/fstab as 16M is too short for compilation
Create an account for the compilation
# adduser --disabled-password --shell /bin/false sage
Install packages needed for the compilation + some for runtime
# apt-get install gcc-4.1-base make m4 bison flex tar perl binutils \ libstdc++6-dev g++ openssh-client \ less screen imagemagick
Download and compile sources
# cd /opt # export http_proxy=http://proxy....:8080 # wget http://www.sagemath.org/dist/src/sage-2.10.tar # tar xf sage-2.10.tar # chown -R sage:sage * # su -s /bin/bash - sage sage$ cd /opt/sage-2.10/ sage$ make
Time for triple coffee...
To maintain the installation and install optional packages:
sage$ export http_proxy=http://proxy....:8080 sage$ ./sage -upgrade sage$ ./sage -optional sage$ ./sage -i extra_docs- sage$ ./sage -i openssl-0.9.8d.p1 sage$ ./sage -i pyopenssl-0.6 sage$ ./sage -i gap_packages-4.4.10_3 sage$ ./sage -i database_gap-4.4.10 ...
Create an account to run sage as webserver
# adduser --disabled-password --shell /bin/false saged # cp /opt/sage-2.10/sage /home/install
Edit the launch script /home/install/sage to point to the right directory:
SAGE_ROOT="/opt/sage-2.10" # ln -s /home/install/sage /usr/local/bin
To start & stop the webserver as a real daemon, in a screen session, save the following script as /home/install/saged:
#! /bin/sh # Author: Philippe Teuwen # Do NOT "set -e" PATH=/usr/sbin:/usr/bin:/sbin:/bin DESC="Launching SAGE webserver" NAME=sage PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME DAEMON=/usr/local/bin/sage HOST="fqdn.of.the.server" PORT="8000" ARGS="-c \"notebook(address=\\\"$HOST\\\",port=$PORT,accounts=true)\"" USER=saged # Exit if mysql client is not installed [ -x "$DAEMON" ] || exit 0 # Load the VERBOSE setting and other rcS variables [ -f /etc/default/rcS ] && . /etc/default/rcS # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # # Function that starts the daemon/service # do_start() { if [ -e $PIDFILE ]; then if ps -p $(cat $PIDFILE) >/dev/null; then echo -n -e "\nError: $NAME seems to be already running!" return 1 else rm -f $PIDFILE fi fi screen -d -m -S sage su -s /bin/bash - $USER -c "$DAEMON $ARGS" # PID of screen PID=$(screen -ls sage|grep sage|sed 's/[[:space:]]*\([0-9]\+\)\..*/\1/') # PID of su PID=$(ps --ppid $PID -o pid --no-headers) # PID of sage PID=$(ps --ppid $PID -o pid --no-headers) echo $PID > $PIDFILE } # # Function that stops the daemon/service # do_stop() { if [ -e $PIDFILE ]; then PID=$(cat $PIDFILE) if ps -p $PID > /dev/null; then # kill script kill $PID rm -f $PIDFILE return 0 else echo -e "\nWarning: $NAME was not running." echo -n -e "\nCleaning PID file" rm -f $PIDFILE return 1 fi else echo -n -e "\nWarning: $NAME was not running" return 1 fi } case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; restart|force-reload) # # If the "reload" option is implemented then remove the # 'force-reload' alias # log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 3 ;; esac :
If you don want anybody to be able to create an account (which gives access to bash!!), remove ",accounts=true" from ARGS.
Install the script:
# ln -s /home/install/saged /etc/init.d # update-rc.d saged defaults 99 01
If you want to install the jsMath fonts locally on your client for a faster rendering:
Download TEX fonts and install them either in ~/.fonts/ or C:\Windows\Fonts
Some notes if you want to use your Maple 32-bit on a 64-bit arch:
apt-get install ia32-libs /bin/maple -binary IBM_INTEL_LINUX
Or from Sage:
maple.fsolve('x^2=cos(x)+4', 'x=0..5')
Some notes to give a console access with python autocompletion:
Put ssh keys in /home/saged/.ssh/authorized_keys
Set /usr/local/bin/sage as shell of user saged in /etc/passwd
Then on the client side:
Host sage Hostname blabla User saged
Some notes to enable X11 forwarding with the sage console:
apt-get install xbase-clients vi /etc/ssh/sshd_config.conf X11Forwarding yes #if you're in a vserver: X11UseLocalhost no /etc/init.d/ssh restart
Then on the client side:
Host sage Hostname blabla User saged ForwardX11 yes
Some notes to enable tcl/tk interactive plotting with maxima:
You need X11 forwarding, cf above
apt-get install tk8.4
Test:
ssh sage Last login: blabla ---------------------------------------------------------------------- | SAGE Version 2.10, Release Date: 2008-01-18 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: maxima.plot2d('cos(2*x) + 2*cos(x)','[x,0,1]','[plot_format,openmath]')
Some notes to enable octave and gnuplot:
You need X11 forwarding, cf above
apt-get install octave gnuplot sage -i gnuplotpy-1.7.p3
Test:
ssh sage Last login: blabla ---------------------------------------------------------------------- | SAGE Version 2.10, Release Date: 2008-01-18 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: octave.de_system_plot(['x+y', 'x-y'], [1, -1], [0,2])