Skip to content

Proxmox VE Virtual Machine Template for Coder Workspaces #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/scripts/version-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ main() {

# Always run formatter to ensure consistent formatting
echo "🔧 Running formatter to ensure consistent formatting..."
if command -v bun >/dev/null 2>&1; then
bun fmt >/dev/null 2>&1 || echo "⚠️ Warning: bun fmt failed, but continuing..."
if command -v bun > /dev/null 2>&1; then
bun fmt > /dev/null 2>&1 || echo "⚠️ Warning: bun fmt failed, but continuing..."
else
echo "⚠️ Warning: bun not found, skipping formatting"
fi
Expand Down
26 changes: 13 additions & 13 deletions registry/coder/modules/agentapi/scripts/agentapi-wait-for-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ agentapi_started=false

echo "Waiting for agentapi server to start on port $port..."
for i in $(seq 1 150); do
for j in $(seq 1 3); do
sleep 0.1
if curl -fs -o /dev/null "http://localhost:$port/status"; then
echo "agentapi response received ($j/3)"
else
echo "agentapi server not responding ($i/15)"
continue 2
fi
done
agentapi_started=true
break
for j in $(seq 1 3); do
sleep 0.1
if curl -fs -o /dev/null "http://localhost:$port/status"; then
echo "agentapi response received ($j/3)"
else
echo "agentapi server not responding ($i/15)"
continue 2
fi
done
agentapi_started=true
break
done

if [ "$agentapi_started" != "true" ]; then
echo "Error: agentapi server did not start on port $port after 15 seconds."
exit 1
echo "Error: agentapi server did not start on port $port after 15 seconds."
exit 1
fi

echo "agentapi server started on port $port."
94 changes: 47 additions & 47 deletions registry/coder/modules/agentapi/scripts/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,81 +16,81 @@ AGENTAPI_PORT="$ARG_AGENTAPI_PORT"
set +o nounset

command_exists() {
command -v "$1" >/dev/null 2>&1
command -v "$1" > /dev/null 2>&1
}

module_path="$HOME/${MODULE_DIR_NAME}"
mkdir -p "$module_path/scripts"

if [ ! -d "${WORKDIR}" ]; then
echo "Warning: The specified folder '${WORKDIR}' does not exist."
echo "Creating the folder..."
mkdir -p "${WORKDIR}"
echo "Folder created successfully."
echo "Warning: The specified folder '${WORKDIR}' does not exist."
echo "Creating the folder..."
mkdir -p "${WORKDIR}"
echo "Folder created successfully."
fi
if [ -n "${PRE_INSTALL_SCRIPT}" ]; then
echo "Running pre-install script..."
echo -n "${PRE_INSTALL_SCRIPT}" >"$module_path/pre_install.sh"
chmod +x "$module_path/pre_install.sh"
"$module_path/pre_install.sh" 2>&1 | tee "$module_path/pre_install.log"
echo "Running pre-install script..."
echo -n "${PRE_INSTALL_SCRIPT}" > "$module_path/pre_install.sh"
chmod +x "$module_path/pre_install.sh"
"$module_path/pre_install.sh" 2>&1 | tee "$module_path/pre_install.log"
fi

echo "Running install script..."
echo -n "${INSTALL_SCRIPT}" >"$module_path/install.sh"
echo -n "${INSTALL_SCRIPT}" > "$module_path/install.sh"
chmod +x "$module_path/install.sh"
"$module_path/install.sh" 2>&1 | tee "$module_path/install.log"

# Install AgentAPI if enabled
if [ "${INSTALL_AGENTAPI}" = "true" ]; then
echo "Installing AgentAPI..."
arch=$(uname -m)
if [ "$arch" = "x86_64" ]; then
binary_name="agentapi-linux-amd64"
elif [ "$arch" = "aarch64" ]; then
binary_name="agentapi-linux-arm64"
else
echo "Error: Unsupported architecture: $arch"
exit 1
fi
if [ "${AGENTAPI_VERSION}" = "latest" ]; then
# for the latest release the download URL pattern is different than for tagged releases
# https://docs.github.com/en/repositories/releasing-projects-on-github/linking-to-releases
download_url="https://github.com/coder/agentapi/releases/latest/download/$binary_name"
else
download_url="https://github.com/coder/agentapi/releases/download/${AGENTAPI_VERSION}/$binary_name"
fi
curl \
--retry 5 \
--retry-delay 5 \
--fail \
--retry-all-errors \
-L \
-C - \
-o agentapi \
"$download_url"
chmod +x agentapi
sudo mv agentapi /usr/local/bin/agentapi
echo "Installing AgentAPI..."
arch=$(uname -m)
if [ "$arch" = "x86_64" ]; then
binary_name="agentapi-linux-amd64"
elif [ "$arch" = "aarch64" ]; then
binary_name="agentapi-linux-arm64"
else
echo "Error: Unsupported architecture: $arch"
exit 1
fi
if [ "${AGENTAPI_VERSION}" = "latest" ]; then
# for the latest release the download URL pattern is different than for tagged releases
# https://docs.github.com/en/repositories/releasing-projects-on-github/linking-to-releases
download_url="https://github.com/coder/agentapi/releases/latest/download/$binary_name"
else
download_url="https://github.com/coder/agentapi/releases/download/${AGENTAPI_VERSION}/$binary_name"
fi
curl \
--retry 5 \
--retry-delay 5 \
--fail \
--retry-all-errors \
-L \
-C - \
-o agentapi \
"$download_url"
chmod +x agentapi
sudo mv agentapi /usr/local/bin/agentapi
fi
if ! command_exists agentapi; then
echo "Error: AgentAPI is not installed. Please enable install_agentapi or install it manually."
exit 1
echo "Error: AgentAPI is not installed. Please enable install_agentapi or install it manually."
exit 1
fi

echo -n "${START_SCRIPT}" >"$module_path/scripts/agentapi-start.sh"
echo -n "${WAIT_FOR_START_SCRIPT}" >"$module_path/scripts/agentapi-wait-for-start.sh"
echo -n "${START_SCRIPT}" > "$module_path/scripts/agentapi-start.sh"
echo -n "${WAIT_FOR_START_SCRIPT}" > "$module_path/scripts/agentapi-wait-for-start.sh"
chmod +x "$module_path/scripts/agentapi-start.sh"
chmod +x "$module_path/scripts/agentapi-wait-for-start.sh"

if [ -n "${POST_INSTALL_SCRIPT}" ]; then
echo "Running post-install script..."
echo -n "${POST_INSTALL_SCRIPT}" >"$module_path/post_install.sh"
chmod +x "$module_path/post_install.sh"
"$module_path/post_install.sh" 2>&1 | tee "$module_path/post_install.log"
echo "Running post-install script..."
echo -n "${POST_INSTALL_SCRIPT}" > "$module_path/post_install.sh"
chmod +x "$module_path/post_install.sh"
"$module_path/post_install.sh" 2>&1 | tee "$module_path/post_install.log"
fi

export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

cd "${WORKDIR}"
nohup "$module_path/scripts/agentapi-start.sh" true "${AGENTAPI_PORT}" &>"$module_path/agentapi-start.log" &
nohup "$module_path/scripts/agentapi-start.sh" true "${AGENTAPI_PORT}" &> "$module_path/agentapi-start.log" &
"$module_path/scripts/agentapi-wait-for-start.sh" "${AGENTAPI_PORT}"
8 changes: 4 additions & 4 deletions registry/coder/modules/agentapi/testdata/agentapi-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ port=${2:-3284}
module_path="$HOME/.agentapi-module"
log_file_path="$module_path/agentapi.log"

echo "using prompt: $use_prompt" >>/home/coder/test-agentapi-start.log
echo "using port: $port" >>/home/coder/test-agentapi-start.log
echo "using prompt: $use_prompt" >> /home/coder/test-agentapi-start.log
echo "using port: $port" >> /home/coder/test-agentapi-start.log

agentapi server --port "$port" --term-width 67 --term-height 1190 -- \
bash -c aiagent \
>"$log_file_path" 2>&1
bash -c aiagent \
> "$log_file_path" 2>&1
30 changes: 15 additions & 15 deletions registry/coder/modules/claude-code/scripts/agentapi-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ log_file_path="$module_path/agentapi.log"

# if the first argument is not empty, start claude with the prompt
if [ -n "$1" ]; then
cp "$module_path/prompt.txt" /tmp/claude-code-prompt
cp "$module_path/prompt.txt" /tmp/claude-code-prompt
else
rm -f /tmp/claude-code-prompt
rm -f /tmp/claude-code-prompt
fi

# if the log file already exists, archive it
if [ -f "$log_file_path" ]; then
mv "$log_file_path" "$log_file_path"".$(date +%s)"
mv "$log_file_path" "$log_file_path"".$(date +%s)"
fi

# see the remove-last-session-id.js script for details
Expand All @@ -28,14 +28,14 @@ node "$scripts_dir/remove-last-session-id.js" "$(pwd)" || true
set +o errexit

function start_agentapi() {
local continue_flag="$1"
local prompt_subshell='"$(cat /tmp/claude-code-prompt)"'
# use low width to fit in the tasks UI sidebar. height is adjusted so that width x height ~= 80x1000 characters
# visible in the terminal screen by default.
agentapi server --term-width 67 --term-height 1190 -- \
bash -c "claude $continue_flag --dangerously-skip-permissions $prompt_subshell" \
> "$log_file_path" 2>&1
local continue_flag="$1"
local prompt_subshell='"$(cat /tmp/claude-code-prompt)"'

# use low width to fit in the tasks UI sidebar. height is adjusted so that width x height ~= 80x1000 characters
# visible in the terminal screen by default.
agentapi server --term-width 67 --term-height 1190 -- \
bash -c "claude $continue_flag --dangerously-skip-permissions $prompt_subshell" \
> "$log_file_path" 2>&1
}

echo "Starting AgentAPI..."
Expand All @@ -47,15 +47,15 @@ exit_code=$?
echo "First AgentAPI exit code: $exit_code"

if [ $exit_code -eq 0 ]; then
exit 0
exit 0
fi

# if there was no conversation to continue, claude exited with an error.
# start claude without the --continue flag.
if grep -q "No conversation found to continue" "$log_file_path"; then
echo "AgentAPI with --continue flag failed, starting claude without it."
start_agentapi
exit_code=$?
echo "AgentAPI with --continue flag failed, starting claude without it."
start_agentapi
exit_code=$?
fi

echo "Second AgentAPI exit code: $exit_code"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ agentapi_started=false

echo "Waiting for agentapi server to start on port 3284..."
for i in $(seq 1 150); do
for j in $(seq 1 3); do
sleep 0.1
if curl -fs -o /dev/null "http://localhost:3284/status"; then
echo "agentapi response received ($j/3)"
else
echo "agentapi server not responding ($i/15)"
continue 2
fi
done
agentapi_started=true
break
for j in $(seq 1 3); do
sleep 0.1
if curl -fs -o /dev/null "http://localhost:3284/status"; then
echo "agentapi response received ($j/3)"
else
echo "agentapi server not responding ($i/15)"
continue 2
fi
done
agentapi_started=true
break
done

if [ "$agentapi_started" != "true" ]; then
echo "Error: agentapi server did not start on port 3284 after 15 seconds."
exit 1
echo "Error: agentapi server did not start on port 3284 after 15 seconds."
exit 1
fi

echo "agentapi server started on port 3284."
66 changes: 33 additions & 33 deletions registry/coder/modules/devcontainers-cli/run.sh
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
#!/usr/bin/env sh

# If @devcontainers/cli is already installed, we can skip
if command -v devcontainer >/dev/null 2>&1; then
echo "🥳 @devcontainers/cli is already installed into $(which devcontainer)!"
exit 0
if command -v devcontainer > /dev/null 2>&1; then
echo "🥳 @devcontainers/cli is already installed into $(which devcontainer)!"
exit 0
fi

# Check if docker is installed
if ! command -v docker >/dev/null 2>&1; then
echo "WARNING: Docker was not found but is required to use @devcontainers/cli, please make sure it is available."
if ! command -v docker > /dev/null 2>&1; then
echo "WARNING: Docker was not found but is required to use @devcontainers/cli, please make sure it is available."
fi

# Determine the package manager to use: npm, pnpm, or yarn
if command -v yarn >/dev/null 2>&1; then
PACKAGE_MANAGER="yarn"
elif command -v npm >/dev/null 2>&1; then
PACKAGE_MANAGER="npm"
elif command -v pnpm >/dev/null 2>&1; then
PACKAGE_MANAGER="pnpm"
if command -v yarn > /dev/null 2>&1; then
PACKAGE_MANAGER="yarn"
elif command -v npm > /dev/null 2>&1; then
PACKAGE_MANAGER="npm"
elif command -v pnpm > /dev/null 2>&1; then
PACKAGE_MANAGER="pnpm"
else
echo "ERROR: No supported package manager (npm, pnpm, yarn) is installed. Please install one first." 1>&2
exit 1
echo "ERROR: No supported package manager (npm, pnpm, yarn) is installed. Please install one first." 1>&2
exit 1
fi

install() {
echo "Installing @devcontainers/cli using $PACKAGE_MANAGER..."
if [ "$PACKAGE_MANAGER" = "npm" ]; then
npm install -g @devcontainers/cli
elif [ "$PACKAGE_MANAGER" = "pnpm" ]; then
# Check if PNPM_HOME is set, if not, set it to the script's bin directory
# pnpm needs this to be set to install binaries
# coder agent ensures this part is part of the PATH
# so that the devcontainer command is available
if [ -z "$PNPM_HOME" ]; then
PNPM_HOME="$CODER_SCRIPT_BIN_DIR"
export M_HOME
fi
pnpm add -g @devcontainers/cli
elif [ "$PACKAGE_MANAGER" = "yarn" ]; then
yarn global add @devcontainers/cli --prefix "$(dirname "$CODER_SCRIPT_BIN_DIR")"
echo "Installing @devcontainers/cli using $PACKAGE_MANAGER..."
if [ "$PACKAGE_MANAGER" = "npm" ]; then
npm install -g @devcontainers/cli
elif [ "$PACKAGE_MANAGER" = "pnpm" ]; then
# Check if PNPM_HOME is set, if not, set it to the script's bin directory
# pnpm needs this to be set to install binaries
# coder agent ensures this part is part of the PATH
# so that the devcontainer command is available
if [ -z "$PNPM_HOME" ]; then
PNPM_HOME="$CODER_SCRIPT_BIN_DIR"
export M_HOME
fi
pnpm add -g @devcontainers/cli
elif [ "$PACKAGE_MANAGER" = "yarn" ]; then
yarn global add @devcontainers/cli --prefix "$(dirname "$CODER_SCRIPT_BIN_DIR")"
fi
}

if ! install; then
echo "Failed to install @devcontainers/cli" >&2
exit 1
echo "Failed to install @devcontainers/cli" >&2
exit 1
fi

if ! command -v devcontainer >/dev/null 2>&1; then
echo "Installation completed but 'devcontainer' command not found in PATH" >&2
exit 1
if ! command -v devcontainer > /dev/null 2>&1; then
echo "Installation completed but 'devcontainer' command not found in PATH" >&2
exit 1
fi

echo "🥳 @devcontainers/cli has been installed into $(which devcontainer)!"
Expand Down
4 changes: 2 additions & 2 deletions registry/coder/modules/filebrowser/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BOLD='\033[[0;1m'
printf "$${BOLD}Installing filebrowser \n\n"

# Check if filebrowser is installed
if ! command -v filebrowser &>/dev/null; then
if ! command -v filebrowser &> /dev/null; then
curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash
fi

Expand All @@ -34,6 +34,6 @@ printf "👷 Starting filebrowser in background... \n\n"

printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n"

filebrowser >>${LOG_PATH} 2>&1 &
filebrowser >> ${LOG_PATH} 2>&1 &

printf "📝 Logs at ${LOG_PATH} \n\n"
Loading