summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-23 09:43:18 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-23 09:43:18 +0000
commit2768c9ed447bf51f1e24431817f2a8aba849d04a (patch)
tree4d08ba21047c05644aad8b6270cccd58cea03437 /remoting
parent721d520adaef5090145f486a4a537c0eadd8ed08 (diff)
downloadchromium_src-2768c9ed447bf51f1e24431817f2a8aba849d04a.zip
chromium_src-2768c9ed447bf51f1e24431817f2a8aba849d04a.tar.gz
chromium_src-2768c9ed447bf51f1e24431817f2a8aba849d04a.tar.bz2
Add Linux init.d script for Chromoting
BUG=142426 Review URL: https://chromiumcodereview.appspot.com/10828405 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152970 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rwxr-xr-xremoting/host/installer/linux/debian/chrome-remote-desktop.init104
1 files changed, 104 insertions, 0 deletions
diff --git a/remoting/host/installer/linux/debian/chrome-remote-desktop.init b/remoting/host/installer/linux/debian/chrome-remote-desktop.init
new file mode 100755
index 0000000..1d50e47
--- /dev/null
+++ b/remoting/host/installer/linux/debian/chrome-remote-desktop.init
@@ -0,0 +1,104 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: chrome-remoting
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 1
+# Short-Description: Chrome Remote Desktop service
+### END INIT INFO
+
+# /etc/init.d/chrome-remote-desktop: Start and stop Chrome Remote Desktop host daemon.
+
+HOST_PATH=/usr/bin/me2me_virtual_host
+
+# Group of users for which Chrome Remote Desktop is enabled. Users are added
+# to that group when they start the host for the first time.
+CHROME_REMOTING_GROUP=chrome-remoting
+
+test -x $HOST_PATH || exit 0
+
+. /lib/lsb/init-functions
+
+if [ "$(whoami)" == "root" ]; then
+ # Extract list of users in the chrome-remoting group.
+ USERS=$(getent group $CHROME_REMOTING_GROUP |
+ awk -F ':' '{ gsub(",", " ", $4); print $4 }')
+else
+ USERS=$(whoami)
+fi
+
+run_and_ignore_error() {
+ user=$1
+ shift
+
+ su_command=su
+ if [ "$1" == "--login" ]; then
+ su_command="su --login"
+ shift
+ fi
+
+ set +e
+ if [ "$(whoami)" == "$user" ]; then
+ $@
+ else
+ $su_command $user --command "$@"
+ fi
+}
+
+do_start() {
+ log_begin_msg "Starting Chrome Remote Desktop host for $1..."
+ run_and_ignore_error $1 --login "$HOST_PATH --silent"
+ log_end_msg $?
+}
+
+do_stop() {
+ log_begin_msg "Stopping Chrome Remote Desktop host for $1..."
+ run_and_ignore_error $1 "$HOST_PATH --stop"
+ log_end_msg $?
+}
+
+do_reload() {
+ log_begin_msg "Reloading Chrome Remote Desktop host configuration for $1..."
+ run_and_ignore_error $1 "$HOST_PATH --reload"
+ log_end_msg $?
+}
+
+do_restart() {
+ log_begin_msg "Restarting Chrome Remote Desktop host for $1..."
+ run_and_ignore_error $1 "$HOST_PATH --stop"
+ run_and_ignore_error $1 --login "$HOST_PATH --silent"
+ log_end_msg $?
+}
+
+for_each_user() {
+ for user in $USERS; do
+ $1 $user
+ done
+}
+
+case "$1" in
+ start)
+ for_each_user do_start
+ ;;
+
+ stop)
+ for_each_user do_stop
+ ;;
+
+ reload|force-reload)
+ for_each_user do_reload
+ ;;
+
+ restart)
+ for_each_user do_restart
+ ;;
+
+ *)
+ log_success_msg "Usage: /etc/init.d/chrome-remote-desktop" \
+ "{start|stop|reload|force-reload|restart}"
+ exit 1
+esac
+
+exit 0