From: Mathieu Baudier Date: Tue, 28 Apr 2020 13:27:18 +0000 (+0200) Subject: Working systemd instance units. X-Git-Tag: argeo-commons-2.1.89~144 X-Git-Url: https://git.argeo.org/?p=lgpl%2Fargeo-commons.git;a=commitdiff_plain;h=96c1c243ff00e3e2ff862e23662ad130dd405272 Working systemd instance units. --- diff --git a/dist/argeo-node/base/share/argeo/selinux/README.txt b/dist/argeo-node/base/share/argeo/selinux/README.txt new file mode 100644 index 000000000..de246fa23 --- /dev/null +++ b/dist/argeo-node/base/share/argeo/selinux/README.txt @@ -0,0 +1,2 @@ +# In order to use the argeo@ systemd services, first execute: +semodule -i /usr/share/argeo/selinux/argeoctl.pp \ No newline at end of file diff --git a/dist/argeo-node/base/share/argeo/selinux/argeoctl.pp b/dist/argeo-node/base/share/argeo/selinux/argeoctl.pp new file mode 100644 index 000000000..2dd583ec2 Binary files /dev/null and b/dist/argeo-node/base/share/argeo/selinux/argeoctl.pp differ diff --git a/dist/argeo-node/base/share/argeo/selinux/argeoctl.te b/dist/argeo-node/base/share/argeo/selinux/argeoctl.te new file mode 100644 index 000000000..5c8007b40 --- /dev/null +++ b/dist/argeo-node/base/share/argeo/selinux/argeoctl.te @@ -0,0 +1,11 @@ + +module argeoctl 1.0; + +require { + type var_lib_t; + type init_t; + class lnk_file { getattr read }; +} + +#============= init_t ============== +allow init_t var_lib_t:lnk_file { getattr read }; diff --git a/dist/argeo-node/rpm/usr/lib/systemd/system/argeo@.service b/dist/argeo-node/rpm/usr/lib/systemd/system/argeo@.service new file mode 100644 index 000000000..d76f7424a --- /dev/null +++ b/dist/argeo-node/rpm/usr/lib/systemd/system/argeo@.service @@ -0,0 +1,18 @@ +[Unit] +Description=Argeo Node %I +After=network.target +Wants=postgresql.service + +[Service] +Type=simple +PIDFile=/var/run/argeo/%i.pid +ExecStart=/usr/sbin/argeoctl start %I +ExecReload=/usr/sbin/argeoctl reload %I +SuccessExitStatus=143 +DynamicUser=true +StateDirectory=argeo.d/%I +LogsDirectory=argeo.d/%I +ConfigurationDirectory=argeo.d/%I + +[Install] +WantedBy=multi-user.target diff --git a/dist/argeo-node/rpm/usr/sbin/argeoctl b/dist/argeo-node/rpm/usr/sbin/argeoctl index bcf597bcc..727ef27f4 100755 --- a/dist/argeo-node/rpm/usr/sbin/argeoctl +++ b/dist/argeo-node/rpm/usr/sbin/argeoctl @@ -1,15 +1,44 @@ #!/bin/sh APP=argeo +if [ -z "$2" ]; then +# Default node +CONF_DIR=/etc/$APP +EXEC_DIR=/var/lib/$APP +else +# Instance +INSTANCE=$2 + if [ -z "$STATE_DIRECTORY" ]; then + INSTANCE_DIR=/var/lib/$APP.d/$INSTANCE + else + # systemd StateDirectory= + INSTANCE_DIR=$STATE_DIRECTORY + fi + if [ -z "$CONFIGURATION_DIRECTORY" ]; then + CONF_DIR=/etc/$APP.d/$INSTANCE + else + # systemd ConfigurationDirectory= + CONF_DIR=$CONFIGURATION_DIRECTORY + fi + +EXEC_DIR=$INSTANCE_DIR + + if [ ! -f $CONF_DIR/$APP.ini ]; then + cp /etc/$APP/$APP.ini $CONF_DIR + fi + if [ ! -f $CONF_DIR/log4j.properties ]; then + cp /etc/$APP/log4j.properties $CONF_DIR + fi +fi + JVM=java # Directories and files -CONF_DIR=/etc/$APP -CONF_DIRS=/etc/$APP/conf.d + BASE_POLICY_ALL=/usr/share/$APP/all.policy BASE_CONFIG_INI=/usr/share/$APP/config.ini -EXEC_DIR=/var/lib/$APP +CONF_DIRS=$CONF_DIR/conf.d DATA_DIR=$EXEC_DIR/data CONF_RW=$EXEC_DIR/state CONFIG_INI=$CONF_RW/config.ini