Index: remoting/host/installer/linux/debian/chrome-remote-desktop.init |
diff --git a/remoting/host/installer/linux/debian/chrome-remote-desktop.init b/remoting/host/installer/linux/debian/chrome-remote-desktop.init |
index 4230632e8131f5880f32e0c1aa366dc4ff1a2be7..91064e643ab5b991c6796c0425b97f5fa3501faf 100755 |
--- a/remoting/host/installer/linux/debian/chrome-remote-desktop.init |
+++ b/remoting/host/installer/linux/debian/chrome-remote-desktop.init |
@@ -46,25 +46,31 @@ run_with_timeout() { |
return 1 |
} |
+# Usage: run_and_ignore_error [-l] user program [args...] |
Sergey Ulanov
2013/06/07 20:51:21
maybe better to use "--login" instead of -l.
Lambros
2013/06/11 01:41:02
Done.
|
+# -l: Run program in a clean login shell (which requires backgrounding, since |
Sergey Ulanov
2013/06/07 20:51:21
the backgrouding details is important here, so may
Lambros
2013/06/11 01:41:02
Done.
|
+# the user's .profile or .login script might be run, which might contain |
+# blocking commands). |
run_and_ignore_error() { |
+ login_options="" |
+ if [ "$1" = "-l" ]; then |
+ login_options="-b -i" |
+ shift |
+ fi |
+ |
user=$1 |
shift |
- exec=$1 |
- shift |
set +e |
if [ "$(whoami)" = "$user" ]; then |
- "$exec" "$@" |
+ "$@" |
else |
- shell="$(getent passwd "$user" | cut -d: -f7)" |
- USER="$user" LOGNAME="$user" SHELL="$shell" start-stop-daemon \ |
- --chuid "$user" --exec "$exec" --start -- "$@" |
+ sudo -u "$user" $login_options "$@" |
fi |
} |
do_start() { |
log_begin_msg "Starting Chrome Remote Desktop host for $1..." |
- run_and_ignore_error $1 "$HOST_PATH" --start |
+ run_and_ignore_error -l $1 "$HOST_PATH" --start |
log_end_msg $? |
} |
@@ -83,7 +89,7 @@ do_reload() { |
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 "$HOST_PATH" --start |
+ run_and_ignore_error -l $1 "$HOST_PATH" --start |
log_end_msg $? |
} |