29 lines
823 B
Bash
Executable File
29 lines
823 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
error() {
|
|
echo $@
|
|
return 1
|
|
}
|
|
|
|
/etc/init.d/ssh start || echo "Failed to start sshd. Maybe the port is already in use, and please check your sshd_config. This is not an error if it's the first time you run this container."
|
|
if [[ ! -e /root/.config/code-server/config.yaml ]]; then
|
|
mkdir -p /root/.config/code-server
|
|
sockname=$(openssl rand -hex 12)
|
|
test "${#sockname}" = "24" || error "invalid sock name: ${sockname}"
|
|
password=$(openssl rand -base64 15)
|
|
test -n "$password" || error "invalid password: ${password}"
|
|
cat << EOF > /root/.config/code-server/config.yaml
|
|
socket: /home2/run/$sockname.sock
|
|
socket-mode: 777
|
|
auth: password
|
|
password: $password
|
|
cert: false
|
|
EOF
|
|
fi
|
|
if [[ -d /home2/run && -x $(command -v code-server) ]]; then
|
|
code-server
|
|
else
|
|
bash
|
|
fi
|