Skip to content

Commit

Permalink
Merge pull request #61 from stdweird/unitfile
Browse files Browse the repository at this point in the history
add unitfile for ncm-cdispd, remove initscripts/chkconfig support
  • Loading branch information
jrha authored Sep 11, 2024
2 parents 731bd12 + dd69b92 commit 50f979c
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 112 deletions.
106 changes: 72 additions & 34 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
<requires>
<require>crontabs</require>
<require>logrotate</require>
<require>chkconfig</require>
</requires>
<mappings>
<mapping>
Expand Down Expand Up @@ -106,11 +105,21 @@
<mapping>
<sources>
<source>
<location>${project.build.directory}/daemon</location>
<location>${project.build.directory}/systemd/${project.artifactId}.service</location>
</source>
</sources>
<directory>/etc/init.d</directory>
<filemode>755</filemode>
<directory>/usr/lib/systemd/system</directory>
<filemode>644</filemode>
<directoryIncluded>false</directoryIncluded>
</mapping>
<mapping>
<sources>
<source>
<location>${project.build.directory}/systemd/80-${project.artifactId}.preset</location>
</source>
</sources>
<directory>/usr/lib/systemd/system-preset</directory>
<filemode>644</filemode>
<directoryIncluded>false</directoryIncluded>
</mapping>
<mapping>
Expand Down Expand Up @@ -168,23 +177,51 @@
</sources>
</mapping>
</mappings>
<preinstallScriptlet>
<script><![CDATA[
if [ "$1" -eq 2 ]; then # upgrade
if [ -x /sbin/chkconfig -a -x /sbin/service -a -h /etc/rc3.d/S30${project.artifactId} ]
then
# Upgrade from the initscript version. The daemon needs to be
# stopped, otherwise, systemd gets confused
/sbin/service ${project.artifactId} stop > /dev/null 2>&1 || :
/sbin/chkconfig --del ${project.artifactId}
fi
fi
]]></script>
</preinstallScriptlet>
<postinstallScriptlet>
<script>
/sbin/chkconfig --add ${project.artifactId}
<script><![CDATA[
if [ "$1" -eq 1 ]; then # first install
/bin/systemctl preset ${project.artifactId}.service > /dev/null 2>&1 || :
elif [ "$1" -eq 2 ]; then # upgrade
# Ensure that profile has been updated to the last format, if any change, to prevent potential ncm-cdispd crash at restart
ccm-fetch --force
/sbin/service ${project.artifactId} restart
</script>
/bin/systemctl daemon-reload > /dev/null 2>&1 || :
# Calling 'preset' here is arguably wrong, but not doing it could leave
# the daemon disabled when upgrading from the init script version
/bin/systemctl preset ${project.artifactId}.service > /dev/null 2>&1 || :
/bin/systemctl restart ${project.artifactId} > /dev/null 2>&1 || :
fi
]]></script>
</postinstallScriptlet>
<preremoveScriptlet>
<script>
if [ "$1" -eq 0 ] # Uninstall rather than upgrade
then
# Do not stop the service as the uninstall may happen from within the service...
/sbin/chkconfig --del ${project.artifactId}
fi
</script>
<script><![CDATA[
if [ "$1" -eq 0 ]; then # Uninstall rather than upgrade
# Do not stop the service as the uninstall may happen from within the service...
/bin/systemctl --no-reload disable ${project.artifactId}.service > /dev/null 2>&1 || :
fi
]]></script>
</preremoveScriptlet>
<postremoveScriptlet>
<script><![CDATA[
if [ -x /bin/systemctl ]; then
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
]]></script>
</postremoveScriptlet>
</configuration>
</plugin>
</plugins>
Expand All @@ -194,25 +231,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>filter-daemon</id>
<phase>process-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/daemon</outputDirectory>
<resources>
<resource>
<directory>src/main/daemon</directory>
<filtering>true</filtering>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>filter-script-sources</id>
<phase>process-sources</phase>
Expand Down Expand Up @@ -350,6 +368,26 @@
</resources>
</configuration>
</execution>
<execution>
<id>copy-systemd-files</id>
<phase>process-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/systemd</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/systemd</directory>
<includes>
<include>${project.artifactId}.service</include>
<include>80-${project.artifactId}.preset</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand Down
78 changes: 0 additions & 78 deletions src/main/daemon/ncm-cdispd

This file was deleted.

1 change: 1 addition & 0 deletions src/main/resources/systemd/80-ncm-cdispd.preset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable ncm-cdispd.service
14 changes: 14 additions & 0 deletions src/main/resources/systemd/ncm-cdispd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Configuration Dispatch Daemon waits for new incoming configuration profiles
After=network.target
After=network-online.target
Before=shutdown.target

[Service]
Type=simple
ExecStart=/usr/sbin/ncm-cdispd
KillMode=process
PIDFile=/run/ncm-cdispd.pid

[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions src/test/perl/00-tqu.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ modules=Application,Utils,Main
[doc]
poddirs=target/lib/perl,target/sbin
panpaths=NOPAN
[tt]
basepath=src/main/notresourcessonotttests
EOF
}
use Test::Quattor::Unittest;

0 comments on commit 50f979c

Please sign in to comment.