From d91cd26b4933c26759438e33a76736c1ae46ef55 Mon Sep 17 00:00:00 2001 From: colin Date: Mon, 1 Jul 2024 18:23:00 +0000 Subject: [PATCH] Update install.sh --- install.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index c55800f..469f44b 100644 --- a/install.sh +++ b/install.sh @@ -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 " "$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 " "$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."