class aes::aes_sw {

  package {
    [
      'a2ps',
      'cronie',
      'java-11-openjdk-devel',
    ]:
      ensure  => installed,
  }

  user { "examadm" :
    ensure => present,
    managehome => false,
    membership => inclusive,
    system => true,
    shell => '/sbin/nologin',
  }

  file { "/etc/systemd/system/aes_login.service":
    ensure => present,
    owner  => root,
    group  => root,
    mode => '0644',
    content => @(LOGINSERVICE)
    [Unit]
    Description=AES Login server
    After=network.target
    
    [Service]
    Type=simple
    User=examadm
    WorkingDirectory=/home/examadm/Version-3.1/exam
    ExecStart=/usr/bin/python3 /home/examadm/Version-3.1/pub/bin/examiner/find_pnr_and_otp_from_liuid.py

    [Install]
    WantedBy=multi-user.target
    | LOGINSERVICE
  }

  # todo: logrotate
  service { "aes_login" : 
    ensure => "running",
  }

  file { "/etc/systemd/system/aes_ms.service":
    ensure => present,
    owner  => root,
    group  => root,
    mode => '0644',
    content => @(MSSERVICE)
    [Unit]
    Description=AES Exam server
    After=network.target
    
    [Service]
    Type=simple
    User=examadm
    WorkingDirectory=/home/examadm/Version-3.1
    ExecStart=/usr/bin/java -Xmx512M -jar /home/examadm/Version-3.1/pub/bin/examiner/ms.jar /home/examadm/Version-3.1

    [Install]
    WantedBy=multi-user.target
    | MSSERVICE
  }

  file { "/etc/cron.daily/aes_ms":
    ensure => present,
    owner  => root,
    group  => root,
    mode => '0700',
    content => @(MSCRON)
    #!/bin/sh
    /usr/bin/systemctl restart aes_ms
    | MSCRON
  }

  # todo: logrotate
  service { "aes_ms" : 
    ensure => "running",
  }

}