Headless Ubuntu Server - Tonido auto start

Support for Tonido on the Desktop including Windows/Mac/Linux
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 » Thu Jul 26, 2012 10:37 am

Nice work, thanks!

madop
Regular Tonidoid
Regular Tonidoid
Posts: 24
Joined: Thu Jan 31, 2013 2:59 pm

Re: Headless Ubuntu Server - Tonido auto start

Postby madop » Thu Jan 31, 2013 3:59 pm

@DeepWoods, @chimpy

I haven't tried these yet but I certainly saved them for future use.

Thanks a ton for sharing those scripts!!

MadOp

Zalta9990
Rookie Tonidoid
Rookie Tonidoid
Posts: 1
Joined: Mon Aug 19, 2013 12:16 pm

Re: Headless Ubuntu Server - Tonido auto start

Postby Zalta9990 » Mon Aug 19, 2013 12:23 pm

DeepWoods wrote: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

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.
Last edited by Zalta9990 on Wed Nov 13, 2013 6:59 pm, edited 2 times in total.

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 » Mon Aug 19, 2013 10:41 pm

No, we don't have a startup script.

User avatar
Steel
Super Tonidoid
Super Tonidoid
Posts: 33
Joined: Wed Mar 19, 2014 11:55 am

Re: Headless Ubuntu Server - Tonido auto start

Postby Steel » Tue Sep 09, 2014 2:20 pm

There is a much easier way to do this without all the complex scripting.

For the record I am using Ubuntu 14.04 64bit, but it will work on all Ubuntu machines.

In Terminal type:

Code: Select all

sudo nano /etc/rc.local


Then add in the following line:

Code: Select all

/path/to/tonido/tonido.sh start


For me it is:

Code: Select all

/usr/local/tonido/tonido.sh start


In the end it should look like:

Code: Select all

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/usr/local/tonido/tonido.sh start

exit 0


Press Ctrl+X, then Y, then Enter to close and save the file.

This will make tonido always run at boot. If you already have Tonido installed you my need to recover your account once this is done.

Enjoy
Last edited by Steel on Fri Oct 24, 2014 1:44 pm, edited 3 times in total.
...sent form my Commodore 64

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 » Thu Sep 11, 2014 5:04 pm

Nice, thanks for the information!

rt006
Rookie Tonidoid
Rookie Tonidoid
Posts: 3
Joined: Mon Nov 28, 2016 12:08 pm

Re: Headless Ubuntu Server - Tonido auto start

Postby rt006 » Thu Dec 01, 2016 10:39 am

I just want to offer some input on running Tonido on Ubuntu Server.

First, the tonido.sh script included in the package has a bug that breaks the stop and restart commands. To fix it, look for the line that reads

Code: Select all

kill -9 `cat  $PIDFILE` &> /dev/null
and change it to

Code: Select all

kill -9 `cat  $PIDFILE` > /dev/null

Second, the rc.local technique is straightforward, but it runs tonidoconsole as root, which may not be what you want. On modern systems it makes sense to use a systemd service. I've included my service definition below, based on the original tonido.sh script. Just change the User and Group lines according to your needs.

Code: Select all

[Unit]
Description=Tonido Server

[Service]
Type=simple
User=ubuntu
Group=ubuntu
RestartSec=10
Restart=on-failure
StandardOutput=syslog
WorkingDirectory=/usr/local/tonido
Environment='LD_LIBRARY_PATH=/usr/local/tonido'
ExecStart=/usr/local/tonido/tonidoconsole

[Install]
WantedBy=multi-user.target

Sreeja
Tonido Team
Tonido Team
Posts: 368
Joined: Mon Dec 16, 2013 4:25 am

Re: Headless Ubuntu Server - Tonido auto start

Postby Sreeja » Mon Dec 19, 2016 5:52 am

Thanks for the information


Return to “Tonido Software”

Who is online

Users browsing this forum: No registered users and 7 guests