Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions misc/custom-script-shim
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
#!/usr/bin/env bash

set -euo pipefail

readonly SCRIPT_DIR=$(dirname "$0")
readonly LOG_DIR="/var/log/azure/custom-script"
readonly LOG_FOLDER_KEY=logFolder
readonly LOG_FILE=handler.log
readonly ARCHITECTURE=$( [[ "$(uname -p)" == "unknown" ]] && echo "$(uname -m)" || echo "$(uname -p)" ) #ternary operator
readonly HANDLER_ENV_PATH="${SCRIPT_DIR}/../HandlerEnvironment.json"
readonly HANDLER_ENV=$(cat $HANDLER_ENV_PATH) # If file is missing, this will come out blank

readonly ARCHITECTURE=$( [[ "$(uname -p)" == "unknown" ]] && echo "$(uname -m)" || echo "$(uname -p)" ) # ternary operator
HANDLER_BIN="custom-script-extension"
if [ $ARCHITECTURE == "arm64" ] || [ $ARCHITECTURE == "aarch64" ]; then
HANDLER_BIN="custom-script-extension-arm64";
HANDLER_BIN="custom-script-extension-arm64"
fi

LOG_DIR="/var/log/azure/custom-script"
if [[ "$HANDLER_ENV" == *"$LOG_FOLDER_KEY"* ]]; then
tmp=${HANDLER_ENV#*$LOG_FOLDER_KEY\": \"}
LOG_DIR=${tmp%%\"\,*}
unset tmp
fi

echo "Placing logs in directory $LOG_DIR"

# status_file returns the .status file path we are supposed to write
# by determining the highest sequence number from ./config/*.settings files.
status_file_path() {
Expand Down
Loading