lock file feature

This commit is contained in:
Thijs Stobbelaar 2023-09-30 10:07:39 +02:00
parent 6dffd64ddb
commit f505eb9268
5 changed files with 50 additions and 6 deletions

26
includes/ps1/lockfile.ps1 Normal file
View file

@ -0,0 +1,26 @@
function new-lock {
if ($env:temp) {
$lockFile = Join-Path -Path $env:temp -ChildPath 'lockfile_pubg.lock'
}
else {
$lockFile = "/tmp/lockfile_pubg.lock"
}
if (Test-Path -Path $lockFile) {
Write-Host "Job is already running."
Exit
}
New-Item -ItemType File -Path $lockFile | Out-Null
}
function remove-lock {
if ($env:temp) {
$lockFile = Join-Path -Path $env:temp -ChildPath 'lockfile_pubg.lock'
}
else {
$lockFile = "/tmp/lockfile_pubg.lock"
}
Remove-Item -Path $lockFile
}