2
0
Fork 0

Update install.sh

This commit is contained in:
colin 2024-07-01 18:23:00 +00:00
parent b47108d242
commit d91cd26b49
1 changed files with 17 additions and 7 deletions

View File

@ -3,6 +3,8 @@
# Define plugin details
PLUGIN_URL="https://git.nixc.us/colin/SimpleOtel/raw/branch/main/simple-otel.php"
PLUGIN_DIR="./wp-content/plugins/simple-otel"
CONFIG_FILE="$PLUGIN_DIR/config.php"
VENDOR_URL="https://git.nixc.us/colin/SimpleOtel/raw/branch/main/vendor.zip"
# Create plugin directory if it doesn't exist
mkdir -p "$PLUGIN_DIR"
@ -10,20 +12,28 @@ 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 "$PLUGIN_DIR/config.php" ]; then
touch "$PLUGIN_DIR/config.php"
echo "<?php" > "$PLUGIN_DIR/config.php"
echo "// Configuration for Simple Otel plugin" >> "$PLUGIN_DIR/config.php"
echo "// Add your configurations here" >> "$PLUGIN_DIR/config.php"
echo "Configuration file created at wp-content/plugins/simple-otel/config.php."
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 "$PLUGIN_DIR/config.php"
chmod 644 "$CONFIG_FILE"
# Inform user
echo "Simple Otel plugin installed/updated successfully."