diff --git a/rpm/build/SOURCES/jenkins.init.in b/rpm/build/SOURCES/jenkins.init.in deleted file mode 100644 index 7efee39f..00000000 --- a/rpm/build/SOURCES/jenkins.init.in +++ /dev/null @@ -1,219 +0,0 @@ -#!/bin/sh -# -# RedHat system statup script for Jenkins -# Based on SUSE system statup script for Jenkins -# Copyright (C) 2007 Pascal Bleser -# -# This library is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or (at -# your option) any later version. -# -# This library is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. -# -############################################################################### -# -# chkconfig: 35 99 01 -# description: @@SUMMARY@@ -# -############################################################################### -### BEGIN INIT INFO -# Provides: @@ARTIFACTNAME@@ -# Required-Start: $local_fs $remote_fs $network $time $named -# Should-Start: $time sendmail -# Required-Stop: $local_fs $remote_fs $network $time $named -# Should-Stop: $time sendmail -# Default-Start: 3 5 -# Default-Stop: 0 1 2 6 -# Short-Description: @@SUMMARY@@ -# Description: @@SUMMARY@@ -### END INIT INFO - -# Check for missing binaries (stale symlinks should not happen) -JENKINS_WAR="~~WAR~~" -test -r "$JENKINS_WAR" || { - echo "$JENKINS_WAR not installed" - if [ "$1" = "stop" ]; then - exit 0 - else - exit 5 - fi -} - -# Check for existence of needed config file and read it -JENKINS_CONFIG=/etc/sysconfig/@@ARTIFACTNAME@@ -test -e "$JENKINS_CONFIG" || { - echo "$JENKINS_CONFIG not existing" - if [ "$1" = "stop" ]; then - exit 0 - else - exit 6 - fi -} -test -r "$JENKINS_CONFIG" || { - echo "$JENKINS_CONFIG not readable. Perhaps you forgot 'sudo'?" - if [ "$1" = "stop" ]; then - exit 0 - else - exit 6 - fi -} - -JENKINS_PID_FILE="/var/run/@@ARTIFACTNAME@@.pid" -JENKINS_LOCKFILE="/var/lock/subsys/@@ARTIFACTNAME@@" - -# Source function library. -. /etc/init.d/functions - -# Read config -[ -f "$JENKINS_CONFIG" ] && . "$JENKINS_CONFIG" - -# Set up environment accordingly to the configuration settings -[ -n "$JENKINS_HOME" ] || { - echo "JENKINS_HOME not configured in $JENKINS_CONFIG" - if [ "$1" = "stop" ]; then - exit 0 - else - exit 6 - fi -} -[ -d "$JENKINS_HOME" ] || { - echo "JENKINS_HOME directory does not exist: $JENKINS_HOME" - if [ "$1" = "stop" ]; then - exit 0 - else - exit 1 - fi -} - -# Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins. -# see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html -candidates=" -/etc/alternatives/java -/usr/lib/jvm/java-1.8.0/bin/java -/usr/lib/jvm/jre-1.8.0/bin/java -/usr/lib/jvm/java-11.0/bin/java -/usr/lib/jvm/jre-11.0/bin/java -/usr/lib/jvm/java-11-openjdk-amd64 -/usr/bin/java -" -for candidate in $candidates; do - [ -x "$JENKINS_JAVA_CMD" ] && break - JENKINS_JAVA_CMD="$candidate" -done - -PARAMS="--logfile=/var/log/@@ARTIFACTNAME@@/@@ARTIFACTNAME@@.log --webroot=/var/cache/@@ARTIFACTNAME@@/war" -[ -n "$JENKINS_PORT" ] && PARAMS="$PARAMS --httpPort=$JENKINS_PORT" -[ -n "$JENKINS_LISTEN_ADDRESS" ] && PARAMS="$PARAMS --httpListenAddress=$JENKINS_LISTEN_ADDRESS" -[ -n "$JENKINS_HTTPS_PORT" ] && PARAMS="$PARAMS --httpsPort=$JENKINS_HTTPS_PORT" -[ -n "$JENKINS_HTTPS_KEYSTORE" ] && PARAMS="$PARAMS --httpsKeyStore='$JENKINS_HTTPS_KEYSTORE'" -[ -n "$JENKINS_HTTPS_KEYSTORE_PASSWORD" ] && PARAMS="$PARAMS --httpsKeyStorePassword='$JENKINS_HTTPS_KEYSTORE_PASSWORD'" -[ -n "$JENKINS_HTTPS_LISTEN_ADDRESS" ] && PARAMS="$PARAMS --httpsListenAddress=$JENKINS_HTTPS_LISTEN_ADDRESS" -[ -n "$JENKINS_HTTP2_PORT" ] && PARAMS="$PARAMS --http2Port=$JENKINS_HTTP2_PORT" -[ -n "$JENKINS_HTTP2_LISTEN_ADDRESS" ] && PARAMS="$PARAMS --http2ListenAddress=$JENKINS_HTTP2_LISTEN_ADDRESS" -[ -n "$JENKINS_DEBUG_LEVEL" ] && PARAMS="$PARAMS --debug=$JENKINS_DEBUG_LEVEL" -[ -n "$JENKINS_ARGS" ] && PARAMS="$PARAMS $JENKINS_ARGS" - -if [ "$JENKINS_ENABLE_ACCESS_LOG" = "yes" ]; then - PARAMS="$PARAMS --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=/var/log/@@ARTIFACTNAME@@/access_log" -fi - -RETVAL=0 - -is_running() { - : >"$JENKINS_PID_FILE" # just in case we fail to find it - # get PID - /bin/ps hww -u "$JENKINS_USER" -o pid,cmd | while read -r pid cmd; do - echo "$cmd" | grep "$JENKINS_WAR" >/dev/null - [ $? = 0 ] || continue - # found a PID - echo "$pid" >"$JENKINS_PID_FILE" - done - if [ -s "$JENKINS_PID_FILE" ]; then - return 0 - else - return 1 - fi -} - -case "$1" in -start) - echo -n "Starting @@PRODUCTNAME@@ " - daemon --user "$JENKINS_USER" --pidfile "$JENKINS_PID_FILE" "$JENKINS_JAVA_CMD" $JENKINS_JAVA_OPTIONS "-DJENKINS_HOME=$JENKINS_HOME" -jar "$JENKINS_WAR" $PARAMS & - RETVAL=$? - if [ $RETVAL = 0 ]; then - attempt=1 - is_started=false - while [ $attempt -le 30 ]; do - if is_running; then - is_started=true - break - fi - sleep 1 - attempt=$((attempt + 1)) - done - if $is_started; then - success - touch "$JENKINS_LOCKFILE" - else - failure - fi - else - failure - fi - echo - ;; -stop) - echo -n "Shutting down @@PRODUCTNAME@@ " - killproc @@ARTIFACTNAME@@ - rm -f $JENKINS_LOCKFILE - RETVAL=$? - echo - ;; -try-restart | condrestart) - if test "$1" = "condrestart"; then - echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" - fi - $0 status - if test $? = 0; then - $0 restart - else - : # Not running is not a failure. - fi - ;; -restart) - $0 stop - $0 start - ;; -force-reload) - echo -n "Reload service @@PRODUCTNAME@@ " - $0 try-restart - ;; -reload) - $0 restart - ;; -status) - status @@ARTIFACTNAME@@ - RETVAL=$? - ;; -probe) - ## Optional: Probe for the necessity of a reload, print out the - ## argument to this init script which is required for a reload. - ## Note: probe is not (yet) part of LSB (as of 1.9) - - test "$JENKINS_CONFIG" -nt "$JENKINS_PID_FILE" && echo reload - ;; -*) - echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}" - exit 1 - ;; -esac -exit $RETVAL diff --git a/rpm/build/SOURCES/jenkins.sysconfig.in b/rpm/build/SOURCES/jenkins.sysconfig.in deleted file mode 100644 index e80f28c5..00000000 --- a/rpm/build/SOURCES/jenkins.sysconfig.in +++ /dev/null @@ -1,153 +0,0 @@ -## Path: Development/@@CAMELARTIFACTNAME@@ -## Description: @@SUMMARY@@ -## Type: string -## Default: "~~HOME~~" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# Directory where Jenkins store its configuration and working -# files (checkouts, build reports, artifacts, ...). -# -JENKINS_HOME="~~HOME~~" - -## Type: string -## Default: "" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# Java executable to run Jenkins -# When left empty, we'll try to find the suitable Java. -# -JENKINS_JAVA_CMD="" - -## Type: string -## Default: "@@ARTIFACTNAME@@" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# Unix user account that runs the Jenkins daemon -# Be careful when you change this, as you need to update -# permissions of $JENKINS_HOME and /var/log/@@ARTIFACTNAME@@, -# and if you have already run Jenkins, potentially other -# directories such as /var/cache/@@ARTIFACTNAME@@ . -# -JENKINS_USER="@@ARTIFACTNAME@@" - -## Type: string -## Default: "false" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# Whether to skip potentially long-running chown at the -# $JENKINS_HOME location. Do not enable this, "true", unless -# you know what you're doing. See JENKINS-23273. -# -#JENKINS_INSTALL_SKIP_CHOWN="false" - -## Type: string -## Default: "-Djava.awt.headless=true" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# Options to pass to java when running Jenkins. -# -JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true" - -## Type: integer(0:65535) -## Default: @@PORT@@ -## ServiceRestart: @@ARTIFACTNAME@@ -# -# Port Jenkins is listening on. -# Set to -1 to disable -# -JENKINS_PORT="@@PORT@@" - -## Type: string -## Default: "" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# IP address Jenkins listens on for HTTP requests. -# Default is all interfaces (0.0.0.0). -# -JENKINS_LISTEN_ADDRESS="" - -## Type: integer(0:65535) -## Default: "" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# HTTPS port Jenkins is listening on. -# Default is disabled. -# -JENKINS_HTTPS_PORT="" - -## Type: string -## Default: "" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# Path to the keystore in JKS format (as created by the JDK 'keytool'). -# Default is disabled. -# -JENKINS_HTTPS_KEYSTORE="" - -## Type: string -## Default: "" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# Password to access the keystore defined in JENKINS_HTTPS_KEYSTORE. -# Default is disabled. -# -JENKINS_HTTPS_KEYSTORE_PASSWORD="" - -## Type: string -## Default: "" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# IP address Jenkins listens on for HTTPS requests. -# Default is disabled. -# -JENKINS_HTTPS_LISTEN_ADDRESS="" - -## Type: integer(0:65535) -## Default: "" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# HTTP2 port Jenkins is listening on. -# Default is disabled. -# -# Notice: HTTP2 support may require additional configuration, see Winstone -# documentation for more information. -# -JENKINS_HTTP2_PORT="" - -## Type: string -## Default: "" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# IP address Jenkins listens on for HTTP2 requests. -# Default is disabled. -# -# Notice: HTTP2 support may require additional configuration, see Winstone -# documentation for more information. -# -JENKINS_HTTP2_LISTEN_ADDRESS="" - -## Type: integer(1:9) -## Default: 5 -## ServiceRestart: @@ARTIFACTNAME@@ -# -# Debug level for logs -- the higher the value, the more verbose. -# 5 is INFO. -# -JENKINS_DEBUG_LEVEL="5" - -## Type: yesno -## Default: no -## ServiceRestart: @@ARTIFACTNAME@@ -# -# Whether to enable access logging or not. -# -JENKINS_ENABLE_ACCESS_LOG="no" - -## Type: string -## Default: "" -## ServiceRestart: @@ARTIFACTNAME@@ -# -# Pass arbitrary arguments to Jenkins. -# Full option list: java -jar @@ARTIFACTNAME@@.war --help -# -JENKINS_ARGS="" diff --git a/rpm/build/SPECS/jenkins.spec b/rpm/build/SPECS/jenkins.spec index b9c6f8fc..f8385919 100644 --- a/rpm/build/SPECS/jenkins.spec +++ b/rpm/build/SPECS/jenkins.spec @@ -1,21 +1,17 @@ # TODO: # - how to add to the trusted service of the firewall? -%define workdir %{_var}/lib/@@ARTIFACTNAME@@ +%define workdir %{_sharedstatedir}/@@ARTIFACTNAME@@ Name: @@ARTIFACTNAME@@ Version: %{ver} Release: 1.1 Summary: @@SUMMARY@@ Source: jenkins.war -Source1: jenkins.init.in -Source2: jenkins.sysconfig.in Source3: jenkins.logrotate Source4: jenkins.service Source5: jenkins.sh -Source6: migrate.sh URL: @@HOMEPAGE@@ -Group: Development/Tools/Building License: @@LICENSE@@ BuildRoot: %{_tmppath}/build-%{name}-%{version} # Unfortunately the Oracle Java RPMs do not register as providing anything (including "java" or "jdk") @@ -26,6 +22,7 @@ BuildRoot: %{_tmppath}/build-%{name}-%{version} Requires: procps Requires(pre): /usr/sbin/useradd, /usr/sbin/groupadd BuildArch: noarch +%systemd_requires %description @@DESCRIPTION_FILE@@ @@ -45,23 +42,14 @@ rm -rf "%{buildroot}" %__install -d "%{buildroot}%{workdir}" %__install -d "%{buildroot}%{workdir}/plugins" -%__install -d "%{buildroot}/var/log/%{name}" -%__install -d "%{buildroot}/var/cache/%{name}" +%__install -d "%{buildroot}%{_localstatedir}/log/%{name}" +%__install -d "%{buildroot}%{_localstatedir}/cache/%{name}" -%__install -D -m0755 "%{SOURCE1}" "%{buildroot}/etc/init.d/%{name}" -%__sed -i 's,~~WAR~~,%{_javadir}/%{name}.war,g' "%{buildroot}/etc/init.d/%{name}" -%__install -d "%{buildroot}/usr/sbin" -%__ln_s "../../etc/init.d/%{name}" "%{buildroot}/usr/sbin/rc%{name}" - -%__install -D -m0600 "%{SOURCE2}" "%{buildroot}/etc/sysconfig/%{name}" -%__sed -i 's,~~HOME~~,%{workdir},g' "%{buildroot}/etc/sysconfig/%{name}" - -%__install -D -m0644 "%{SOURCE3}" "%{buildroot}/etc/logrotate.d/%{name}" +%__install -D -m0644 "%{SOURCE3}" "%{buildroot}%{_sysconfdir}/logrotate.d/%{name}" %__install -D -m0644 "%{SOURCE4}" "%{buildroot}%{_unitdir}/%{name}.service" + %__install -D -m0755 "%{SOURCE5}" "%{buildroot}%{_bindir}/%{name}" -%__install -d "%{buildroot}%{_datadir}/%{name}" -%__install -D -m0755 "%{SOURCE6}" "%{buildroot}%{_datadir}/%{name}/migrate" %pre /usr/bin/getent group %{name} &>/dev/null || /usr/sbin/groupadd -r %{name} &>/dev/null @@ -69,79 +57,27 @@ rm -rf "%{buildroot}" /usr/bin/getent passwd %{name} &>/dev/null || /usr/sbin/useradd -g %{name} -s /bin/false -r -c "@@SUMMARY@@" \ -d "%{workdir}" %{name} &>/dev/null - # Used to decide later if we should perform a chown in case JENKINS_INSTALL_SKIP_CHOWN is false - # Check if a previous installation exists, if so check the JENKINS_HOME value and existing owners of work, log and cache dir, need to to this check - # here because the %files directive overwrites folder owners, I have not found a simple way to make the - # files directive to use JENKINS_USER as owner. - if [ -f "/etc/sysconfig/%{name}" ]; then - logger -t %{name}.installer "Found previous config file /etc/sysconfig/%{name}" - . "/etc/sysconfig/%{name}" - stat --format=%U "/var/cache/%{name}" > "/tmp/%{name}.installer.cacheowner" - stat --format=%U "/var/log/%{name}" > "/tmp/%{name}.installer.logowner" - stat --format=%U ${JENKINS_HOME:-%{workdir}} > "/tmp/%{name}.installer.workdirowner" - else - logger -t %{name}.installer "No previous config file /etc/sysconfig/%{name} found" - fi - %post -%{_datadir}/%{name}/migrate "/etc/sysconfig/%{name}" || true %systemd_post %{name}.service -function chownIfNecessary { - logger -t %{name}.installer "Checking ${2} ownership" - if [ -f "${1}" ] ; then - owner=$(cat "$1") - rm -f "$1" - logger -t %{name}.installer "Found previous owner of ${2}: ${owner} " - fi - if [ "${owner:-%{name}}" != "${JENKINS_USER:-%{name}}" ] ; then - logger -t %{name}.installer "Previous owner of ${2} is different than configured JENKINS_USER... Doing a recursive chown of ${2} " - chown -R ${JENKINS_USER:-%{name}} "$2" - elif [ "${JENKINS_USER:-%{name}}" != "%{name}" ] ; then - # User has changed ownership of files and JENKINS_USER, chown only the folder - logger -t %{name}.installer "Configured JENKINS_USER is different than default... Doing a non recursive chown of ${2} " - chown ${JENKINS_USER:-%{name}} "$2" - else - logger -t %{name}.installer "No chown needed for ${2} " - fi -} - -# Ensure the right ownership on files only if not owned by JENKINS_USER and JENKINS_USER -# != %{name}, namely all cases but the default one (configured for %{name} owned by %{name}) -# In any case if JENKINS_INSTALL_SKIP_CHOWN is true we do not chown anything to maintain -# the existing semantics -. /etc/sysconfig/%{name} -if test x"$JENKINS_INSTALL_SKIP_CHOWN" != "xtrue"; then - chownIfNecessary "/tmp/%{name}.installer.cacheowner" "/var/cache/%{name}" - chownIfNecessary "/tmp/%{name}.installer.logowner" "/var/log/%{name}" - chownIfNecessary "/tmp/%{name}.installer.workdirowner" ${JENKINS_HOME:-%{workdir}} -fi - %preun %systemd_preun %{name}.service %postun %systemd_postun_with_restart %{name}.service -%clean -%__rm -rf "%{buildroot}" - %files -%defattr(-,root,root) %{_javadir}/%{name}.war %attr(0755,%{name},%{name}) %dir %{workdir} -%attr(0750,%{name},%{name}) /var/log/%{name} -%attr(0750,%{name},%{name}) /var/cache/%{name} -%config /etc/logrotate.d/%{name} -%config(noreplace) /etc/init.d/%{name} -%config(noreplace) /etc/sysconfig/%{name} -/usr/sbin/rc%{name} +%attr(0750,%{name},%{name}) %{_localstatedir}/log/%{name} +%attr(0750,%{name},%{name}) %{_localstatedir}/cache/%{name} +%config %{_sysconfdir}/logrotate.d/%{name} %{_unitdir}/%{name}.service %{_bindir}/%{name} -%dir %{_datadir}/%{name} -%{_datadir}/%{name}/migrate %changelog +* Mon Jun 19 2023 projects@unixadm.org +- removed sysv initscript for el>=7 * Sat Apr 19 2014 mbarr@mbarr.net - Removed the jenkins.repo installation. Per https://issues.jenkins-ci.org/browse/JENKINS-22690 * Wed Sep 28 2011 kk@kohsuke.org