Adding configuration for Nudge testing (#31928)
In preparation for Nudge testing: - created a label - install policy - install script - pkg for assets - configuration profile
This commit is contained in:
@@ -16,24 +16,25 @@ if [ -z "$DOGFOOD_AUTOMATION_TOKEN" ] || [ -z "$DOGFOOD_AUTOMATION_USER_NAME" ]
|
||||
fi
|
||||
|
||||
# Function to calculate 4 Sundays from today
|
||||
calculate_deadline() {
|
||||
# Get current date
|
||||
current_date=$(date +%Y-%m-%d)
|
||||
|
||||
# Calculate days until next Sunday (0 = Sunday, 1 = Monday, ..., 6 = Saturday)
|
||||
current_day=$(date +%u) # 1-7 (Monday=1, Sunday=7)
|
||||
days_to_next_sunday=$((7 - current_day))
|
||||
if [ $days_to_next_sunday -eq 0 ]; then
|
||||
days_to_next_sunday=7
|
||||
fi
|
||||
|
||||
# Calculate 4 Sundays from today
|
||||
days_to_deadline=$((days_to_next_sunday + 21)) # 3 more weeks (21 days)
|
||||
|
||||
# Calculate the deadline date
|
||||
deadline_date=$(date -d "$current_date + $days_to_deadline days" +%Y-%m-%d)
|
||||
echo "$deadline_date"
|
||||
}
|
||||
# COMMENTED OUT: Deadline calculation logic temporarily disabled
|
||||
# calculate_deadline() {
|
||||
# # Get current date
|
||||
# current_date=$(date +%Y-%m-%d)
|
||||
#
|
||||
# # Calculate days until next Sunday (0 = Sunday, 1 = Monday, ..., 6 = Saturday)
|
||||
# current_day=$(date +%u) # 1-7 (Monday=1, Sunday=7)
|
||||
# days_to_next_sunday=$((7 - current_day))
|
||||
# if [ $days_to_next_sunday -eq 0 ]; then
|
||||
# days_to_next_sunday=7
|
||||
# fi
|
||||
#
|
||||
# # Calculate 4 Sundays from today
|
||||
# days_to_deadline=$((days_to_next_sunday + 21)) # 3 more weeks (21 days)
|
||||
#
|
||||
# # Calculate the deadline date
|
||||
# deadline_date=$(date -d "$current_date + $days_to_deadline days" +%Y-%m-%d)
|
||||
# echo "$deadline_date"
|
||||
# }
|
||||
|
||||
# Function to fetch file content from GitHub
|
||||
fetch_file_content() {
|
||||
@@ -58,26 +59,28 @@ extract_minimum_version() {
|
||||
}
|
||||
|
||||
# Function to extract current deadline from team file content
|
||||
extract_deadline() {
|
||||
local content="$1"
|
||||
local deadline=$(echo "$content" | grep -A 5 "macos_updates:" | grep "deadline:" | sed 's/.*deadline: *"\([^"]*\)".*/\1/')
|
||||
echo "$deadline"
|
||||
}
|
||||
# COMMENTED OUT: Deadline extraction logic temporarily disabled
|
||||
# extract_deadline() {
|
||||
# local content="$1"
|
||||
# local deadline=$(echo "$content" | grep -A 5 "macos_updates:" | grep "deadline:" | sed 's/.*deadline: *"\([^"]*\)".*/\1/')
|
||||
# echo "$deadline"
|
||||
# }
|
||||
|
||||
# Function to update team file content with new version and deadline
|
||||
update_team_file_content() {
|
||||
local content="$1"
|
||||
local new_version="$2"
|
||||
local new_deadline="$3"
|
||||
|
||||
# Update minimum_version
|
||||
content=$(echo "$content" | sed "s/minimum_version: \"[^\"]*\"/minimum_version: \"$new_version\"/")
|
||||
|
||||
# Update deadline
|
||||
content=$(echo "$content" | sed "s/deadline: \"[^\"]*\"/deadline: \"$new_deadline\"/")
|
||||
|
||||
echo "$content"
|
||||
}
|
||||
# COMMENTED OUT: Team file update logic temporarily disabled
|
||||
# update_team_file_content() {
|
||||
# local content="$1"
|
||||
# local new_version="$2"
|
||||
# local new_deadline="$3"
|
||||
#
|
||||
# # Update minimum_version
|
||||
# content=$(echo "$content" | sed "s/minimum_version: \"[^\"]*\"/minimum_version: \"$new_version\"/")
|
||||
#
|
||||
# # Update deadline
|
||||
# content=$(echo "$content" | sed "s/deadline: \"[^\"]*\"/deadline: \"$new_deadline\"/")
|
||||
#
|
||||
# echo "$content"
|
||||
# }
|
||||
|
||||
# Fetch the latest macOS version
|
||||
echo "Fetching latest macOS version..."
|
||||
@@ -93,7 +96,8 @@ echo "Latest macOS version: $latest_macos_version"
|
||||
|
||||
# Initialize update flags
|
||||
policy_update_needed=false
|
||||
team_updates_needed=false
|
||||
# COMMENTED OUT: Team updates flag temporarily disabled
|
||||
# team_updates_needed=false
|
||||
updates_needed=false
|
||||
|
||||
# Check policy file
|
||||
@@ -127,52 +131,53 @@ if [ "$policy_version_number" != "$latest_macos_version" ]; then
|
||||
updates_needed=true
|
||||
fi
|
||||
|
||||
# COMMENTED OUT: Team files check logic temporarily disabled
|
||||
# Check team files
|
||||
echo "Checking team files..."
|
||||
workstations_content=$(fetch_file_content "$WORKSTATIONS_FILE")
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Warning: Could not fetch workstations file, skipping team updates."
|
||||
else
|
||||
workstations_canary_content=$(fetch_file_content "$WORKSTATIONS_CANARY_FILE")
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Warning: Could not fetch workstations-canary file, skipping team updates."
|
||||
else
|
||||
# Extract current versions and deadlines
|
||||
current_workstations_version=$(extract_minimum_version "$workstations_content")
|
||||
current_workstations_deadline=$(extract_deadline "$workstations_content")
|
||||
current_workstations_canary_version=$(extract_minimum_version "$workstations_canary_content")
|
||||
current_workstations_canary_deadline=$(extract_deadline "$workstations_canary_content")
|
||||
|
||||
echo "Current Workstations minimum_version: $current_workstations_version"
|
||||
echo "Current Workstations deadline: $current_workstations_deadline"
|
||||
echo "Current Workstations (canary) minimum_version: $current_workstations_canary_version"
|
||||
echo "Current Workstations (canary) deadline: $current_workstations_canary_deadline"
|
||||
|
||||
# Calculate new deadline
|
||||
new_deadline=$(calculate_deadline)
|
||||
echo "New deadline (4 Sundays from today): $new_deadline"
|
||||
|
||||
# Check if team updates are needed
|
||||
# Only update deadline if there's a new macOS version
|
||||
if [ "$current_workstations_version" != "$latest_macos_version" ]; then
|
||||
team_updates_needed=true
|
||||
updates_needed=true
|
||||
elif [ "$current_workstations_deadline" != "$new_deadline" ] && [ "$policy_update_needed" = true ]; then
|
||||
# Only update deadline if policy was updated (meaning there's a new version)
|
||||
team_updates_needed=true
|
||||
updates_needed=true
|
||||
fi
|
||||
|
||||
if [ "$current_workstations_canary_version" != "$latest_macos_version" ]; then
|
||||
team_updates_needed=true
|
||||
updates_needed=true
|
||||
elif [ "$current_workstations_canary_deadline" != "$new_deadline" ] && [ "$policy_update_needed" = true ]; then
|
||||
# Only update deadline if policy was updated (meaning there's a new version)
|
||||
team_updates_needed=true
|
||||
updates_needed=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# echo "Checking team files..."
|
||||
# workstations_content=$(fetch_file_content "$WORKSTATIONS_FILE")
|
||||
# if [ $? -ne 0 ]; then
|
||||
# echo "Warning: Could not fetch workstations file, skipping team updates."
|
||||
# else
|
||||
# workstations_canary_content=$(fetch_file_content "$WORKSTATIONS_CANARY_FILE")
|
||||
# if [ $? -ne 0 ]; then
|
||||
# echo "Warning: Could not fetch workstations-canary file, skipping team updates."
|
||||
# else
|
||||
# # Extract current versions and deadlines
|
||||
# current_workstations_version=$(extract_minimum_version "$workstations_content")
|
||||
# current_workstations_deadline=$(extract_deadline "$workstations_content")
|
||||
# current_workstations_canary_version=$(extract_minimum_version "$workstations_canary_content")
|
||||
# current_workstations_canary_deadline=$(extract_deadline "$workstations_canary_content")
|
||||
#
|
||||
# echo "Current Workstations minimum_version: $current_workstations_version"
|
||||
# echo "Current Workstations deadline: $current_workstations_deadline"
|
||||
# echo "Current Workstations (canary) minimum_version: $current_workstations_canary_version"
|
||||
# echo "Current Workstations (canary) deadline: $current_workstations_canary_deadline"
|
||||
#
|
||||
# # Calculate new deadline
|
||||
# new_deadline=$(calculate_deadline)
|
||||
# echo "New deadline (4 Sundays from today): $new_deadline"
|
||||
#
|
||||
# # Check if team updates are needed
|
||||
# # Only update deadline if there's a new macOS version
|
||||
# if [ "$current_workstations_version" != "$latest_macos_version" ]; then
|
||||
# team_updates_needed=true
|
||||
# updates_needed=true
|
||||
# elif [ "$current_workstations_deadline" != "$new_deadline" ] && [ "$policy_update_needed" = true ]; then
|
||||
# # Only update deadline if policy was updated (meaning there's a new version)
|
||||
# team_updates_needed=true
|
||||
# updates_needed=true
|
||||
# fi
|
||||
#
|
||||
# if [ "$current_workstations_canary_version" != "$latest_macos_version" ]; then
|
||||
# team_updates_needed=true
|
||||
# updates_needed=true
|
||||
# elif [ "$current_workstations_canary_deadline" != "$new_deadline" ] && [ "$policy_update_needed" = true ]; then
|
||||
# # Only update deadline if policy was updated (meaning there's a new version)
|
||||
# team_updates_needed=true
|
||||
# updates_needed=true
|
||||
# fi
|
||||
# fi
|
||||
# fi
|
||||
|
||||
# Create updates if needed
|
||||
if [ "$updates_needed" = true ]; then
|
||||
@@ -205,17 +210,18 @@ if [ "$updates_needed" = true ]; then
|
||||
git add "$POLICY_FILE_PATH"
|
||||
fi
|
||||
|
||||
# COMMENTED OUT: Team files update logic temporarily disabled
|
||||
# Update team files if needed
|
||||
if [ "$team_updates_needed" = true ]; then
|
||||
echo "Updating team files..."
|
||||
updated_workstations_content=$(update_team_file_content "$workstations_content" "$latest_macos_version" "$new_deadline")
|
||||
updated_canary_content=$(update_team_file_content "$workstations_canary_content" "$latest_macos_version" "$new_deadline")
|
||||
|
||||
echo "$updated_workstations_content" > "$WORKSTATIONS_FILE"
|
||||
echo "$updated_canary_content" > "$WORKSTATIONS_CANARY_FILE"
|
||||
|
||||
git add "$WORKSTATIONS_FILE" "$WORKSTATIONS_CANARY_FILE"
|
||||
fi
|
||||
# if [ "$team_updates_needed" = true ]; then
|
||||
# echo "Updating team files..."
|
||||
# updated_workstations_content=$(update_team_file_content "$workstations_content" "$latest_macos_version" "$new_deadline")
|
||||
# updated_canary_content=$(update_team_file_content "$workstations_canary_content" "$latest_macos_version" "$new_deadline")
|
||||
#
|
||||
# echo "$updated_workstations_content" > "$WORKSTATIONS_FILE"
|
||||
# echo "$updated_canary_content" > "$WORKSTATIONS_CANARY_FILE"
|
||||
#
|
||||
# git add "$WORKSTATIONS_FILE" "$WORKSTATIONS_CANARY_FILE"
|
||||
# fi
|
||||
|
||||
# Create commit message
|
||||
commit_message="Update macOS version to $latest_macos_version"
|
||||
@@ -224,12 +230,13 @@ if [ "$updates_needed" = true ]; then
|
||||
|
||||
- Updated policy version from $policy_version_number to $latest_macos_version"
|
||||
fi
|
||||
if [ "$team_updates_needed" = true ]; then
|
||||
commit_message="$commit_message
|
||||
- Updated team minimum_version from $current_workstations_version to $latest_macos_version
|
||||
- Updated team deadline from $current_workstations_deadline to $new_deadline (4 Sundays from today)
|
||||
- Applied to both workstations and workstations-canary teams"
|
||||
fi
|
||||
# COMMENTED OUT: Team updates commit message logic temporarily disabled
|
||||
# if [ "$team_updates_needed" = true ]; then
|
||||
# commit_message="$commit_message
|
||||
# - Updated team minimum_version from $current_workstations_version to $latest_macos_version
|
||||
# - Updated team deadline from $current_workstations_deadline to $new_deadline (4 Sundays from today)
|
||||
# - Applied to both workstations and workstations-canary teams"
|
||||
# fi
|
||||
|
||||
git commit -m "$commit_message"
|
||||
git push origin "$NEW_BRANCH"
|
||||
|
||||
Reference in New Issue
Block a user