Working systemd instance units.
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 28 Apr 2020 13:27:18 +0000 (15:27 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 28 Apr 2020 13:27:18 +0000 (15:27 +0200)
dist/argeo-node/base/share/argeo/selinux/README.txt [new file with mode: 0644]
dist/argeo-node/base/share/argeo/selinux/argeoctl.pp [new file with mode: 0644]
dist/argeo-node/base/share/argeo/selinux/argeoctl.te [new file with mode: 0644]
dist/argeo-node/rpm/usr/lib/systemd/system/argeo@.service [new file with mode: 0644]
dist/argeo-node/rpm/usr/sbin/argeoctl

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 (file)
index 0000000..de246fa
--- /dev/null
@@ -0,0 +1,2 @@
+# In order to use the argeo@<iinstance> 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 (file)
index 0000000..2dd583e
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 (file)
index 0000000..5c8007b
--- /dev/null
@@ -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 (file)
index 0000000..d76f742
--- /dev/null
@@ -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
index bcf597bccfebfe6a23a9201040f371b918441fe3..727ef27f4fbeac9d763062c19c8c2394e6b9cec7 100755 (executable)
@@ -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