foam_sync.ps1 (LIFEBALANCE) 2025-06-19T14:09:16Z
This commit is contained in:
@ -1,19 +1,18 @@
|
|||||||
#Requires -Version 5.1
|
#Requires -Version 5.1
|
||||||
|
Set-StrictMode -Version 3.0
|
||||||
|
|
||||||
$task = @{
|
$scriptPath = $MyInvocation.MyCommand.Path
|
||||||
name = 'FoamGitSync'
|
$scriptDir = Split-Path -Path $scriptPath -Parent
|
||||||
description = "Periodically synchronizes the Git repository at $scriptDir using $scriptName."
|
$logDir = Join-Path -Path $scriptDir -ChildPath ".logs"
|
||||||
freqencyMinutes = 2
|
$logName = "foam_sync.log"
|
||||||
}
|
$logFilePath = Join-Path -Path $logDir -ChildPath $logName
|
||||||
|
$scriptName = (Get-Item $scriptPath).Name
|
||||||
|
|
||||||
# --- Configuration ---
|
# --- Task Setup ---
|
||||||
$frequencyMinutes = $task.freqencyMinutes # How often the Scheduled Task should attempt to run this script
|
$taskName = 'FoamGitSync'
|
||||||
$taskName = $task.name
|
$taskDescription = "Periodically synchronizes the Git repository at $scriptDir using $scriptName."
|
||||||
|
$frequencyMinutes = 2
|
||||||
|
|
||||||
# --- Log File Setup ---
|
|
||||||
# Log inside the repository, in a .logs subfolder. Ensure this is in .gitignore
|
|
||||||
$scriptDirForLog = $PSScriptRoot # Use PSScriptRoot for robustness in determining script's dir
|
|
||||||
$logDir = Join-Path -Path $scriptDirForLog -ChildPath ".logs"
|
|
||||||
if (-not (Test-Path -Path $logDir)) {
|
if (-not (Test-Path -Path $logDir)) {
|
||||||
New-Item -ItemType Directory -Path $logDir -Force | Out-Null
|
New-Item -ItemType Directory -Path $logDir -Force | Out-Null
|
||||||
}
|
}
|
||||||
@ -22,9 +21,7 @@ $logFilePath = Join-Path -Path $logDir -ChildPath "foam_sync.log"
|
|||||||
Start-Transcript -Path $logFilePath -Append -IncludeInvocationHeader -Force
|
Start-Transcript -Path $logFilePath -Append -IncludeInvocationHeader -Force
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$scriptPath = $MyInvocation.MyCommand.Path
|
|
||||||
$scriptDir = Split-Path -Path $scriptPath -Parent
|
|
||||||
$scriptName = (Get-Item $scriptPath).Name
|
|
||||||
|
|
||||||
Write-Host "Script: $scriptName at $scriptPath"
|
Write-Host "Script: $scriptName at $scriptPath"
|
||||||
Write-Host "Repository directory: $scriptDir"
|
Write-Host "Repository directory: $scriptDir"
|
||||||
|
|||||||
Reference in New Issue
Block a user