1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | #!/bin/bash WINE=wine-development if [ -d /usr/local/share/codesys ]; then BASEPATH=/usr/local/share/codesys else BASEPATH=$(pwd)/scripts fi # get first CODESYS profile and start the script with it profile=$(basename "$(ls -1 ~/.wine.cds/drive_c/CODESYS/CODESYS/Profiles/*.profile | head -n 1 | sed 's,.profile,,')") libdoc=$(ls -1 ${HOME}/.wine.cds/drive_c/CODESYS/CODESYS/DocScripting/*/libdoc.exe) # start ide? if [ "${1}" == "ide" ]; then export WINEPREFIX=~/.wine.cds export WINEDEBUG=-all ${WINE} ~/.wine.cds/drive_c/CODESYS/CODESYS/Common/CODESYS.exe --culture=en --profile="'"${profile}"'" --runscript="z:${BASEPATH}/noop.py" --noUI ${WINE} ~/.wine.cds/drive_c/CODESYS/CODESYS/Common/CODESYS.exe --culture=en --profile="'"${profile}"'" elif [ "${1}" == "export-libdoc" ]; then export WINEPREFIX=~/.wine.cds export WINEDEBUG=-all export LIBDOC_CODESYS="c:/CODESYS/CODESYS/Common/CODESYS.exe --profile=\"${profile}\"" for i in $(find -iname \*.library); do ${WINE} ${libdoc} make ${i} html libbase=$(basename $i .library) libdir=$(dirname $i) if [ -d ${libdir}/${libbase}-html ]; then mkdir -p .drone-artifacts/${libdir} zip -r .drone-artifacts/${libdir}/${libbase}.zip ${libdir}/${libbase}-html fi done elif [ "${1}" == "export-libdoc-pdf" ]; then export WINEPREFIX=~/.wine.cds export WINEDEBUG=-all export LIBDOC_CODESYS="c:/CODESYS/CODESYS/Common/CODESYS.exe --profile=\"${profile}\"" for i in $(find -iname \*.library); do ${WINE} ${libdoc} make ${i} chm libbase=$(basename $i .library) libdir=$(dirname $i) if [ -f ${libdir}/${libbase}.pdf ]; then mkdir -p .drone-artifacts/${libdir} cp ${libdir}/${libbase}.pdf .drone-artifacts/${libdir}/${libbase}.pdf fi done else # check if file exists, before we call CODESYS with it if [ ! -f ${BASEPATH}/${1}.py ]; then echo "error: script '${BASEPATH}/${1}.py' not found." exit -1 fi export DISPLAY=:91 Xvfb :91 &> /dev/zero & sleep 1 export WINEPREFIX=~/.wine.cds ${WINE} ~/.wine.cds/drive_c/CODESYS/CODESYS/Common/CODESYS.exe --culture=en --profile="'"${profile}"'" --runscript="z:${BASEPATH}/noop.py" --noUI 2> /dev/zero # remove output log [ -f .codesys.output.txt ] && rm -f .codesys.output.txt # check if script runs with or without UI if grep '# CODESYS with UI' "${BASEPATH}/${1}.py" 2>&1 > /dev/zero; then ${WINE} ~/.wine.cds/drive_c/CODESYS/CODESYS/Common/CODESYS.exe --culture=en --profile="'"${profile}"'" --runscript="z:${BASEPATH}/${1}.py" 2> /dev/zero else ${WINE} ~/.wine.cds/drive_c/CODESYS/CODESYS/Common/CODESYS.exe --culture=en --profile="'"${profile}"'" --runscript="z:${BASEPATH}/${1}.py" --noUI 2> /dev/zero fi result=$? # flush output log [ -f .codesys.output.txt ] && cat .codesys.output.txt sleep 1 killall Xvfb rm -rf /tmp/.X91* if [ "${result}" == "0" ]; then true else false fi fi |