File size: 1,725 Bytes
3ab24da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/command/with-contenv bash
# This script is executed by S6 overlay during container initialization.
set -e

echo "[custom-setup] Starting custom setup script (99-custom-setup.sh)..."

# Attempt to install VS Code extensions
# The user for linuxserver.io images is typically 'abc' (PUID/PGID 1000/1000)
# Extensions are installed into the user's data directory, usually within /config

EXTENSIONS_TO_INSTALL=(
  "ms-python.python"       # Python extension by Microsoft
  "dbaeumer.vscode-eslint" # ESLint extension
)

# Check if openvscode-server or code-server command is available and try to install extensions
# It's important to run this as the correct user (abc)
INSTALL_CMD=""
if command -v openvscode-server &> /dev/null; then
  INSTALL_CMD="openvscode-server"
elif command -v code-server &> /dev/null; then
  INSTALL_CMD="code-server"
fi

if [ -n "$INSTALL_CMD" ]; then
  echo "[custom-setup] Found command: $INSTALL_CMD. Attempting to install extensions..."
  for EXT_ID in "${EXTENSIONS_TO_INSTALL[@]}"; do
    echo "[custom-setup] Installing extension: $EXT_ID"
    if su -ls /bin/bash abc -c "$INSTALL_CMD --install-extension $EXT_ID --force"; then
      echo "[custom-setup] Successfully installed $EXT_ID (or it was already installed)."
    else
      echo "[custom-setup] WARN: Failed to install extension $EXT_ID. Please try installing it manually from the VS Code UI."
    fi
  done
else
  echo "[custom-setup] WARN: Neither 'openvscode-server' nor 'code-server' command found in PATH. Skipping automatic extension installation."
fi

echo "[custom-setup] Extension installation process finished."

# You can add other custom setup tasks here if needed.

echo "[custom-setup] Custom setup script finished."