|
#!/bin/bash |
|
|
|
|
|
echo "Exporting environment variables..." |
|
printenv | grep -E '^RUNPOD_|^PATH=|^_=' | sed 's/^\(.*\)=\(.*\)$/export \1="\2"/' >> /etc/rp_environment |
|
conda init |
|
|
|
echo 'source /etc/rp_environment' >> ~/.bashrc |
|
|
|
add_keys_to_authorized() { |
|
local key_value=$1 |
|
|
|
|
|
mkdir -p ~/.ssh |
|
chmod 700 ~/.ssh |
|
|
|
|
|
touch ~/.ssh/authorized_keys |
|
|
|
|
|
local key="" |
|
|
|
|
|
for word in $key_value; do |
|
|
|
if [[ $word == ssh-* ]]; then |
|
|
|
if [[ -n $key ]]; then |
|
echo $key >> ~/.ssh/authorized_keys |
|
fi |
|
|
|
key=$word |
|
else |
|
|
|
key="$key $word" |
|
fi |
|
done |
|
|
|
|
|
if [[ -n $key ]]; then |
|
echo $key >> ~/.ssh/authorized_keys |
|
fi |
|
|
|
|
|
chmod 600 ~/.ssh/authorized_keys |
|
chmod 700 -R ~/.ssh |
|
} |
|
|
|
if [[ $PUBLIC_KEY ]]; then |
|
|
|
add_keys_to_authorized "$PUBLIC_KEY" |
|
|
|
service ssh start |
|
elif [[ $SSH_KEY ]]; then |
|
|
|
add_keys_to_authorized "$SSH_KEY" |
|
|
|
service ssh start |
|
else |
|
echo "No PUBLIC_KEY or SSH_KEY environment variable provided, not starting openSSH daemon" |
|
fi |
|
|
|
|
|
if [ -n "$JUPYTER_PASSWORD" ]; then |
|
|
|
export JUPYTER_TOKEN="$JUPYTER_PASSWORD" |
|
fi |
|
|
|
if [ "$JUPYTER_DISABLE" != "1" ]; then |
|
|
|
jupyter lab --port=8888 --ip=* --allow-root --ServerApp.allow_origin=* & |
|
fi |
|
|
|
if [ ! -d "/workspace/data/axolotl-artifacts" ]; then |
|
mkdir -p /workspace/data/axolotl-artifacts |
|
fi |
|
if [ ! -L "/workspace/axolotl/outputs" ]; then |
|
ln -sf /workspace/data/axolotl-artifacts /workspace/axolotl/outputs |
|
fi |
|
|
|
|
|
exec "$@" |
|
|