From c1cc05a9c05896c60862cdd3a81764949f144b18 Mon Sep 17 00:00:00 2001 From: Jochen Schalanda Date: Wed, 9 Feb 2011 02:29:26 +0100 Subject: [PATCH] Fixes feature #550 - Added Debian package specification. --- extra/debian/changelog | 5 ++ extra/debian/compat | 1 + extra/debian/control | 20 ++++++ extra/debian/copyright | 29 ++++++++ extra/debian/default | 6 ++ extra/debian/dirs | 3 + extra/debian/docs | 1 + extra/debian/init.d | 156 +++++++++++++++++++++++++++++++++++++++++++++ extra/debian/install | 8 ++ extra/debian/links | 1 + extra/debian/logrotate | 12 ++++ extra/debian/postinst | 44 +++++++++++++ extra/debian/rules | 13 ++++ extra/debian/settings.yml | 52 +++++++++++++++ 14 files changed, 351 insertions(+), 0 deletions(-) create mode 100644 extra/debian/changelog create mode 100644 extra/debian/compat create mode 100644 extra/debian/control create mode 100644 extra/debian/copyright create mode 100644 extra/debian/default create mode 100644 extra/debian/dirs create mode 100644 extra/debian/docs create mode 100644 extra/debian/init.d create mode 100644 extra/debian/install create mode 100644 extra/debian/links create mode 100644 extra/debian/logrotate create mode 100644 extra/debian/postinst create mode 100755 extra/debian/rules create mode 100644 extra/debian/settings.yml diff --git a/extra/debian/changelog b/extra/debian/changelog new file mode 100644 index 0000000..a5b2bf6 --- /dev/null +++ b/extra/debian/changelog @@ -0,0 +1,5 @@ +foreman-proxy (0.0.2-1) unstable; urgency=low + + * Initial release + + -- Jochen Schalanda Tue, 08 Feb 2011 22:02:53 +0100 diff --git a/extra/debian/compat b/extra/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/extra/debian/compat @@ -0,0 +1 @@ +7 diff --git a/extra/debian/control b/extra/debian/control new file mode 100644 index 0000000..fb0a779 --- /dev/null +++ b/extra/debian/control @@ -0,0 +1,20 @@ +Source: foreman-proxy +Section: net +Priority: extra +Maintainer: Jochen Schalanda +Build-Depends: debhelper (>= 7.0.50~) +Standards-Version: 3.9.1 +Homepage: http://theforeman.org/projects/smart-proxy +Vcs-Git: git://github.com/ohadlevy/smart-proxy.git +Vcs-Browser: https://github.com/ohadlevy/smart-proxy + +Package: foreman-proxy +Architecture: all +Depends: ruby, rubygems, libopenssl-ruby, libsinatra-ruby, libjson-ruby, libnet-ping-ruby, rake, ${misc:Depends} +Description: RESTful proxies for DNS, DHCP, TFTP, and Puppet + Smart-Proxy is a project which provides a RESTful API to various sub-systems + like DNS, DHCP, TFTP, and Puppet. + . + Its goal is to provide API for a higher level orchestration tools. + Smart-Proxy provides an easy way to add or extended existing + sub-systems and APIs. diff --git a/extra/debian/copyright b/extra/debian/copyright new file mode 100644 index 0000000..9c74280 --- /dev/null +++ b/extra/debian/copyright @@ -0,0 +1,29 @@ +This work was packaged for Debian by: + + Jochen Schalanda on Tue, 08 Feb 2011 22:02:53 +0100 + +It was downloaded from: + + http://theforeman.org/projects/smart-proxy + +Upstream Author(s): + + Ohad Levy + +Copyright: + + Copyright (C) 2010-2011 Ohad Levy + +License: + + GPL-3 + +On any Debian system, you can find the complete text of the GNU GPL +(GNU General Public License) in the file '/usr/share/common-licenses/GPL-3'. + +The Debian packaging is: + + Copyright (C) 2011 Jochen Schalanda + +and is licensed under the GPL version 3, +see "/usr/share/common-licenses/GPL-3". diff --git a/extra/debian/default b/extra/debian/default new file mode 100644 index 0000000..0ee43df --- /dev/null +++ b/extra/debian/default @@ -0,0 +1,6 @@ +# Defaults for smart-proxy initscript +# sourced by /etc/init.d/foreman-proxy + +DAEMON_USER="foreman-proxy:foreman-proxy" +DAEMON_HOME="/usr/share/foreman-proxy" +DAEMON_ARGS="" diff --git a/extra/debian/dirs b/extra/debian/dirs new file mode 100644 index 0000000..a027348 --- /dev/null +++ b/extra/debian/dirs @@ -0,0 +1,3 @@ +etc/foreman-proxy +usr/share/foreman-proxy/logs +var/log/foreman-proxy diff --git a/extra/debian/docs b/extra/debian/docs new file mode 100644 index 0000000..e845566 --- /dev/null +++ b/extra/debian/docs @@ -0,0 +1 @@ +README diff --git a/extra/debian/init.d b/extra/debian/init.d new file mode 100644 index 0000000..2cafb8b --- /dev/null +++ b/extra/debian/init.d @@ -0,0 +1,156 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: foreman-proxy +# Required-Start: $network $local_fs $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: RESTful proxies for DNS, DHCP, TFTP, and Puppet +# Description: Smart-Proxy is a project which provides a RESTful API to various sub-systems +# like DNS, DHCP, TFTP, and Puppet. +### END INIT INFO + +# Author: Jochen Schalanda + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC=foreman-proxy +NAME=foreman-proxy +DAEMON=/usr/share/$NAME/bin/smart-proxy +DAEMON_ARGS="" +PIDFILE=/var/run/$NAME/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME + +# Exit if the package is not installed +[ -x $DAEMON ] || exit 0 + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + PIDFILE_DIR=$(dirname $PIDFILE) + if [ ! -x $PIDFILE_DIR ] + then + mkdir -p $PIDFILE_DIR && chown $DAEMON_USER $PIDFILE_DIR + fi + + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --chuid $DAEMON_USER --pidfile $PIDFILE --exec $DAEMON -- \ + $DAEMON_ARGS \ + || return 2 +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + # Wait for children to finish too if this is a daemon that forks + # and if the daemon is only ever run from this initscript. + # If the above conditions are not satisfied then add some other code + # that waits for the process to drop all resources that could be + # needed by services started subsequently. A last resort is to + # sleep for some time. + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" +} + +# +# Function that sends a SIGHUP to the daemon/service +# +do_reload() { + # + # If the daemon can reload its configuration without + # restarting (for example, when it is sent a SIGHUP), + # then implement that here. + # + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + return 0 +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + #reload|force-reload) + # + # If do_reload() is not implemented then leave this commented out + # and leave 'force-reload' as an alias for 'restart'. + # + #log_daemon_msg "Reloading $DESC" "$NAME" + #do_reload + #log_end_msg $? + #;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/extra/debian/install b/extra/debian/install new file mode 100644 index 0000000..ff16d86 --- /dev/null +++ b/extra/debian/install @@ -0,0 +1,8 @@ +bin usr/share/foreman-proxy +config usr/share/foreman-proxy +lib usr/share/foreman-proxy +public usr/share/foreman-proxy +Rakefile usr/share/foreman-proxy +tasks usr/share/foreman-proxy +views usr/share/foreman-proxy +debian/settings.yml etc/foreman-proxy diff --git a/extra/debian/links b/extra/debian/links new file mode 100644 index 0000000..ebb942c --- /dev/null +++ b/extra/debian/links @@ -0,0 +1 @@ +etc/foreman-proxy/settings.yml usr/share/foreman-proxy/config/settings.yml diff --git a/extra/debian/logrotate b/extra/debian/logrotate new file mode 100644 index 0000000..cb984eb --- /dev/null +++ b/extra/debian/logrotate @@ -0,0 +1,12 @@ +/var/log/foreman-proxy/*log { + missingok + notifempty + create 0644 foreman-proxy foreman-proxy + sharedscripts + rotate 5 + compress + daily + postrotate + [ -e /etc/init.d/foreman-proxy ] && /etc/init.d/foreman-proxy restart >/dev/null 2>&1 || true + endscript +} diff --git a/extra/debian/postinst b/extra/debian/postinst new file mode 100644 index 0000000..af46ed6 --- /dev/null +++ b/extra/debian/postinst @@ -0,0 +1,44 @@ +#!/bin/sh +# postinst script for smart-proxy +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + +case "$1" in + configure) + getent group foreman-proxy >/dev/null || groupadd -r foreman-proxy + getent passwd foreman-proxy >/dev/null || \ + useradd -r -g foreman-proxy -d /usr/share/foreman-proxy -s /usr/sbin/nologin -c "Foreman Smart-Proxy" foreman-proxy + + chown 'foreman-proxy:foreman-proxy' '/usr/share/foreman-proxy/logs' + chown 'foreman-proxy:foreman-proxy' '/var/log/foreman-proxy' + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/extra/debian/rules b/extra/debian/rules new file mode 100755 index 0000000..b760bee --- /dev/null +++ b/extra/debian/rules @@ -0,0 +1,13 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +%: + dh $@ diff --git a/extra/debian/settings.yml b/extra/debian/settings.yml new file mode 100644 index 0000000..293c9f8 --- /dev/null +++ b/extra/debian/settings.yml @@ -0,0 +1,52 @@ +--- +# SSL Setup + +# if enabled, all communication would be verfied via SSL +# NOTE that both certificates need to be signed by the same CA in order for this to work +# see http://theforeman.org/projects/smart-proxy/wiki/SSL for more information +#:ssl_certificate: ssl/certs/fqdn.pem +#:ssl_ca_file: ssl/certs/ca.pem +#:ssl_private_key: ssl/private_keys/fqdn.key +# the hosts which the proxy accepts connections from +# commenting the following lines would mean every verified SSL connection allowed +#:trusted_hosts: +#- foreman.prod.domain +#- foreman.dev.domain + +# enable the daemon to run in the background +:daemon: true +:daemon_pid: /var/run/foreman-proxy/foreman-proxy.pid + +# port used by the proxy +:port: 8443 + +# Enable TFTP management +#:tftp: true +#:tftproot: /tmp/tftpboot + + +# Enable DNS management +#:dns: true +#:dns_key: /home/proxy/keys/Kapi.+157+47848.private +#:dns_server: dns.domain.com + +# Enable DHCP management +#:dhcp: true +# The vendor can be either isc or native_ms +#:dhcp_vendor: isc +# Settings for Ubuntu ISC +#:dhcp_config: /etc/dhcp3/dhcpd.conf +#:dhcp_leases: /var/lib/dhcp3/dhcpd.leases + +# enable PuppetCA management +#:puppetca: true + +# enable Puppet management +#:puppet: true + +# Where our proxy log files are stored +# filename or STDOUT +:log_file: /var/log/foreman-proxy/foreman-proxy.log +# valid options are +# Logger::WARN, Logger::DEBUG, Logger::Error, Logger::Fatal, Logger:INFO, LOGGER::UNKNOWN +#:log_level: Logger::DEBUG -- 1.7.4