Diff of /codesys-xinetd/install.sh [000000] .. [16685e]  Maximize  Restore

Switch to unified view

a b/codesys-xinetd/install.sh
1
#!/bin/bash
2
################################################################################
3
# Copyright 2017 Ingo Hornberger <ingo_@gmx.net>
4
#
5
# This software is licensed under the MIT License
6
#
7
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
8
# software and associated documentation files (the "Software"), to deal in the Software
9
# without restriction, including without limitation the rights to use, copy, modify,
10
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
11
# permit persons to whom the Software is furnished to do so, subject to the following
12
# conditions:
13
#
14
# The above copyright notice and this permission notice shall be included in all copies
15
# or substantial portions of the Software.
16
#
17
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22
# OR OTHER DEALINGS IN THE SOFTWARE.
23
#
24
################################################################################
25
26
CDS_LINK="https://store.codesys.com/ftp_download/3S/CODESYS/300000/3.5.14.0/CODESYS%203.5.14.0.exe"
27
TRICKS_LINK="https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks"
28
ADDITIONAL_PACKAGES=https://forge.codesys.com/svn/tol,cforge,code/trunk/cforge.package
29
export WINEPREFIX=~/.wine.cds
30
export WINEARCH=win32
31
32
# kill current and subprocesses on exit
33
trap "kill 0" EXIT
34
35
# this should be running in the background to close rundll32 dialogs
36
function handle_rundll
37
{
38
    while true; do
39
    #
40
    # rundll32 error
41
    #
42
    while ! xdotool search --name 'rundll32'; do
43
        sleep 1
44
    done
45
    echo "rundll32 error found"
46
    (
47
        # next
48
        sleep 2
49
        echo "-> sending key sequence"
50
        xdotool key "Tab"; xdotool key "space";
51
    )
52
    sleep 1
53
    done
54
55
}
56
57
function handle_codemeter
58
{
59
    while true; do
60
    #
61
    # CodeMeter setup
62
    #
63
    while ! xdotool search --name 'codemeter'; do
64
        sleep 1
65
    done
66
    echo "codemeter found"
67
    (
68
        # next
69
        sleep 5
70
        echo "-> sending key sequence"
71
        xdotool key "space"; 
72
        # check license
73
        sleep 1
74
        xdotool key "space";
75
        # next
76
        sleep 1
77
        xdotool key "Tab"; xdotool key "Tab"; xdotool key "space";
78
        # next
79
        sleep 1
80
        xdotool key "Tab"; xdotool key "Tab"; xdotool key "Tab"; xdotool key "Tab"; xdotool key "space";
81
        # next
82
        sleep 1
83
        xdotool key "Tab"; xdotool key "Tab"; xdotool key "Tab"; xdotool key "Tab"; xdotool key "Tab"; xdotool key "space";
84
        # install
85
        sleep 1
86
        xdotool key "space";
87
        # finish
88
        sleep 5
89
        xdotool key "space";
90
    )
91
    sleep 1
92
    done
93
94
}
95
96
function kill_systray
97
{
98
    while true; do
99
    while ! pgrep -f SysTray.exe; do
100
        sleep 1
101
    done
102
    echo "SysTrays running - kill them..."
103
    pgrep -f SysTray.exe | xargs -n 1 kill
104
    sleep 1
105
    done
106
}
107
108
function get
109
{
110
    wget --no-verbose --output-document=setup.exe -c "${CDS_LINK}"
111
    wget --no-verbose --output-document=winetricks -c "${TRICKS_LINK}" 
112
    chmod 755 winetricks 
113
    (
114
    mkdir -p Packages
115
    cd Packages
116
    for i in ${ADDITIONAL_PACKAGES}; do
117
        wget --no-verbose -c "${i}" 
118
    done
119
    )
120
}
121
122
function prereq
123
{
124
    echo -n "Checking prerequisite 'wine-development'"
125
    if which wine-development; then
126
    echo "=> OK"
127
    else
128
    echo "ERROR: Please install wine32-development and wine64-development"
129
    exit 1
130
    fi
131
}
132
133
function switch_to_win7
134
{
135
    # call wine to create new WINEPREFIX
136
    wine-development dir
137
    sleep 5
138
    # patch win version
139
    cp system.reg ${WINEPREFIX}
140
}
141
142
function winetricks
143
{
144
    ./winetricks -q vcrun2005 vcrun2008 vcrun2013 vcrun2015 dotnet46 &> /dev/zero
145
    wineserver-development -w
146
    ./winetricks nocrashdialog
147
    wineserver-development -w
148
}
149
150
function install
151
{
152
    wine-development setup.exe /v/qn /s /v'INSTALLDIR=C:\\CODESYS' /v"ADDLOCAL=Basic,CODESYS,cforge Tool" /v"CDS_INSTALL_SERVICES=0"
153
    wineserver-development -w
154
}
155
156
function post_install
157
{
158
    wine-development reg add "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\S-1-5-21-0-0-0-1000"
159
    wineserver-development -w
160
}
161
162
no_check="y"
163
no_dl="y"
164
no_winetricks="y"
165
no_install="y"
166
no_postinstall="y"
167
no_xvfb="y"
168
case ${1} in
169
    --winetricks)
170
    no_winetricks=""
171
    ;;
172
    --install)
173
    no_install=""
174
    ;;
175
    --postinstall)
176
    no_postinstall=""
177
    ;;
178
    --xvfb)
179
    no_check=""
180
    no_dl=""
181
    no_winetricks=""
182
    no_install=""
183
    no_postinstall=""
184
    no_xvfb=""
185
    ;;
186
    *)
187
    no_check=""
188
    no_dl=""
189
    no_winetricks=""
190
    no_install=""
191
    no_postinstall=""
192
    ;;
193
esac
194
195
if [ -z ${no_xvfb} ]; then
196
    echo "=== Start XVFB ==="
197
    export DISPLAY=:98
198
    Xvfb :98 &
199
    sleep 3
200
    jwm &
201
    
202
    # install handlers only when automating the installation
203
    # with Xvfb and xdotool
204
    (handle_rundll)&
205
    (handle_codemeter)&
206
    (kill_systray)&
207
fi
208
if [ -z ${no_check} ]; then
209
    echo "=== Checking Prerequisites ==="
210
    prereq
211
fi
212
if [ -z ${no_dl} ]; then
213
    echo "=== Downloading packets ==="
214
    get
215
fi
216
if [ -z ${no_winetricks} ]; then
217
    echo "=== Installing Prerequisites w/ winetricks ==="
218
    winetricks
219
fi
220
if [ -z ${no_install} ]; then
221
    echo "=== Installing CODESYS ==="
222
    install
223
fi
224
if [ -z ${no_postinstall} ]; then
225
    echo "=== Postinstall Fixups ==="
226
    post_install
227
    if [ -z ${no_install} ]; then
228
    echo "=== Installing CODESYS again ==="
229
    echo "after one complete run + post install, also all *.exe are copied ;)"
230
    install
231
    fi
232
fi
233
if [ -z ${no_xvfb} ]; then
234
    echo "=== Kill XVFB ==="
235
    killall -9 Xvfb
236
fi
237
238
exit