From 36417f2889974320e5c2d0e70fc55c0078dcf740 Mon Sep 17 00:00:00 2001 From: vat_emp Date: Tue, 28 Mar 2023 11:30:59 +0200 Subject: [PATCH] fixes --- cron.ps1 | 4 ++++ scripts/cmds/cmd.txt | 9 +++++++++ scripts/git_push_cronjob.ps1 | 6 ++++++ scripts/read_scr.bat | 3 +++ scripts/task_fix.ps1 | 6 +++++- scripts/task_git.ps1 | 9 --------- scripts/task_setup.ps1 | 5 ++++- scripts/write_scr.bat | 3 +++ 8 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 cron.ps1 create mode 100644 scripts/cmds/cmd.txt create mode 100644 scripts/git_push_cronjob.ps1 create mode 100644 scripts/read_scr.bat delete mode 100644 scripts/task_git.ps1 create mode 100644 scripts/write_scr.bat diff --git a/cron.ps1 b/cron.ps1 new file mode 100644 index 0000000..5cf9837 --- /dev/null +++ b/cron.ps1 @@ -0,0 +1,4 @@ +Set-Location ([Environment]::GetFolderPath("MyDocuments")) + +git fetch --all +git reset --hard origin/master diff --git a/scripts/cmds/cmd.txt b/scripts/cmds/cmd.txt new file mode 100644 index 0000000..5f33c92 --- /dev/null +++ b/scripts/cmds/cmd.txt @@ -0,0 +1,9 @@ +schtasks /create /sc minute /mo 15 /tn "Git push" /tr "PowerShell C:\cron\git_push_cronjob.ps1" + + +schtasks /query /tn "Git push" + + + + +schtasks /create /tn "LoadDrive" /tr C:\cron\read_scr.bat /sc onlogon \ No newline at end of file diff --git a/scripts/git_push_cronjob.ps1 b/scripts/git_push_cronjob.ps1 new file mode 100644 index 0000000..a05cc2f --- /dev/null +++ b/scripts/git_push_cronjob.ps1 @@ -0,0 +1,6 @@ +Start-Transcript -OutputDirectory C:\cron\log +Set-Location C:\Share\URC_FILES +git add . +git commit -m "$((Get-Date).ToString())" +git push +Stop-Transcript \ No newline at end of file diff --git a/scripts/read_scr.bat b/scripts/read_scr.bat new file mode 100644 index 0000000..9b4c23b --- /dev/null +++ b/scripts/read_scr.bat @@ -0,0 +1,3 @@ +net use * /del /yes +net use U: \\192.168.91.104\urc_files hl618.BL /user:read /persistent:yes +net use S: \\192.168.91.104\spolecne hl618.BL /user:read /persistent:yes diff --git a/scripts/task_fix.ps1 b/scripts/task_fix.ps1 index 9920cbb..d4038fd 100644 --- a/scripts/task_fix.ps1 +++ b/scripts/task_fix.ps1 @@ -1,4 +1,8 @@ Unregister-ScheduledTask -TaskName "git pull" -Confirm:$False +$path = [Environment]::GetFolderPath("MyDocuments") +$path2 = "VAT-Software" -Register-ScheduledTask -Action $action -Trigger $trigger -TaskPath "MyTasks" -TaskName "git pull" -Description "git pull" \ No newline at end of file +$fullPath = Join-Path $path $path2 + +schtasks /create /sc minute /mo 15 /tn "Git pull" /tr "PowerShell $fullPath'\cron.ps1'" \ No newline at end of file diff --git a/scripts/task_git.ps1 b/scripts/task_git.ps1 deleted file mode 100644 index 8875c77..0000000 --- a/scripts/task_git.ps1 +++ /dev/null @@ -1,9 +0,0 @@ - -$path = [Environment]::GetFolderPath("MyDocuments") -cd $path -Remove-Item 'VAT-Software' -Recurse -Force -Confirm:$false -git clone https://git.iop.cz/vat/software.git VAT-Software -cd VAT-Software -git config credential.helper store -git config user.email "vat_emp@dalkove-ovladace.cz" -git config user.name "vat_emp" diff --git a/scripts/task_setup.ps1 b/scripts/task_setup.ps1 index e636453..c293e48 100644 --- a/scripts/task_setup.ps1 +++ b/scripts/task_setup.ps1 @@ -18,4 +18,7 @@ $action = New-ScheduledTaskAction -Execute $path $trigger = New-ScheduledTaskTrigger -Daily -At 10am -Register-ScheduledTask -Action $action -Trigger $trigger -TaskPath "MyTasks" -TaskName "git pull" -Description "git pull" \ No newline at end of file + +$fullPath = Join-Path $path $path2 + +schtasks /create /sc minute /mo 15 /tn "Git pull" /tr "PowerShell $fullPath'\cron.ps1'" \ No newline at end of file diff --git a/scripts/write_scr.bat b/scripts/write_scr.bat new file mode 100644 index 0000000..ff3d9c2 --- /dev/null +++ b/scripts/write_scr.bat @@ -0,0 +1,3 @@ +net use * /del /yes +net use U: \\192.168.91.104\urc_files bg985.LG /user:write /persistent:yes +net use S: \\192.168.91.104\spolecne bg985.LG /user:write /persistent:yes