Показаны сообщения с ярлыком cloud. Показать все сообщения
Показаны сообщения с ярлыком cloud. Показать все сообщения

вторник, 18 марта 2014 г.

Copy.com init.d script for console sync

I'm testing new cloud storage Copy.com. This service has console client for Linux and it is great for backup stuff. If you register with this link, you will get 20Gigs of space.

Now. Copy.com provides only linux binaries with no init.d script. We can create our own:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          CopyAgent
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: CopyAgent
# Description:       CopyConsole (Copy cloud storage by Barracuda) service
### END INIT INFO

RUN_AS="root"
HOME=`grep $RUN_AS /etc/passwd | cut -d":" -f6`
CC="$HOME/copy/x86/CopyConsole"

start() {
   echo "Starting CopyConsole..."
       if [ -x $CC ]; then
           start-stop-daemon -b -o -c $RUN_AS -S -u $RUN_AS -x $CC -- -daemon
       fi
}

stop() {
   echo "Stopping CopyConsole..."
       if [ -x $CC ]; then
           start-stop-daemon -o -c $RUN_AS -K -u $RUN_AS -x $CC
       fi
}

status() {
       dbpid=`pgrep -u $RUN_AS CopyConsole`
       if [ -z $dbpid ] ; then
           echo "CopyConsole for user $RUN_AS: not running."
       else
           echo "CopyConsole for user $RUN_AS: running (pid $dbpid)"
       fi
}

case "$1" in

   start)
       start
       ;;
   stop)
       stop
       ;;
   restart|reload|force-reload)
       stop
       start
       ;;
   status)
       status
       ;;
   *)
       echo "Usage: /etc/init.d/copy.com {start|stop|reload|force-reload|restart|status}"
       exit 1

esac

exit 0

Do now forget to setup proper user to run from and check your installation path in CC property.