xx
This commit is contained in:
@@ -147,6 +147,8 @@ locals {
|
||||
" apt-get install -y python3.12 python3.12-venv python3.12-dev python3-pip",
|
||||
" update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1",
|
||||
"fi",
|
||||
"mkdir -p /workspaces",
|
||||
"chown -R coder:coder /workspaces || echo 'Cannot change workspace ownership'",
|
||||
"# SSL Certificate setup (running as root)",
|
||||
"if [ -f /home/coder/lab-certs/lab.crt ]; then",
|
||||
" echo 'Installing SSL certificate for lab.crt'",
|
||||
|
||||
@@ -94,21 +94,29 @@ done
|
||||
|
||||
# Clone requested repository into /workspaces if not already present
|
||||
mkdir -p /workspaces
|
||||
workspace_has_content=false
|
||||
if [ -n "$(find /workspaces -mindepth 1 -maxdepth 1 ! -name '.git' ! -name 'lost+found' -print -quit 2>/dev/null)" ]; then
|
||||
workspace_has_content=true
|
||||
fi
|
||||
if [ -n "$${CODER_WORKSPACE_REPO:-}" ]; then
|
||||
if [ ! -d /workspaces/.git ]; then
|
||||
if [ -z "$(ls -A /workspaces 2>/dev/null)" ]; then
|
||||
if [ -d /workspaces/.git ]; then
|
||||
echo "Git repository already present in /workspaces"
|
||||
else
|
||||
if [ "$workspace_has_content" = "false" ]; then
|
||||
echo "Cloning $${CODER_WORKSPACE_REPO} into /workspaces"
|
||||
if (cd /workspaces && git clone "$${CODER_WORKSPACE_REPO}" .); then
|
||||
echo "Repository clone completed"
|
||||
else
|
||||
echo "Git clone failed; initializing empty repository"
|
||||
(cd /workspaces && git init . && echo "Initialized empty workspace directory")
|
||||
if (cd /workspaces && git init .); then
|
||||
echo "Initialized empty workspace directory"
|
||||
else
|
||||
echo "Failed to initialise repository; please check permissions"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "/workspaces already contains files; skipping automatic clone"
|
||||
fi
|
||||
else
|
||||
echo "Git repository already present in /workspaces"
|
||||
fi
|
||||
else
|
||||
echo "No repository requested"
|
||||
|
||||
Reference in New Issue
Block a user