forked from colin/SimpleOtel
40 lines
1.4 KiB
Bash
40 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Define plugin details
|
|
PLUGIN_URL="https://git.nixc.us/colin/SimpleOtel-c5/raw/branch/main/simple-otel.php"
|
|
PLUGIN_DIR="./packages/simple_otel"
|
|
CONFIG_FILE="$PLUGIN_DIR/config.php"
|
|
VENDOR_URL="https://git.nixc.us/colin/SimpleOtel-c5/raw/branch/main/vendor.zip"
|
|
|
|
# Create plugin directory if it doesn't exist
|
|
mkdir -p "$PLUGIN_DIR"
|
|
|
|
# Download the plugin file
|
|
curl -o "$PLUGIN_DIR/simple-otel.php" "$PLUGIN_URL"
|
|
|
|
# Download the vendor directory zip file
|
|
curl -o "$PLUGIN_DIR/vendor.zip" "$VENDOR_URL"
|
|
|
|
# Unzip the vendor directory
|
|
unzip -o "$PLUGIN_DIR/vendor.zip" -d "$PLUGIN_DIR"
|
|
rm "$PLUGIN_DIR/vendor.zip"
|
|
|
|
# Create a blank config.php file if it doesn't exist
|
|
if [ ! -f "$CONFIG_FILE" ]; then
|
|
touch "$CONFIG_FILE"
|
|
echo "<?php" > "$CONFIG_FILE"
|
|
echo "// Configuration for Simple Otel plugin" >> "$CONFIG_FILE"
|
|
echo "// Set default values using environment variables or fallback to manual configuration" >> "$CONFIG_FILE"
|
|
echo "\$otel_service_name = getenv('OTEL_SERVICE_NAME') ?: 'default-service-name';" >> "$CONFIG_FILE"
|
|
echo "\$otel_exporter_otlp_endpoint = getenv('OTEL_EXPORTER_OTLP_ENDPOINT') ?: 'http://localhost:4317';" >> "$CONFIG_FILE"
|
|
else
|
|
echo "config.php already exists."
|
|
fi
|
|
|
|
# Set correct permissions
|
|
chmod 644 "$PLUGIN_DIR/simple-otel.php"
|
|
chmod 644 "$CONFIG_FILE"
|
|
|
|
# Inform user
|
|
echo "Simple Otel plugin installed/updated successfully."
|