Skip to content

Instantly share code, notes, and snippets.

@mactkg
Forked from masuidrive/install_code_server.sh
Created November 24, 2019 06:53
Show Gist options
  • Save mactkg/9fbd7ed2674b27cdbd47390dbfa4eb91 to your computer and use it in GitHub Desktop.
Save mactkg/9fbd7ed2674b27cdbd47390dbfa4eb91 to your computer and use it in GitHub Desktop.
Install code-server on Coder
#!/bin/bash
VERSION=${VERSION:-2.1692-vsc1.39.2}
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