thiagoralves / OpenPLC_v3

OpenPLC Runtime version 3
GNU General Public License v3.0
1.1k stars 442 forks source link

ArchLinux PKGBUILD #89

Closed tarnh closed 4 years ago

tarnh commented 5 years ago

Dear Thiago,

I have been working on a PKGBUILD for ArchLinux:

_pkgname=OpenPLC_v3
pkgname=openplc3
pkgver=1.0
pkgrel=1
pkgdesc="OpenPLC Runtime version 3"
arch=('x86_64' 'i686')
url="https://github.com/thiagoralves/OpenPLC_v3"
license=('MIT')
depends=('python-flask'
         'python-flask-login'
         'python-pyserial'
         'python-pymodbus'
         'matiec-hg'
         'opendnp3-git')
source=('git+'$url'.git'
        'openplc.service')
sha256sums=('SKIP'
            '7c06ff817390e240705740fcbf53a732106aa392ab12dafbaad4ad3dfdc0429e')

build() {
    echo "[ST OPTIMIZER]"
    cd $srcdir/$_pkgname/utils/st_optimizer_src
    g++ st_optimizer.cpp -o st_optimizer

    echo "[GLUE GENERATOR]"
    cd $srcdir/$_pkgname/utils/glue_generator_src
    g++ -std=c++11 glue_generator.cpp -o glue_generator
}

package(){
  mkdir -p $pkgdir/opt/openplc

  cp -r $srcdir/$_pkgname/webserver/* $pkgdir/opt/openplc

  cp $srcdir/$_pkgname/utils/st_optimizer_src/st_optimizer $pkgdir/opt/openplc
  cp $srcdir/$_pkgname/utils/glue_generator_src/glue_generator $pkgdir/opt/openplc/core

  echo "Optimizing ST program..."
  st_optimizer $pkgdir/opt/openplc/st_files/blank_program.st $pkgdir/opt/openplc/st_files/blank_program.st
  iec2c -I $pkgdir/opt/openplc/lib $pkgdir/opt/openplc/st_files/blank_program.st

  mkdir -p $pkgdir/usr/lib/systemd/system
  cp $srcdir/openplc.service $pkgdir/usr/lib/systemd/system/
}

The only missing: How should start_openplc.sh look like?

innir commented 4 years ago

You don't need a start_openplc.sh, a service file like this should do:

    [Unit]
    Description=OpenPLC Service
    After=network.target

    [Service]
    Type=simple
    Restart=always
    RestartSec=1
    User=openplc
    Group=openplc
    WorkingDirectory=/opt/openplc
    ExecStart=/usr/bin/python webserver.py

    [Install]
    WantedBy=multi-user.target

Make sure you change the path of WorkingDirectory and make sure that openplc can write to the directories needed.