Skip to content

Commit c144915

Browse files
Coder-Code-Server: Check if config file exists (#12758)
* Check if config file exists * Apply suggestion from @tremor021 --------- Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com>
1 parent ad1e207 commit c144915

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tools/addon/coder-code-server.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,25 @@ VERSION=$(curl -fsSL https://api.github.com/repos/coder/code-server/releases/lat
8989
awk '{print substr($2, 3, length($2)-4) }')
9090

9191
msg_info "Installing Code-Server v${VERSION}"
92+
93+
if [ -f ~/.config/code-server/config.yaml ]; then
94+
existing_config = true
95+
fi
96+
9297
curl -fOL https://github.com/coder/code-server/releases/download/v"$VERSION"/code-server_"${VERSION}"_amd64.deb &>/dev/null
9398
dpkg -i code-server_"${VERSION}"_amd64.deb &>/dev/null
9499
rm -rf code-server_"${VERSION}"_amd64.deb
95100
mkdir -p ~/.config/code-server/
96101
systemctl enable -q --now code-server@"$USER"
102+
103+
if [ $existing_config = false ]; then
97104
cat <<EOF >~/.config/code-server/config.yaml
98105
bind-addr: 0.0.0.0:8680
99106
auth: none
100107
password:
101108
cert: false
102109
EOF
110+
fi
103111
systemctl restart code-server@"$USER"
104112
msg_ok "Installed Code-Server v${VERSION} on $hostname"
105113

0 commit comments

Comments
 (0)