forked from freeleaps/freeleaps-pub
45 lines
1.3 KiB
Bash
Executable File
45 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
export CONTAINER_NAME="devbox_local"
|
|
|
|
if [ ! -d "./freeleaps" ]; then
|
|
echo "Error: ./freeleaps directory does not exist."
|
|
return 1
|
|
fi
|
|
|
|
if [ ! -f "./.acr_token" ]; then
|
|
echo "Error: .acr_token file does not exist or is empty. Please run acr_login.sh first."
|
|
return 1
|
|
fi
|
|
|
|
# Try to get the architecture using the `arch` command
|
|
ARCH=$(arch 2>/dev/null)
|
|
|
|
# Check if the architecture is 'arm64'
|
|
if [ "$ARCH" = "arm64" ]; then
|
|
TAG="latest-linux-arm64"
|
|
ACR_TOKEN="acr_token"
|
|
else
|
|
TAG="latest-linux-amd64"
|
|
ACR_TOKEN=".acr_token"
|
|
fi
|
|
|
|
if ! docker pull freeleaps.azurecr.io/devbox_v3:${TAG}; then
|
|
echo "Error: Failed to pull the latest devbox_v3 image."
|
|
return 1
|
|
fi
|
|
|
|
if docker ps --format '{{.Names}}' | grep -q ^${CONTAINER_NAME}$; then
|
|
echo "Container '${CONTAINER_NAME}' is already running."
|
|
return 0
|
|
fi
|
|
|
|
if ! docker run --privileged -d -p 22222:22 \
|
|
-v ./freeleaps:/mnt/freeleaps \
|
|
-v ./${ACR_TOKEN}:/home/freedev/devbox/.acr_token \
|
|
-v ./var/lib/docker/app/devsvc/log:/var/lib/docker/app/devsvc/log \
|
|
--name ${CONTAINER_NAME} freeleaps.azurecr.io/devbox_v3:${TAG}; then
|
|
echo "Error: Failed to start the ${CONTAINER_NAME} container."
|
|
return 1
|
|
fi
|
|
|
|
echo "${CONTAINER_NAME} container started successfully." |