Skip to content

Instantly share code, notes, and snippets.

@antoinell
Created January 4, 2019 18:47
Show Gist options
  • Save antoinell/e3d08b667e6d088892d1cc5823bb042a to your computer and use it in GitHub Desktop.
Save antoinell/e3d08b667e6d088892d1cc5823bb042a to your computer and use it in GitHub Desktop.
patch for artifactoryManage.sh / artifactory.service
--- distribution/standalone/src/main/install/bin/artifactoryManage.sh.orig 2019-01-04 13:44:06.706292535 -0500
+++ distribution/standalone/src/main/install/bin/artifactoryManage.sh 2019-01-04 13:17:50.454061203 -0500
@@ -1,5 +1,4 @@
#!/bin/bash
-#
# Init script for Artifactory service (currently systemd)
#
# chkconfig: 345 86 14
@@ -75,17 +74,24 @@
fi
}
+artexecute() {
+ if [ ! ${USER} == ${ARTIFACTORY_USER} ]; then
+ su -s "/bin/sh" ${ARTIFACTORY_USER} -c "export JAVA_HOME=${JAVA_HOME}; $@"
+ else
+ eval "$@"
+ fi
+}
startReplicator() {
if runReplicator; then
chmod +x ${replicatorScript}
- su -s "/bin/sh" ${ARTIFACTORY_USER} -c "${replicatorScript} start"
+ artexecute ${replicatorScript} start
fi
}
stopReplicator() {
if runReplicator; then
chmod +x ${replicatorScript}
- su -s "/bin/sh" ${ARTIFACTORY_USER} -c "${replicatorScript} stop"
+ artexecute ${replicatorScript} stop
fi
}
@@ -117,7 +123,7 @@
artifactory hard nproc $minNbProcess
to your /etc/security/limits.conf file."
fi
- su -s "/bin/sh" ${ARTIFACTORY_USER} -c "export JAVA_HOME='$JAVA_HOME'; $TOMCAT_HOME/bin/startup.sh"
+ artexecute "$TOMCAT_HOME/bin/startup.sh"
RETVAL=$?
if [ ${RETVAL} -ne 0 ]; then
errorArtHome "Artifactory Tomcat server did not start. Please check the logs"
@@ -148,7 +154,7 @@
else
echo "Stopping Artifactory Tomcat..."
if [ ${SHUTDOWN_PORT} -ne 0 ]; then
- su -s "/bin/sh" ${ARTIFACTORY_USER} -c "export JAVA_HOME='$JAVA_HOME'; $TOMCAT_HOME/bin/shutdown.sh"
+ artexecute "$TOMCAT_HOME/bin/shutdown.sh"
RETVAL=$?
else
RETVAL=1
--- distribution/standalone/src/main/install/misc/service/artifactory.service.orig 2019-01-04 13:44:22.557649526 -0500
+++ distribution/standalone/src/main/install/misc/service/artifactory.service 2019-01-04 13:22:41.766300433 -0500
@@ -3,6 +3,8 @@
After=network.target
[Service]
+User=artifactory
+Group=artifactory
Type=forking
GuessMainPID=yes
Restart=always
@@ -12,5 +14,4 @@
ExecStop=/opt/jfrog/artifactory/bin/artifactoryManage.sh stop
[Install]
-WantedBy=multi-user.target
-Alias=artifactory.service
\ No newline at end of file
+WantedBy=multi-user.target
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment