1
+ @ echo off
2
+ rem This script updates the mod "Courseplay" for Farming Simulator 17
3
+ rem Copy this file to a folder of your choice and run in from time to time.
4
+ rem
5
+ rem Backups will be stored as ZIP files in a subfolder .\cpbackup
6
+ rem
7
+ rem =============================================================================
8
+ rem I M P O R T A N T N O T I C E
9
+ rem =============================================================================
10
+ rem Git for Windows and 7-Zip have to be installed and reside in your PATH!
11
+ rem Otherwise, adjust 'set gitexe=' and 'set zipexe' to your needs.
12
+ rem
13
+ rem For help with setting a program to your path, have a look @ http://www.computerhope.com/issues/ch000549.htm
14
+ rem
15
+ rem Have fun!
16
+ rem
17
+ rem (c) 2016 M. Busche, [email protected]
18
+ rem You could replace these with the full path to the files if they don´t reside in your PATH
19
+ set gitexe = " .\cmd\git.exe"
20
+ set zipexe = " .\App\7-Zip\7z.exe"
21
+
22
+ rem setlocal EnableDelayedExpansion
23
+ Setlocal
24
+ echo Courseplay Beta Updatescript
25
+ echo (c) 2016 elpatron@ mailbox.org
26
+ echo .
27
+ rem git.exe startable?
28
+ echo Checking for Git...
29
+ %gitexe% --version > NUL
30
+ if not errorlevel == 1 set gitok = " -1"
31
+ rem 7-Zip startable?
32
+ echo Checking for 7-Zip...
33
+ %zipexe% > NUL
34
+ if errorlevel == 9009 goto zipok=" -1"
35
+ if " %gitok% " == " -1" goto gitzipfehler
36
+ if " %zipok% " == " -1" goto gitzipfehler
37
+
38
+ echo Git and 7-Zip are ok, lets move on...
39
+ echo .
40
+
41
+ rem Write a VBS file for getting Courseplay version
42
+ > " %temp% \getversion.vbs" (
43
+ echo .Dim oXml: Set oXml = CreateObject^ (" Microsoft.XMLDOM" ^ )
44
+ echo .oXml.Load WScript.Arguments.Item^ (0^ )
45
+ echo .Dim oDoc: Set oDoc = oXml.documentElement
46
+ echo .
47
+ echo .For Each node In oDoc.childNodes
48
+ echo . If node.nodeName = " version" Then
49
+ echo . WScript.Echo node.text
50
+ echo . End If
51
+ echo .Next
52
+ echo .Set oXml = Nothing
53
+ )
54
+
55
+ rem Setting `Documents` folder
56
+ for /f " skip=2 tokens=2*" %%A in ('reg query " HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v " Personal" ') do set " UserDocs = %%B "
57
+ rem Setting Courseplay mod folder
58
+ set destination = %UserDocs% \my games\FarmingSimulator2017\mods\ZZZ_courseplay
59
+ echo Your Courseplay mod folder is: %destination%
60
+ rem Backup-Ordner
61
+ set " curpath = %cd% "
62
+ set backup = %curpath% \cpbackup
63
+ echo Your backup folder ist %backup%
64
+
65
+ rem Get current Courseplay version with vbs script
66
+ if exist " %destination% \moddesc.xml" (
67
+ del /q " %temp% \cpversion.txt" > NUL
68
+ cscript " %temp% \getversion.vbs" " %destination% \modDesc.xml" //Nologo > " %temp% \cpversion.txt"
69
+ set /p version = < " %temp% \cpversion.txt"
70
+ echo Your currently installed Version is: %version%
71
+ del " %temp% \cpversion.txt" > NUL
72
+ set freshinstall = " no"
73
+ ) else (
74
+ set freshinstall = " yes"
75
+ set version = " 0"
76
+ )
77
+
78
+ rem Delete old checkout
79
+ echo Deleting temporary folder...
80
+ rd /s/q .\courseplay 2 > NUL
81
+ rem Git clone
82
+ echo Cloning Courseplay repository from Github...
83
+ %gitexe% clone --depth=1 -q https://github.com/Courseplay/courseplay.git
84
+ rem Get new Courseplay version
85
+ cscript " %temp% \getversion.vbs" " .\courseplay\modDesc.xml" //Nologo > " %temp% \cpversion.txt"
86
+ set /p newversion = < " %temp% \cpversion.txt"
87
+ echo Version from Github: %newversion%
88
+ del " %temp% \cpversion.txt" > NUL
89
+
90
+ rem Do we have an update?
91
+ if " %newversion% " == " %version% " (
92
+ echo No update found, exiting.
93
+ rd /s/q .\courseplay 2 > NUL
94
+ goto ende
95
+ ) else (
96
+ echo We have found an update.
97
+ )
98
+
99
+ rem Backup current version
100
+ if %freshinstall% == " no" (
101
+ echo Creating a backup of your current Courseplay...
102
+ mkdir %backup% 2 > NUL
103
+ %zipexe% a -r " %backup% \courseplay_backup-%version% .zip" " %destination% \*" > NUL 2 >& 1
104
+ echo If you consider any problems, check your backup file: " %backup% \courseplay_backup-%version% .zip"
105
+ ) else (
106
+ echo No former version found - this seems to be a fresh install. Creating new mod directory for Courseplay...
107
+ md " %destination% " > NUL
108
+ )
109
+
110
+ rem Copy clone to mod folder
111
+ echo Copying the update to your mod folder...
112
+ xcopy /S /E /H /Y /C /Q " .\courseplay\*.*" " %destination% \" > NUL
113
+ rem Couseplay Git checkout wieder löschen
114
+ echo Deleting temporary folder...
115
+ rd /s/q .\courseplay 2 > NUL
116
+ echo Sucessfully updated from %version% to %newversion% .
117
+
118
+ goto ende
119
+
120
+ :gitzipfehler
121
+ if " %gitok% " == " -1" (
122
+ echo Git for Windows has to be installed and reside in PATH!
123
+ echo Download: https://git-scm.com/download/win
124
+ )
125
+ if " %zipok% " == " -1" (
126
+ echo 7-Zip has to be installed and reside in PATH!
127
+ echo Download: http://www.7-zip.org/download.html
128
+ )
129
+ goto ende
130
+
131
+ :ende
132
+ del " %temp% \getversion.vbs" > NUL
133
+ echo .
134
+ echo Thanks for using me.
0 commit comments