-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c81b62
commit 3f52568
Showing
3 changed files
with
100 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,28 @@ | ||
#!/usr/bin/expect -f | ||
#!/usr/bin/env expect | ||
|
||
# Set infinite timeout for expect | ||
set timeout -1 | ||
|
||
# Check for presence of the RUNPOD_POD_ID environment variable | ||
if { ![info exists env(RUNPOD_POD_ID)] } { | ||
puts "Error: RUNPOD_POD_ID environment variable is not set." | ||
exit 1 | ||
} | ||
set runpod_pod_id $env(RUNPOD_POD_ID) | ||
|
||
# Spawn the code-server process | ||
spawn code-server \ | ||
--accept-server-license-terms \ | ||
--disable-telemetry \ | ||
serve | ||
|
||
# Automate responses to code-server prompts | ||
expect { | ||
"What would you like to call this machine?" { | ||
send -- "$runpod_pod_id\r" | ||
exp_continue | ||
} | ||
eof | ||
eof { | ||
puts "Finished interacting with code-server." | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
official-templates/vscode-server/src/vscode-server-setup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/bash | ||
|
||
INSTALL_LOCATION=/usr/local/bin/code-server | ||
INSTALL_ARCH=x86_64 | ||
INSTALL_TARGET=unknown-linux-gnu | ||
|
||
MIN_GLIBC_VERSION=2.18 | ||
LDD=$(ldd --version 2>&1) | ||
|
||
if [ "$(uname)" = "Darwin" ]; then | ||
INSTALL_TARGET=apple-darwin-signed | ||
elif echo "$LDD" | grep -q 'musl'; then | ||
INSTALL_TARGET=unknown-linux-musl | ||
echo "is musl" | ||
else | ||
GLIBC_VERSION=$(echo "$LDD" | grep -o 'GLIBC [0-9]\+\.[0-9]\+' | head -n 1 | tr -d 'GLIBC ') | ||
echo "glibc version is $GLIBC_VERSION" | ||
IS_MIN_GLIBC_VERSION=$(awk 'BEGIN{ print "'$MIN_GLIBC_VERSION'"<="'$GLIBC_VERSION'" }') | ||
echo "is min? $IS_MIN_GLIBC_VERSION" | ||
if [ "$IS_MIN_GLIBC_VERSION" = "0" ]; then | ||
INSTALL_TARGET=unknown-linux-musl | ||
fi | ||
fi | ||
|
||
ARCH=$(uname -m) | ||
if [ $ARCH = "aarch64" ] || [ $ARCH = "arm64" ]; then | ||
INSTALL_ARCH=aarch64 | ||
fi | ||
|
||
INSTALL_URL=https://aka.ms/vscode-server-launcher/$INSTALL_ARCH-$INSTALL_TARGET | ||
echo "Installing from $INSTALL_URL" | ||
|
||
|
||
command_exists() { | ||
command -v "$1" > /dev/null 2>&1 | ||
} | ||
|
||
download_into() { | ||
if command_exists curl; then | ||
curl -sSL "$1" -o "$2" | ||
elif command_exists wget; then | ||
wget -qO "$2" "$1" | ||
else | ||
echo "Please install curl or wget" | ||
exit 1 | ||
fi | ||
} | ||
|
||
if command_exists curl; then | ||
DOWNLOAD_WITH=curl | ||
elif command_exists wget; then | ||
DOWNLOAD_WITH=wget | ||
else | ||
echo "Please install curl or wget" | ||
exit 1 | ||
fi | ||
|
||
if command_exists sudo; | ||
then | ||
if [ "$DOWNLOAD_WITH" = curl ]; then | ||
sudo curl -sSL "$INSTALL_URL" -o "$INSTALL_LOCATION" | ||
else | ||
sudo wget -qO "$INSTALL_LOCATION" "$INSTALL_URL" | ||
fi | ||
|
||
sudo chown $USER $INSTALL_LOCATION | ||
else | ||
if [ "$DOWNLOAD_WITH" = curl ]; then | ||
curl -sSL "$INSTALL_URL" -o "$INSTALL_LOCATION" | ||
else | ||
wget -qO "$INSTALL_LOCATION" "$INSTALL_URL" | ||
fi | ||
fi | ||
|
||
chmod +x $INSTALL_LOCATION |