Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nhooyr committed Oct 9, 2020
1 parent e6b20ce commit a5387a4
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Please extend your path to use code-server:
PATH="$STANDALONE_INSTALL_PREFIX/bin:\$PATH"
Then you can run:
code-server
Or pass the --start flag to the install script to have it start code-server for you.
EOF
}

Expand All @@ -107,6 +108,7 @@ To have systemd start code-server now and restart on boot:
sudo systemctl enable --now code-server@\$USER
Or, if you don't want/need a background service you can run:
code-server
Or pass the --start flag to the install script to have it start code-server for you.
EOF
}

Expand Down Expand Up @@ -148,6 +150,9 @@ main() {
--version=*)
VERSION="$(parse_arg "$@")"
;;
--start)
START=1
;;
--)
shift
break
Expand All @@ -161,15 +166,6 @@ main() {
echoerr "Run with --help to see usage."
exit 1
;;
*)
SSH_ARGS="$1"
if ! sshs true; then
echoerr "could not ssh into remote host"
echoerr "failed: ssh $SSH_ARGS true"
exit 1
fi
echoh "Installing remotely with ssh $SSH_ARGS"
;;
esac

shift
Expand Down Expand Up @@ -492,29 +488,34 @@ sh_c() {
}

sshs() {
cmdline="$*"

# We want connection sharing between invocations, a connection timeout,
# heartbeat and ssh to exit if port forwarding fails.
mkdir -p ~/.ssh/sockets
chmod 700 ~/.ssh

set -- \
-oControlPath=~/.ssh/sockets/%r@%n.sock \
-oControlMaster=auto \
-oControlPersist=yes \
-oConnectTimeout=5 \
-o ControlPath=~/.ssh/sockets/%r@%n.sock \
-o ControlMaster=auto \
-o ControlPersist=yes \
-o ConnectTimeout=10 \
-o ServerAliveInterval=5 \
-o ExitOnForwardFailure=yes \
$SSH_ARGS \
"$@"

if ssh "$@"; then
return
set +e
ssh "$@"; code="$?"
set -e
# Exit code of 255 means ssh itself failed.
if [ "$code" -ne 255 ]; then
return "$code"
fi

if ssh -O exit "$@"; then
# Control master has been deleted so we ought to try once more.
if ssh "$@"; then
return
fi
fi

return 1
echoerr "Failed to SSH into remote machine:"
echoerr "+ ssh $SSH_ARGS $cmdline"
echoerr "+ \$? = $code"
exit 1
}

# Always runs.
Expand Down

0 comments on commit a5387a4

Please sign in to comment.