Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Init script for CopyConsole. See Installation instructions in comments for detailed explanations.
### BEGIN INIT INFO
# Provides: CopyConsole
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: CopyConsole service
### END INIT INFO
#!/bin/sh
USER_LIST="user1 user2"
DAEMON_POS=/usr/bin
DAEMON_NAME=CopyConsole
DAEMON=$DAEMON_POS/$DAEMON_NAME
DAEMON_OPTIONS=-daemonize
VERBOSE=1
start() {
echo "Starting $DAEMON_NAME..."
for dbuser in $USER_LIST; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
if [ -x $DAEMON ]; then
HOME="$HOMEDIR" start-stop-daemon -b -o -c $dbuser -S -u $dbuser -x $DAEMON -- $DAEMON_OPTIONS
fi
done
}
stop() {
echo "Stopping $DAEMON_NAME..."
for dbuser in $USER_LIST; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
if [ -x $DAEMON ]; then
start-stop-daemon -o -c $dbuser -K -u $dbuser -x $DAEMON
fi
done
}
status() {
for dbuser in $USER_LIST; do
dbpid=`pgrep -u $dbuser $DAEMON_NAME`
if [ -z $dbpid ] ; then
echo "$DAEMON_NAME for USER $dbuser: not running."
else
echo "$DAMON_NAME for USER $dbuser: running (pid $dbpid)"
fi
done
}
case "$1" in
start)
start
if [ $VERBOSE -eq 1 ] ; then
status
fi
;;
stop)
stop
;;
restart|reload|force-reload)
stop
start
if [ $VERBOSE -eq 1 ] ; then
status
fi
;;
status)
status
;;
*)
echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|(reload|force-reload|restart)|status}"
exit 1
esac
exit 0

NEW VERSION

please refer to this new version, that supports also Debian like distro and armhf version (like rPi and BananaPi).

Install init.d script for CopyConsole in Debian-like distros

Installation of CopyConsole

First of all you need to install CopyConsole, that may be done with this simple script, that must be run with superuser privileges (we need CopyConsole to be installed in a system directory, to make it available to all system users):

Warning! You must define if 32bit or 64bit version in VERSION var!

#!/bin/bash

VERSION=x86_64  # Select this for 64bit version
#VERSION=x86    # Select this for 32bit version

if [ $UID -eq 0 ]; then
  cd /usr/local
  wget https://copy.com/install/linux/Copy.tgz -O copy.tgz --no-check-certificate
  tar xfvz copy.tgz
  ln -s copy/$VERSION/CopyConsole /usr/bin/CopyConsole
else
  echo "Run this script as superuser. Installation Failed"
fi

User validation for CopyConsole

(Taken from: https://coderwall.com/p/rwxnma thank's to Marcelo Waisman)

The user must be validated the first time. To do that, this command must be inserted by the user

CopyConsole -u=USER_COPY_MAIL -r=$HOME/USER_COPY_DIR -p=USER_COPY_PASSWORD

When CopyCoonsole replies with press enter to exit user may exit, and we are ready to use the init script.

init.d script installation

First of all, you need to create the script in which it is saved the script. This could be done easily with a single line command:

sudo wget https://gist.githubusercontent.com/MatteoRagni/9271828/raw/ffb03b431671185080feb086627c29a3fff4f774/.etc.init.d.CopyConsole --no-check-certificate -O /etc/init.d/CopyConsole && sudo chmod +x /etc/init.d/CopyConsole

After that, you need to configure the script. If You have used previous instructions, you have only to insert users in the users list. Users shall be separated by a space, and you may insert as many user as you want.

The last step is to enable the init script:

sudo update-rc.d CopyConsole defaults

and it's done!

@gepatino

This comment has been minimized.

Copy link

gepatino commented Apr 21, 2014

I think you have a typo in the last command, it should be 'update-rc.d' instead of 'update-rd.d'

Nice work, thanks for sharing.

@MatteoRagni

This comment has been minimized.

Copy link
Owner Author

MatteoRagni commented Jun 30, 2014

You're right! thank's!

@matozoid

This comment has been minimized.

Copy link

matozoid commented Dec 13, 2015

I've made some changes in my fork to make it work for me on an Orange Pi: https://gist.github.com/matozoid/3a5ce92dfde9782384a1

@MatteoRagni

This comment has been minimized.

Copy link
Owner Author

MatteoRagni commented Dec 16, 2015

And it is much better. I've put your link in the first lines of the README.md to make people find it easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.