4 # Provides: chrome-remote-desktop
5 # Required-Start: $remote_fs $syslog
6 # Required-Stop: $remote_fs $syslog
7 # Default-Start: 2 3 4 5
9 # Short-Description: Chrome Remote Desktop service
12 # /etc/init.d/chrome-remote-desktop: Start and stop Chrome Remote Desktop host daemon.
14 HOST_PATH
=/opt
/google
/chrome-remote-desktop
/chrome-remote-desktop
16 # Group of users for which Chrome Remote Desktop is enabled. Users are added
17 # to that group when they start the host for the first time.
18 CHROME_REMOTING_GROUP
=chrome-remote-desktop
20 test -x $HOST_PATH ||
exit 0
22 .
/lib
/lsb
/init-functions
24 if [ "$(whoami)" = "root" ]; then
25 # Extract list of users in the chrome-remoting group.
26 USERS
=$
(getent group
$CHROME_REMOTING_GROUP |
27 awk -F ':' '{ gsub(",", " ", $4); print $4 }')
32 # Tries to wait for 10 seconds until specified command exits and then kills it.
37 while [ $time_left -gt 0 ]; do
38 (kill -0 $pid 2>/dev
/null
) ||
return `wait $pid`
40 time_left
=$
((time_left
- 1))
42 (kill -0 $pid 2>/dev
/null
) ||
return `wait $pid`
44 echo command \"$@
\" has timed out
>&2
49 # Usage: run_and_ignore_error [--login] user program [args...]
51 # Run program in a clean login shell. This requires backgrounding, since
52 # the user's .profile or .login script might be run, which might contain
54 run_and_ignore_error
() {
56 if [ "$1" = "--login" ]; then
65 if [ "$(whoami)" = "$user" ]; then
68 sudo
-u "$user" $login_options "$@"
73 log_begin_msg
"Starting Chrome Remote Desktop host for $1..."
74 run_and_ignore_error
--login $1 "$HOST_PATH" --start
79 log_begin_msg
"Stopping Chrome Remote Desktop host for $1..."
80 run_with_timeout run_and_ignore_error
$1 "$HOST_PATH" --stop
85 log_begin_msg
"Reloading Chrome Remote Desktop host configuration for $1..."
86 run_and_ignore_error
$1 "$HOST_PATH" --reload
91 log_begin_msg
"Restarting Chrome Remote Desktop host for $1..."
92 run_and_ignore_error
$1 "$HOST_PATH" --stop
93 run_and_ignore_error
--login $1 "$HOST_PATH" --start
98 for user
in $USERS; do
105 for_each_user do_start
109 for_each_user do_stop
113 for_each_user do_reload
117 for_each_user do_restart
121 log_success_msg
"Usage: /etc/init.d/chrome-remote-desktop" \
122 "{start|stop|reload|force-reload|restart}"