Skip to content

Instantly share code, notes, and snippets.

@masuidrive
Last active December 5, 2019 08:18
Show Gist options
  • Save masuidrive/4b7d33de275fe15d83bedcefe0aa583f to your computer and use it in GitHub Desktop.
Save masuidrive/4b7d33de275fe15d83bedcefe0aa583f to your computer and use it in GitHub Desktop.
Install code-server on Coder
#!/bin/bash
VERSION=${VERSION:-2.1523-vsc1.38.1}
WORK_DIR=/home/ubuntu/projects
USER_ID=1000
GROUP_ID=1000
PORT=8888
TARBALL_URL=https://github.com/cdr/code-server/releases/download/$VERSION/code-server$VERSION-linux-x86_64.tar.gz
curl -L $TARBALL_URL | tar xfz - -C /usr/local/
EXEC_PATH=/usr/local/code-server$VERSION-linux-x86_64/code-server
mkdir -p $WORK_DIR
chown $USER_ID:$GROUP_ID $WORK_DIR
cat << EOT > /etc/systemd/system/code-server.service
[Unit]
Description=VSCode in a browser
After=network.target
[Service]
Type=simple
ExecStart=$EXEC_PATH --host 0.0.0.0 --port $PORT --locale ja-JP $WORK_DIR
WorkingDirectory=$WORK_DIR
ExecStop=/sbin/start-stop-daemon --stop -x $EXEC_PATH
Restart=on-failure
User=$USER_ID
[Install]
WantedBy=multi-user.target
EOT
systemctl daemon-reload
systemctl enable code-server.service
systemctl start code-server.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment