feat: pull the image from root repo if not available locally
This commit is contained in:
parent
da444a58cc
commit
6ec78f09fd
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
PERSON="$1"
|
PERSON="$1"
|
||||||
WORKSPACE="$SSH_ORIGINAL_COMMAND"
|
WORKSPACE="$SSH_ORIGINAL_COMMAND"
|
||||||
IMAGE="analytics-backend-workspace" # change to match your setup
|
IMAGE="localhost:5100/analytics-backend-workspace:latest"
|
||||||
TMUX_SESSION="$WORKSPACE|analytics-backend"
|
TMUX_SESSION="$WORKSPACE|analytics-backend"
|
||||||
DEV_USER="devuser"
|
DEV_USER="devuser"
|
||||||
|
|
||||||
@ -10,11 +10,29 @@ log() {
|
|||||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ ! "$WORKSPACE" =~ ^[a-zA-Z0-9._-]+$ ]]; then
|
# Log access
|
||||||
log "❌ Invalid container name: $WORKSPACE"
|
log "[SSH] $USER connected with command: $SSH_ORIGINAL_COMMAND" >>/home/infilytics/ssh-router.log
|
||||||
exit 1
|
|
||||||
|
# Check if image exists locally
|
||||||
|
if ! podman image exists "$IMAGE"; then
|
||||||
|
log "📦 Image $IMAGE not found locally. Pulling from registry..."
|
||||||
|
|
||||||
|
# Attempt to pull the image from the local registry (insecure HTTP)
|
||||||
|
if ! podman pull --tls-verify=false "$IMAGE"; then
|
||||||
|
log "❌ Failed to pull image from $IMAGE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "✅ Successfully pulled $IMAGE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
case "$SSH_ORIGINAL_COMMAND" in
|
||||||
|
*scp* | *sftp* | *rsync* | *tar*)
|
||||||
|
log "❌ File transfers are disabled"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Function to start the container if not running
|
# Function to start the container if not running
|
||||||
start_container_if_needed() {
|
start_container_if_needed() {
|
||||||
if ! podman container exists "$WORKSPACE"; then
|
if ! podman container exists "$WORKSPACE"; then
|
||||||
@ -55,6 +73,18 @@ get_access_mode_and_session() {
|
|||||||
local workspace="$1"
|
local workspace="$1"
|
||||||
local person="$2"
|
local person="$2"
|
||||||
|
|
||||||
|
# If workspace is empty, use person's name
|
||||||
|
if [[ -z "$workspace" ]]; then
|
||||||
|
WORKSPACE="$person"
|
||||||
|
echo "access=rw"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! "$workspace" =~ ^[a-zA-Z0-9._-]+$ ]]; then
|
||||||
|
log "❌ Invalid container name: $WORKSPACE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Special case: user accessing their own workspace
|
# Special case: user accessing their own workspace
|
||||||
if [[ "$workspace" == "$person" ]]; then
|
if [[ "$workspace" == "$person" ]]; then
|
||||||
echo "access=rw"
|
echo "access=rw"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user