Spaces:
Paused
Paused
Delete entrypoint.sh
Browse files- entrypoint.sh +0 -117
entrypoint.sh
DELETED
|
@@ -1,117 +0,0 @@
|
|
| 1 |
-
#!/bin/sh
|
| 2 |
-
# Exit immediately if a command exits with a non-zero status.
|
| 3 |
-
set -e
|
| 4 |
-
|
| 5 |
-
echo "--- Running Entrypoint Script as user: $(id -u -n) ---"
|
| 6 |
-
|
| 7 |
-
# --- BEGIN: Install Plugins at Runtime ---
|
| 8 |
-
if [ -n "$PLUGINS" ]; then
|
| 9 |
-
echo '--- Found PLUGINS environment variable, attempting to install plugins ---'
|
| 10 |
-
# Ensure plugin dir exists within the app home
|
| 11 |
-
mkdir -p ./plugins
|
| 12 |
-
|
| 13 |
-
# Using printf/read loop which is often more robust than IFS for comma-separated lists
|
| 14 |
-
printf "%s," "$PLUGINS" | while IFS= read -r plugin_url_with_comma; do
|
| 15 |
-
# Remove trailing comma if exists
|
| 16 |
-
plugin_url="${plugin_url_with_comma%,}"
|
| 17 |
-
|
| 18 |
-
# Trim leading/trailing whitespace using awk (should be available via busybox)
|
| 19 |
-
plugin_url=$(echo "$plugin_url" | awk '{$1=$1;print}')
|
| 20 |
-
|
| 21 |
-
if [ -z "$plugin_url" ]; then continue; fi
|
| 22 |
-
|
| 23 |
-
# Extract plugin name: remove .git suffix, then get basename
|
| 24 |
-
# Handle URLs that might not end in .git
|
| 25 |
-
plugin_name_tmp="${plugin_url%.git}"
|
| 26 |
-
plugin_name="${plugin_name_tmp##*/}"
|
| 27 |
-
|
| 28 |
-
if [ -z "$plugin_name" ]; then
|
| 29 |
-
echo "WARN: Could not extract plugin name from URL: $plugin_url, skipping."
|
| 30 |
-
continue
|
| 31 |
-
fi
|
| 32 |
-
|
| 33 |
-
plugin_dir="./plugins/$plugin_name"
|
| 34 |
-
echo "--- Processing plugin: $plugin_name from $plugin_url ---"
|
| 35 |
-
|
| 36 |
-
# Clone (remove existing first for clean install)
|
| 37 |
-
echo "Removing existing directory $plugin_dir (if any)..."
|
| 38 |
-
rm -rf "$plugin_dir"
|
| 39 |
-
echo "Cloning $plugin_name from $plugin_url into $plugin_dir..."
|
| 40 |
-
if git clone --depth 1 "$plugin_url" "$plugin_dir"; then
|
| 41 |
-
echo "Cloned successfully."
|
| 42 |
-
# Install dependencies if package.json exists
|
| 43 |
-
if [ -f "$plugin_dir/package.json" ]; then
|
| 44 |
-
echo "Found package.json, installing dependencies for $plugin_name..."
|
| 45 |
-
# Run npm install within the plugin directory using a subshell
|
| 46 |
-
(cd "$plugin_dir" && npm install --no-audit --no-fund --loglevel=error --no-progress --omit=dev --force && npm cache clean --force)
|
| 47 |
-
if [ $? -ne 0 ]; then
|
| 48 |
-
echo "WARN: Failed to install dependencies for $plugin_name"
|
| 49 |
-
else
|
| 50 |
-
echo "Dependencies installed for $plugin_name."
|
| 51 |
-
fi
|
| 52 |
-
else
|
| 53 |
-
echo "No package.json found for $plugin_name, skipping dependency install."
|
| 54 |
-
fi
|
| 55 |
-
else
|
| 56 |
-
echo "WARN: Failed to clone $plugin_name from $plugin_url, skipping further processing."
|
| 57 |
-
fi
|
| 58 |
-
echo "--- Finished processing $plugin_name ---"
|
| 59 |
-
done
|
| 60 |
-
echo '--- Finished installing all specified plugins ---'
|
| 61 |
-
else
|
| 62 |
-
echo '--- PLUGINS environment variable not set or empty, skipping plugin installation ---'
|
| 63 |
-
fi
|
| 64 |
-
# --- END: Install Plugins at Runtime ---
|
| 65 |
-
|
| 66 |
-
# --- Config Handling ---
|
| 67 |
-
echo '--- Checking for CONFIG_YAML environment variable ---'
|
| 68 |
-
CONFIG_FILE="./config.yaml"
|
| 69 |
-
if [ -n "$CONFIG_YAML" ]; then
|
| 70 |
-
echo "Environment variable CONFIG_YAML found. Writing to $CONFIG_FILE..."
|
| 71 |
-
# Write directly to ./config.yaml in the CWD (should be APP_HOME)
|
| 72 |
-
# Use printf to handle potential special characters in YAML
|
| 73 |
-
printf '%s\n' "$CONFIG_YAML" > "$CONFIG_FILE"
|
| 74 |
-
if [ $? -eq 0 ]; then
|
| 75 |
-
echo "Config written to $CONFIG_FILE successfully."
|
| 76 |
-
# --- BEGIN DEBUG: Print the written config file ---
|
| 77 |
-
echo "--- Verifying written $CONFIG_FILE ---"
|
| 78 |
-
cat "$CONFIG_FILE"
|
| 79 |
-
echo "--- End of $CONFIG_FILE ---"
|
| 80 |
-
# --- END DEBUG ---
|
| 81 |
-
else
|
| 82 |
-
echo "ERROR: Failed to write config to $CONFIG_FILE" >&2
|
| 83 |
-
# Clear variable so default logic runs if write failed
|
| 84 |
-
CONFIG_YAML=""
|
| 85 |
-
fi
|
| 86 |
-
else
|
| 87 |
-
echo 'Warning: Environment variable CONFIG_YAML is not set or empty.'
|
| 88 |
-
fi
|
| 89 |
-
|
| 90 |
-
# If config file doesn't exist or is empty after potential write attempt, try default
|
| 91 |
-
if [ ! -s "$CONFIG_FILE" ]; then
|
| 92 |
-
echo "Attempting to copy default config (because $CONFIG_FILE is missing or empty)..."
|
| 93 |
-
DEFAULT_CONFIG_EXAMPLE="./public/config.yaml.example"
|
| 94 |
-
if [ -f "$DEFAULT_CONFIG_EXAMPLE" ]; then
|
| 95 |
-
cp "$DEFAULT_CONFIG_EXAMPLE" "$CONFIG_FILE" && \
|
| 96 |
-
echo "Copied default config from $DEFAULT_CONFIG_EXAMPLE to $CONFIG_FILE"
|
| 97 |
-
else
|
| 98 |
-
echo "Warning: Default config $DEFAULT_CONFIG_EXAMPLE not found. SillyTavern might fail without a config file."
|
| 99 |
-
fi
|
| 100 |
-
fi
|
| 101 |
-
# --- END Config Handling ---
|
| 102 |
-
|
| 103 |
-
# --- BEGIN: Configure Git default identity at Runtime ---
|
| 104 |
-
# This is needed if plugins perform git operations
|
| 105 |
-
echo '--- Configuring Git default user identity at runtime ---'
|
| 106 |
-
# Check if user.name or user.email is already set to avoid errors
|
| 107 |
-
# Use git config commands directly, checking return code isn't strictly needed here
|
| 108 |
-
git config --global user.name "SillyTavern Sync" || echo "Could not set git user.name"
|
| 109 |
-
git config --global user.email "sillytavern-sync@example.com" || echo "Could not set git user.email"
|
| 110 |
-
# Ensure the app directory is marked as safe
|
| 111 |
-
git config --global --add safe.directory "$APP_HOME" || echo "Could not add safe directory"
|
| 112 |
-
echo '--- Git identity configured (or attempted) for runtime user. ---'
|
| 113 |
-
# --- END: Configure Git default identity at Runtime ---
|
| 114 |
-
|
| 115 |
-
echo "--- Starting SillyTavern server ---"
|
| 116 |
-
# Execute node server directly. 'exec' replaces the shell process with the node process.
|
| 117 |
-
exec node server.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|