Page MenuHomePhabricator
Paste P84273

mw-experimental-shell
ActivePublic

Authored by jijiki on Oct 23 2025, 10:33 AM.
Tags
None
Referenced Files
F66785416: mw-experimental-shell
Oct 23 2025, 10:33 AM
Subscribers
None
#!/bin/bash
# Source /etc/profile.d/ (kube_env is defined there)
if [ -d /etc/profile.d ]; then
for file in /etc/profile.d/*.sh; do
[ -r "$file" ] && source "$file"
done
fi
# Check DC arg is given
if [ -z "$1" ]; then
echo "Usage: $0 <DC>"
echo "DC must be 'eqiad' or 'codfw'."
exit 1
fi
DC="$1"
if [ "$DC" != "eqiad" ] && [ "$DC" != "codfw" ]; then
echo "Error: DC must be either 'eqiad' or 'codfw'."
exit 1
fi
# Activate the kube environment
echo "Activating env for mw-experimental in $DC..."
kube_env mw-experimental-deploy "$DC" || { echo "Failed to set kube environment"; exit 1; }
# Get the pod name (we have 1 pod per DC)
POD=$(kubectl get po --no-headers -o custom-columns=":metadata.name" | grep '^mw-experimental' | head -n1)
if [ -z "$POD" ]; then
echo "Error: no 'mw-experimental' pods found."
exit 1
fi
echo "Found a pod! $POD"
# Start an interactive bash session with a custom prompt
kubectl exec "$POD" -c mediawiki-pinkllama-app -it -- bash -c 'CLUSTER=$(cat /etc/wikimedia-cluster); echo "PS1=\"\${debian_chroot:+(\$debian_chroot)}\u@\\h-${CLUSTER}:\w\\$ \" ; export PS1" > /tmp/custom_ps1; bash --rcfile /tmp/custom_ps1 -i'