@@ -97,6 +97,7 @@ Please extend your path to use code-server:
9797 PATH="$STANDALONE_INSTALL_PREFIX /bin:\$ PATH"
9898Then you can run:
9999 code-server
100+ Or pass the --start flag to the install script to have it start code-server for you.
100101EOF
101102}
102103
@@ -107,6 +108,7 @@ To have systemd start code-server now and restart on boot:
107108 sudo systemctl enable --now code-server@\$ USER
108109Or, if you don't want/need a background service you can run:
109110 code-server
111+ Or pass the --start flag to the install script to have it start code-server for you.
110112EOF
111113}
112114
@@ -148,6 +150,9 @@ main() {
148150 --version=* )
149151 VERSION=" $( parse_arg " $@ " ) "
150152 ;;
153+ --start)
154+ START=1
155+ ;;
151156 --)
152157 shift
153158 break
@@ -161,15 +166,6 @@ main() {
161166 echoerr " Run with --help to see usage."
162167 exit 1
163168 ;;
164- * )
165- SSH_ARGS=" $1 "
166- if ! sshs true ; then
167- echoerr " could not ssh into remote host"
168- echoerr " failed: ssh $SSH_ARGS true"
169- exit 1
170- fi
171- echoh " Installing remotely with ssh $SSH_ARGS "
172- ;;
173169 esac
174170
175171 shift
@@ -492,29 +488,34 @@ sh_c() {
492488}
493489
494490sshs () {
491+ cmdline=" $* "
492+
493+ # We want connection sharing between invocations, a connection timeout,
494+ # heartbeat and ssh to exit if port forwarding fails.
495495 mkdir -p ~ /.ssh/sockets
496496 chmod 700 ~ /.ssh
497-
498497 set -- \
499- -oControlPath=~ /.ssh/sockets/%r@%n.sock \
500- -oControlMaster=auto \
501- -oControlPersist=yes \
502- -oConnectTimeout=5 \
498+ -o ControlPath=~ /.ssh/sockets/%r@%n.sock \
499+ -o ControlMaster=auto \
500+ -o ControlPersist=yes \
501+ -o ConnectTimeout=10 \
502+ -o ServerAliveInterval=5 \
503+ -o ExitOnForwardFailure=yes \
503504 $SSH_ARGS \
504505 " $@ "
505506
506- if ssh " $@ " ; then
507- return
507+ set +e
508+ ssh " $@ " ; code=" $? "
509+ set -e
510+ # Exit code of 255 means ssh itself failed.
511+ if [ " $code " -ne 255 ]; then
512+ return " $code "
508513 fi
509514
510- if ssh -O exit " $@ " ; then
511- # Control master has been deleted so we ought to try once more.
512- if ssh " $@ " ; then
513- return
514- fi
515- fi
516-
517- return 1
515+ echoerr " Failed to SSH into remote machine:"
516+ echoerr " + ssh $SSH_ARGS $cmdline "
517+ echoerr " + \$ ? = $code "
518+ exit 1
518519}
519520
520521# Always runs.
0 commit comments