Headless Ubuntu Server - Tonido auto start

Support for Tonido on the Desktop including Windows/Mac/Linux
chudux
Rookie Tonidoid
Rookie Tonidoid
Posts: 7
Joined: Thu Aug 18, 2011 2:40 pm

Headless Ubuntu Server - Tonido auto start

Postby chudux » Tue Jan 31, 2012 3:50 pm

I've just installed a fresh Ubuntu Server 11.10 32bit and now I'm trying to get Tonido installed and auto launching on bootup.
I had this all working on 11.4, but now with 11.10 auto start doesn't happen.
My steps:
1. sudo apt-get install libjpeg62 fontconfig libpng12-0 libssl0.9.8
2. wget http://www.tonido.com/download.php?TonidoSetup_i686.deb
(rename donwnload.php?TonidoSetup_i686.deb to TonidoSetup_i686.deb)
3. dpkg -i TonidoSetup_i686.deb
4. /usr/local/tonido/tonido.sh start
5. Edit ~/tonido/data/configex.xml (for remote access...search the form)

Tonido will run, but after a reboot, no joy. :cry: I have to run #4 after every reboot.

The forum doesn't seem to already have a viable answer...any ideas?

Thanks!

User avatar
madhan
Admin Tonidoid
Admin Tonidoid
Posts: 8617
Joined: Tue Dec 30, 2008 12:13 am
Location: Austin, TX, USA
Contact:

Re: Headless Ubuntu Server - Tonido auto start

Postby madhan » Tue Jan 31, 2012 4:11 pm

Something seems to have broken from 11.04 to 11.10, so it is not clear what the new procedure is from googling around. Maybe someone in the community can help.

User avatar
DeepWoods
Rookie Tonidoid
Rookie Tonidoid
Posts: 2
Joined: Fri Feb 03, 2012 2:48 pm
Location: Arkansas

Re: Headless Ubuntu Server - Tonido auto start

Postby DeepWoods » Fri Feb 03, 2012 3:38 pm

I cobbled this init script together that's been working for our testing.

Code: Select all

#! /bin/sh

### BEGIN INIT INFO
# Provides:          tonidoconsole
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      $named
# Default-Start:     2 3 4 5
# Default-Stop:      1
# Short-Description: Tonido server program startup
# Description:       Tonido server is a way to access your applications and share,
#                    sync, collaborate with friends and family without relying on
#                    public online services.
### END INIT INFO

# Assembled by: Rob Asher <xxxxxxxxxx@gmail.com>
 
#------------------------------------------------------------------------------
#                          Functions & Library
#------------------------------------------------------------------------------
. /lib/lsb/init-functions

export LD_LIBRARY_PATH=/usr/local/tonido:$LD_LIBRARY_PATH
 
#------------------------------------------------------------------------------
#                               Constants
#------------------------------------------------------------------------------
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

PROG=/usr/local/tonido/tonidoconsole

RUNAS=administrator                     #user to run as

 
PS="tonidoconsole"
PIDNAME="tonidoconsole"   
PIDFILE=$PIDNAME.pid                    # pid file
PIDSPATH=/tmp                # path to pid file
OPTIONS=" "                   # Program options
 
 
SCRIPT_OK=0                                  #error codes
SCRIPT_ERROR=1                            #error codes
TRUE=1                                          #boolean
FALSE=0                                         #boolean
 
DESCRIPTION="Tonido Server..."
 
#------------------------------------------------------------------------------
#                               Simple Tests
#------------------------------------------------------------------------------
 
#test if tonidoconsole is a file and executable
test -x $PROG || exit 0
 
#set exit condition
#set -e
 
#------------------------------------------------------------------------------
#                               Functions
#------------------------------------------------------------------------------
 
setFilePerms(){
 
        if [ -f $PIDSPATH/$PIDFILE ]; then
                chmod 400 $PIDSPATH/$PIDFILE
        fi
}
 
isRunning() {
        if [ $1 ]; then
                pidof_daemon $1
                PID=$?
 
                if [ $PID -gt 0 ]; then
                        return 1
                else
                        return 0
                fi
        else
                pidof_daemon
                PID=$?
 
                if [ $PID -gt 0 ]; then
                        return 1
                else
                        return 0
                fi
        fi
}
 
status(){
   isRunning
   isAlive=$?
 
   if [ "${isAlive}" -eq $TRUE ]; then
                echo "$PIDNAME found running with processes:  `pidof $PS`"
        else
                echo "$PIDNAME is NOT running."
        fi
 
 
}
 
removePIDFile(){
   if [ $1 ]; then
                if [ -f $1 ]; then
                   rm -f $1
           fi
        else
      #Do default removal
      if [ -f $PIDSPATH/$PIDFILE ]; then
                   rm -f $PIDSPATH/$PIDFILE
           fi
        fi
}
 
start() {
        log_daemon_msg "Starting $DESCRIPTION"
 
   isRunning
   isAlive=$?
 
        if [ "${isAlive}" -eq $TRUE ]; then
                log_end_msg $SCRIPT_ERROR
        else
                start-stop-daemon --start --quiet --background --chuid $RUNAS --user $RUNAS --pidfile $PIDSPATH/$PIDFILE --make-pidfile --exec $PROG -- $OPTIONS
                setFilePerms
                log_end_msg $SCRIPT_OK
        fi
}
 
stop() {
   log_daemon_msg "Stopping $DESCRIPTION"
 
   isRunning
   isAlive=$?
        if [ "${isAlive}" -eq $TRUE ]; then
                start-stop-daemon --stop --quiet --oknodo --retry=TERM/30/KILL/5 --pidfile $PIDSPATH/$PIDFILE --name $PS
 
                if [ -n "$try" ] ; then
                        log_end_msg $SCRIPT_ERROR
                else
                        removePIDFile
                   log_end_msg $SCRIPT_OK
                fi
 
        else
                log_end_msg $SCRIPT_ERROR
        fi
}
 
terminate() {
        log_daemon_msg "Force terminating (via KILL) $DESCRIPTION"
 
   PIDS=`pidof $PS` || true
 
   [ -e $PIDSPATH/$PIDFILE ] && PIDS2=`cat $PIDSPATH/$PIDFILE`
 
   for i in $PIDS; do
      if [ "$i" = "$PIDS2" ]; then
              kill $i
         removePIDFile
      fi
   done
 
   log_end_msg $SCRIPT_OK
}
 
destroy() {
   log_daemon_msg "Force terminating and may include self (via KILLALL) $DESCRIPTION"
   killall $PS -q >> /dev/null 2>&1
   log_end_msg $SCRIPT_OK
}
 
pidof_daemon() {
    PIDS=`pidof $PS` || true
 
    [ -e $PIDSPATH/$PIDFILE ] && PIDS2=`cat $PIDSPATH/$PIDFILE`
 
    for i in $PIDS; do
        if [ "$i" = "$PIDS2" ]; then
            return 1
        fi
    done
    return 0
}
 
case "$1" in
  start)
   start
        ;;
  stop)
   stop
        ;;
  restart)
   stop
   sleep 1
   start
        ;;
  status)
   status
   ;;
  terminate)
   $1
   ;;
  destroy)
   $1
   ;;
  *)
   FULLPATH=/etc/init.d/$PS
   echo "Usage: $FULLPATH {start|stop|restart|status|terminate|destroy}"
   echo "       The 'destroy' command should only be used as a last resort."
   exit 1
   ;;
esac
 
exit 0

Save that as: /etc/init.d/tonido

Make sure to edit the RUNAS constant to match the username on your system you wish to run the service with. You may also need to check the PROG path as well if it's different.


Make the script executable:

Code: Select all

sudo chmod +x /etc/init.d/tonido



Add it to startup run levels:

Code: Select all

sudo update-rc.d tonido defaults


You can start|stop|restart the tonido server via - service tonido <command> - like so:

Code: Select all

sudo service tonido start


Working well on our test ubuntu 11.10 server but no guarantees written or implied. :mrgreen:

Rob

chudux
Rookie Tonidoid
Rookie Tonidoid
Posts: 7
Joined: Thu Aug 18, 2011 2:40 pm

Re: Headless Ubuntu Server - Tonido auto start

Postby chudux » Wed Feb 29, 2012 5:38 pm

So...any fix for this yet? I'm not a linux super user and I don't want to introduce a script that may not be needed later.

User avatar
madhan
Admin Tonidoid
Admin Tonidoid
Posts: 8617
Joined: Tue Dec 30, 2008 12:13 am
Location: Austin, TX, USA
Contact:

Re: Headless Ubuntu Server - Tonido auto start

Postby madhan » Wed Feb 29, 2012 6:40 pm

We don't have a script at this point. Please use the provided ones from the community.

User avatar
madhan
Admin Tonidoid
Admin Tonidoid
Posts: 8617
Joined: Tue Dec 30, 2008 12:13 am
Location: Austin, TX, USA
Contact:

Re: Headless Ubuntu Server - Tonido auto start

Postby madhan » Wed Feb 29, 2012 6:41 pm

@DeepWoods Thanks for the write up. If it ok with you we will sticky this and maybe even use this in our documentation.

User avatar
DeepWoods
Rookie Tonidoid
Rookie Tonidoid
Posts: 2
Joined: Fri Feb 03, 2012 2:48 pm
Location: Arkansas

Re: Headless Ubuntu Server - Tonido auto start

Postby DeepWoods » Thu Mar 01, 2012 8:49 am

madhan wrote:@DeepWoods Thanks for the write up. If it ok with you we will sticky this and maybe even use this in our documentation.
By all means feel free to use or modify whatever parts of it you wish. Always glad to contribute if I can.

Rob

walthamfrank
Rookie Tonidoid
Rookie Tonidoid
Posts: 1
Joined: Tue Apr 17, 2012 6:29 am

Re: Headless Ubuntu Server - Tonido auto start

Postby walthamfrank » Tue Apr 17, 2012 6:32 am

@deepwood Thanks very much for the script and instructions worked great for me

pemadorje
Super Tonidoid
Super Tonidoid
Posts: 36
Joined: Fri Dec 11, 2009 4:07 pm

Re: Headless Ubuntu Server - Tonido auto start

Postby pemadorje » Tue May 15, 2012 10:33 pm

@DeepWoods Thanks very much for sharing this... Script working great on Ubuntu 12.04

chimpy
Rookie Tonidoid
Rookie Tonidoid
Posts: 1
Joined: Thu Jul 26, 2012 9:56 am

Re: Headless Ubuntu Server - Tonido auto start

Postby chimpy » Thu Jul 26, 2012 10:05 am

I tried the init.d script posted above, and it certainly succeeded in starting the daemon, but restarts, status inquiries and graceful termination were impossible. So having never done an init.d script I decided to do a mashup of the script above and a deluged init.d script. I am very pleased with the results, I must say!

Works brilliantly here on Ubuntu 11.04. Save to /etc/init.d/tonido, chmod +x /etc/init.d/tonido, and replace USER=www-data with your user of choice. Start, stop, restart and status are supported.

Code: Select all

#!/bin/sh
### BEGIN INIT INFO
# Provides:          tonidoconsole
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      $named
# Default-Start:     2 3 4 5
# Default-Stop:      1
# Short-Description: Tonido server program startup
# Description:       Tonido server is a way to access your applications and share,
#                    sync, collaborate with friends and family without relying on
#                    public online services.
### END INIT INFO

# Authors: Tanguy Ortolo <tanguy+debian@ortolo.eu>,
# Cristian Greco <cristian@regolo.cc>
# Rob Asher <xxxxxxxxxx@gmail.com>
# Lewis Miller <chimpy@ohai.co.cc>

#------------------------------------------------------------------------------
#                          Functions & Library
#------------------------------------------------------------------------------

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

export LD_LIBRARY_PATH=/usr/local/tonido:$LD_LIBRARY_PATH

#------------------------------------------------------------------------------
#                               Constants
#------------------------------------------------------------------------------

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

PROG=/usr/local/tonido/tonidoconsole

USER=www-data                     #user to run as

NAME=tonidoconsole
DAEMON=/usr/local/tonido/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/tonido
DESC="Tonido Media Server"

#------------------------------------------------------------------------------
#                               Simple Tests
#------------------------------------------------------------------------------

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

ENABLE_TONIDO=1

#------------------------------------------------------------------------------
#                               Functions
#------------------------------------------------------------------------------

#
# Function that starts the daemon/service
#
do_start()
{
  if [ $ENABLE_TONIDO != 1 ]; then
    log_daemon_msg "Not starting ${DESC} ${NAME}, disabled in ${SCRIPTNAME}"
  else
    # Return
    #   0 if daemon has been started
    #   1 if daemon was already running
    #   2 if daemon could not be started
    start-stop-daemon --start --background --quiet --pidfile $PIDFILE --exec $DAEMON \
      --chuid $USER --test > /dev/null \
      || return 1

    start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile --exec $DAEMON \
      --chuid $USER \
      || return 2
  fi
}

#
# Function that stops the daemon/service
#
do_stop()
{
  # Return
  #   0 if daemon has been stopped
  #   1 if daemon was already stopped
  #   2 if daemon could not be stopped
  #   other if a failure occurred

  start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
  RETVAL="$?"
  [ "$RETVAL" = "2" ] && return 2

  rm -f $PIDFILE
  return "$RETVAL"
}

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
    ;;
  status)
    status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
    ;;
  restart|force-reload)
    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|status|restart|force-reload}" >&2
    exit 3
    ;;
esac

:


Return to “Tonido Software”

Who is online

Users browsing this forum: No registered users and 5 guests