From 6a634c6102a7e39f5390becc3993b4375201668f Mon Sep 17 00:00:00 2001
From: Jochen Schalanda <jochen.schalanda@detasad.com.sa>
Date: Wed, 2 Jun 2010 14:46:53 +0000
Subject: [PATCH] Added Debian package files.

---
 .gitmodules                      |   16 +++---
 extras/debian/changelog          |    5 ++
 extras/debian/compat             |    1 +
 extras/debian/conf/database.yml  |   22 ++++++++
 extras/debian/conf/email.yaml    |    9 +++
 extras/debian/conf/settings.yaml |   12 ++++
 extras/debian/contrib/dbmigrate  |    9 +++
 extras/debian/control            |   29 ++++++++++
 extras/debian/copyright          |   17 ++++++
 extras/debian/dirs               |    4 ++
 extras/debian/docs               |    1 +
 extras/debian/foreman.default    |   18 ++++++
 extras/debian/foreman.init       |  107 ++++++++++++++++++++++++++++++++++++++
 extras/debian/foreman.logrotate  |    9 +++
 extras/debian/install            |   15 +++++
 extras/debian/links              |    7 +++
 extras/debian/postinst           |   49 +++++++++++++++++
 extras/debian/postrm             |    7 +++
 extras/debian/preinst            |   12 ++++
 extras/debian/prerm              |    7 +++
 extras/debian/rules              |   38 +++++++++++++
 extras/debian/source/format      |    1 +
 vendor/rails                     |    2 +-
 23 files changed, 388 insertions(+), 9 deletions(-)
 create mode 100644 extras/debian/changelog
 create mode 100644 extras/debian/compat
 create mode 100644 extras/debian/conf/database.yml
 create mode 100644 extras/debian/conf/email.yaml
 create mode 100644 extras/debian/conf/settings.yaml
 create mode 100755 extras/debian/contrib/dbmigrate
 create mode 100644 extras/debian/control
 create mode 100644 extras/debian/copyright
 create mode 100644 extras/debian/dirs
 create mode 100644 extras/debian/docs
 create mode 100644 extras/debian/foreman.default
 create mode 100755 extras/debian/foreman.init
 create mode 100644 extras/debian/foreman.logrotate
 create mode 100644 extras/debian/install
 create mode 100644 extras/debian/links
 create mode 100644 extras/debian/postinst
 create mode 100644 extras/debian/postrm
 create mode 100644 extras/debian/preinst
 create mode 100644 extras/debian/prerm
 create mode 100755 extras/debian/rules
 create mode 100644 extras/debian/source/format
 mode change 160000 => 120000 vendor/rails

diff --git a/.gitmodules b/.gitmodules
index 4cfd8e4..a640550 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,24 +1,24 @@
 [submodule "vendor/plugins/ruby-net-ldap"]
 	path = vendor/plugins/ruby-net-ldap
-	url = git://github.com/innovationfactory/ruby-net-ldap.git
+	url = http://github.com/innovationfactory/ruby-net-ldap.git
 [submodule "vendor/plugins/acts_as_audited"]
 	path = vendor/plugins/acts_as_audited
-	url = git://github.com/collectiveidea/acts_as_audited.git
+	url = http://github.com/collectiveidea/acts_as_audited.git
 [submodule "vendor/plugins/will_paginate"]
 	path = vendor/plugins/will_paginate
-	url = git://github.com/mislav/will_paginate.git
+	url = http://github.com/mislav/will_paginate.git
 [submodule "vendor/rails"]
 	path = vendor/rails
-	url = git://github.com/rails/rails.git
+	url = http://github.com/rails/rails.git
 [submodule "vendor/plugins/searchlogic"]
 	path = vendor/plugins/searchlogic
-	url = git://github.com/binarylogic/searchlogic.git
+	url = http://github.com/binarylogic/searchlogic.git
 [submodule "vendor/plugins/google_visualr"]
 	path = vendor/plugins/google_visualr
-	url = git://github.com/ohadlevy/google_visualr.git
+	url = http://github.com/ohadlevy/google_visualr.git
 [submodule "extras/puppet"]
 	path = extras/puppet
-	url = git://github.com/ohadlevy/puppet-foreman.git
+	url = http://github.com/ohadlevy/puppet-foreman.git
 [submodule "vendor/plugins/has_many_polymorphs"]
 	path = vendor/plugins/has_many_polymorphs
-	url = git://github.com/fauna/has_many_polymorphs.git
+	url = http://github.com/fauna/has_many_polymorphs.git
diff --git a/extras/debian/changelog b/extras/debian/changelog
new file mode 100644
index 0000000..7d358ca
--- /dev/null
+++ b/extras/debian/changelog
@@ -0,0 +1,5 @@
+foreman (0.1.5-1) experimental; urgency=low
+
+  * Initial Debian version
+
+ -- Ohad Levy <ohadlevy@gmail.com>  Mon, 31 May 2010 23:33:11 +0800
diff --git a/extras/debian/compat b/extras/debian/compat
new file mode 100644
index 0000000..7f8f011
--- /dev/null
+++ b/extras/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/extras/debian/conf/database.yml b/extras/debian/conf/database.yml
new file mode 100644
index 0000000..025d62a
--- /dev/null
+++ b/extras/debian/conf/database.yml
@@ -0,0 +1,22 @@
+# SQLite version 3.x
+#   gem install sqlite3-ruby (not necessary on OS X Leopard)
+development:
+  adapter: sqlite3
+  database: db/development.sqlite3
+  pool: 5
+  timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+  adapter: sqlite3
+  database: db/test.sqlite3
+  pool: 5
+  timeout: 5000
+
+production:
+  adapter: sqlite3
+  database: db/production.sqlite3
+  pool: 5
+  timeout: 5000
diff --git a/extras/debian/conf/email.yaml b/extras/debian/conf/email.yaml
new file mode 100644
index 0000000..d15b497
--- /dev/null
+++ b/extras/debian/conf/email.yaml
@@ -0,0 +1,9 @@
+# Outgoing email settings
+
+production:
+  delivery_method: :smtp
+  smtp_settings:
+    address: smtp.example.com
+    port: 25
+    domain: example.com
+    authentication: :none
diff --git a/extras/debian/conf/settings.yaml b/extras/debian/conf/settings.yaml
new file mode 100644
index 0000000..a9fcf83
--- /dev/null
+++ b/extras/debian/conf/settings.yaml
@@ -0,0 +1,12 @@
+--- 
+#:modulepath: /etc/puppet/modules/
+:tftppath: tftp/
+#:rrd_report_url: report/
+#:ldap: true
+#your default puppet server - can be overridden in the host level
+#if none specified, plain "puppet" will be used.
+#:puppet_server: puppet
+#:unattended: false
+#use the following setting to override the default 30 minutes puppet run interval - value must be in minutes
+#:puppet_interval: 60
+#:document_root: /var/www
diff --git a/extras/debian/contrib/dbmigrate b/extras/debian/contrib/dbmigrate
new file mode 100755
index 0000000..07b4d4e
--- /dev/null
+++ b/extras/debian/contrib/dbmigrate
@@ -0,0 +1,9 @@
+#!/bin/sh
+USERNAME=$(/usr/bin/id -un)
+
+if [ $USERNAME = 'foreman' ]; then
+  cd && /usr/bin/rake db:migrate RAILS_ENV=production
+else
+  echo "User 'foreman' does not exist."
+  exit 1
+fi
diff --git a/extras/debian/control b/extras/debian/control
new file mode 100644
index 0000000..076d91c
--- /dev/null
+++ b/extras/debian/control
@@ -0,0 +1,29 @@
+Source: foreman
+Maintainer: Ohad Levy <ohadlevy@gmail.com>
+Section: web
+Priority: extra
+Standards-Version: 3.8.4
+Build-Depends: debhelper (>= 7)
+Homepage: http://www.theforeman.org/
+
+Package: foreman
+Architecture: all
+Depends: ${misc:Depends}, ruby, ruby1.8 (>= 1.8.7), rake (>=0.8.3), puppet (>=0.24.4)
+Recommends: libfcgi-ruby, libapache2-mod-passenger | libapache2-mod-fcgid | mongrel, libdbd-sqlite3-ruby, sqlite3
+Description: Systems management web interface
+ Foreman is aimed to be a single address for all machines life cycle management.
+ .
+  - Foreman integrates with Puppet and acts as web front end to it.
+  - Foreman takes care of bare bone provisioning until the point puppet is
+    running, allowing Puppet to do what it does best.
+  - Foreman shows you Systems Inventory (based on Facter) and provides real time
+    information about hosts status based on Puppet reports.
+  - Foreman creates everything you need when adding a new machine to your
+    network. Its goal being automatically managing everything you would
+    normally manage manually - that would eventually include DNS, DHCP,
+    TFTP, PuppetCA, CMDB and everything else you might consider useful.
+  - With Foreman you can always rebuild your machines from scratch.
+  - Foreman is designed to work in a large enterprise, where multiple domains,
+    subnets and puppetmasters are required.
+    In many cases, Foreman could help remote provisions where no experienced
+    technicians are available.
diff --git a/extras/debian/copyright b/extras/debian/copyright
new file mode 100644
index 0000000..4a33295
--- /dev/null
+++ b/extras/debian/copyright
@@ -0,0 +1,17 @@
+Copyright (c) 2009-2010 Ohad Levy and Paul Kelly
+
+This program and entire repository is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+any later version.
+
+This program 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+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
diff --git a/extras/debian/dirs b/extras/debian/dirs
new file mode 100644
index 0000000..5ddc4a6
--- /dev/null
+++ b/extras/debian/dirs
@@ -0,0 +1,4 @@
+etc/foreman
+var/cache/foreman
+var/lib/foreman
+var/log/foreman
diff --git a/extras/debian/docs b/extras/debian/docs
new file mode 100644
index 0000000..e845566
--- /dev/null
+++ b/extras/debian/docs
@@ -0,0 +1 @@
+README
diff --git a/extras/debian/foreman.default b/extras/debian/foreman.default
new file mode 100644
index 0000000..70a8f9a
--- /dev/null
+++ b/extras/debian/foreman.default
@@ -0,0 +1,18 @@
+# Start foreman on boot?
+START=yes
+
+# the location where foreman is installed
+#FOREMAN_HOME=/usr/share/foreman
+
+# the network interface which foreman web server is running at
+#FOREMAN_IFACE=0.0.0.0
+
+# the port which foreman web server is running at
+# note that if the foreman user is not root, it has to be a > 1024
+#FOREMAN_PORT=3000
+
+# the user which runs the web interface
+#FOREMAN_USER=foreman
+
+# the rails environment in which foreman runs
+#FOREMAN_ENV=production
diff --git a/extras/debian/foreman.init b/extras/debian/foreman.init
new file mode 100755
index 0000000..15890c9
--- /dev/null
+++ b/extras/debian/foreman.init
@@ -0,0 +1,107 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          foreman
+# Required-Start:    $network $named $remote_fs $syslog
+# Required-Stop:     $network $named $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+### END INIT INFO 
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="Foreman systems management web application"
+NAME=foreman
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+FOREMAN_IFACE=${FOREMAN_IFACE:-'0.0.0.0'}
+FOREMAN_PORT=${FOREMAN_PORT:-'3000'}
+FOREMAN_USER=${FOREMAN_USER:-'foreman'}
+FOREMAN_HOME=${FOREMAN_HOME:-'/usr/share/foreman'}
+FOREMAN_ENV=${FOREMAN_ENV:-'production'}
+FOREMAN_PID=${FOREMAN_PID:-"${FOREMAN_HOME}/tmp/pids/server.pid"}
+
+DAEMON="${FOREMAN_HOME}/script/server"
+DAEMON_OPTS="-b ${FOREMAN_IFACE} -p ${FOREMAN_PORT} -e ${FOREMAN_ENV} -d"
+
+. /lib/init/vars.sh
+. /lib/lsb/init-functions
+
+is_true() {
+	if [ "x$1" = "xtrue" -o "x$1" = "xyes" -o "x$1" = "x0" ]; then
+		return 0
+	else
+		return 1
+	fi
+}
+
+do_start()
+{
+	if is_true "$START" ; then
+		start-stop-daemon --start --quiet --chuid $FOREMAN_USER --pidfile $FOREMAN_PID --exec $DAEMON -- $DAEMON_OPTS
+	else
+		echo ""
+		echo "${NAME} not configured to start. Please edit /etc/default/${NAME} to enable."
+	fi
+}
+
+do_stop()
+{
+	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $FOREMAN_PID
+	RETVAL="$?"
+	[ "$RETVAL" = 2 ] && return 2
+	
+	rm -f $FOREMAN_PID
+	return "$RETVAL"
+}
+
+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 "$FOREMAN_PID" "$DAEMON" "$NAME" && exit 0 || exit $?
+       ;;
+  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|status|restart|force-reload}" >&2
+	exit 3
+	;;
+esac
+
+:
diff --git a/extras/debian/foreman.logrotate b/extras/debian/foreman.logrotate
new file mode 100644
index 0000000..5e3b87c
--- /dev/null
+++ b/extras/debian/foreman.logrotate
@@ -0,0 +1,9 @@
+/var/log/foreman/*log {
+  missingok
+  notifempty
+  create 0644 foreman foreman
+  sharedscripts
+  postrotate
+    [ -x /etc/init.d/foreman ] && /etc/init.d/foreman force-reload >/dev/null 2>&1 || true
+  endscript
+}
diff --git a/extras/debian/install b/extras/debian/install
new file mode 100644
index 0000000..f032733
--- /dev/null
+++ b/extras/debian/install
@@ -0,0 +1,15 @@
+# Install the basic application files
+app usr/share/foreman
+config usr/share/foreman
+db var/lib/foreman
+extras usr/share/foreman
+lib usr/share/foreman
+public var/lib/foreman
+Rakefile usr/share/foreman
+script usr/share/foreman
+test usr/share/foreman
+vendor/plugins usr/share/foreman/vendor
+vendor/gems usr/share/foreman/vendor
+vendor/rails usr/share/foreman/vendor
+debian/conf/* etc/foreman
+debian/contrib/* usr/share/foreman/extras
diff --git a/extras/debian/links b/extras/debian/links
new file mode 100644
index 0000000..59317fe
--- /dev/null
+++ b/extras/debian/links
@@ -0,0 +1,7 @@
+etc/foreman/database.yml	usr/share/foreman/config/database.yml
+etc/foreman/email.yml		usr/share/foreman/config/email.yml
+etc/foreman/settings.yml	usr/share/foreman/config/settings.yml
+var/cache/foreman		usr/share/foreman/tmp
+var/lib/foreman/db		usr/share/foreman/db
+var/log/foreman			usr/share/foreman/log
+var/lib/foreman/public		usr/share/foreman/public
diff --git a/extras/debian/postinst b/extras/debian/postinst
new file mode 100644
index 0000000..f57c4f9
--- /dev/null
+++ b/extras/debian/postinst
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+set -e
+
+chown 'foreman:foreman' '/var/lib/foreman'
+chmod '755' '/var/lib/foreman'
+chown 'foreman:foreman' '/var/lib/foreman/db'
+chmod '755' '/var/lib/foreman/db'
+chown 'foreman:foreman' '/var/lib/foreman/public'
+chmod '755' '/var/lib/foreman/public'
+chown 'foreman:foreman' '/var/lib/foreman/public/404.html'
+chown 'foreman:foreman' '/var/lib/foreman/public/422.html'
+chown 'foreman:foreman' '/var/lib/foreman/public/500.html'
+chown 'foreman:foreman' '/var/lib/foreman/public/blank.html'
+chown 'foreman:foreman' '/var/lib/foreman/public/favicon.ico'
+chown 'foreman:foreman' '/var/lib/foreman/public/images'
+chmod '755' '/var/lib/foreman/public/images'
+chown 'foreman:foreman' '/var/lib/foreman/public/images/false.png'
+chown 'foreman:foreman' '/var/lib/foreman/public/images/hosts'
+chmod '755' '/var/lib/foreman/public/images/hosts'
+chown 'foreman:foreman' '/var/lib/foreman/public/images/hosts/Darwin.jpg'
+chown 'foreman:foreman' '/var/lib/foreman/public/images/hosts/Linux.jpg'
+chown 'foreman:foreman' '/var/lib/foreman/public/images/hosts/SunOS.jpg'
+chown 'foreman:foreman' '/var/lib/foreman/public/images/hosts/attention_required.png'
+chown 'foreman:foreman' '/var/lib/foreman/public/images/hosts/warning.png'
+chown 'foreman:foreman' '/var/lib/foreman/public/images/rails.png'
+chown 'foreman:foreman' '/var/lib/foreman/public/images/true.png'
+chown 'foreman:foreman' '/var/lib/foreman/public/javascripts'
+chmod '755' '/var/lib/foreman/public/javascripts'
+chown 'foreman:foreman' '/var/lib/foreman/public/javascripts/application.js'
+chown 'foreman:foreman' '/var/lib/foreman/public/javascripts/controls.js'
+chown 'foreman:foreman' '/var/lib/foreman/public/javascripts/dragdrop.js'
+chown 'foreman:foreman' '/var/lib/foreman/public/javascripts/effects.js'
+chown 'foreman:foreman' '/var/lib/foreman/public/javascripts/host_checkbox.js'
+chown 'foreman:foreman' '/var/lib/foreman/public/javascripts/prototype.js'
+chown 'foreman:foreman' '/var/lib/foreman/public/robots.txt'
+chown 'foreman:foreman' '/var/lib/foreman/public/stylesheets'
+chmod '755' '/var/lib/foreman/public/stylesheets'
+chown 'foreman:foreman' '/var/lib/foreman/public/stylesheets/style.css'
+chown 'foreman:foreman' '/var/log/foreman'
+chown 'foreman:foreman' '/var/cache/foreman'
+chmod '755' '/var/cache/foreman'
+
+# initialize/migrate the database (defaults to SQLITE3)
+su - foreman -s /bin/bash -c /usr/share/foreman/extras/dbmigrate >/dev/null 2>&1
+
+#DEBHELPER# 
+    
+exit 0
diff --git a/extras/debian/postrm b/extras/debian/postrm
new file mode 100644
index 0000000..efab641
--- /dev/null
+++ b/extras/debian/postrm
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+
+#DEBHELPER# 
+    
+exit 0
diff --git a/extras/debian/preinst b/extras/debian/preinst
new file mode 100644
index 0000000..b7d02a9
--- /dev/null
+++ b/extras/debian/preinst
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -e
+
+# Add the "foreman" user and group
+getent group foreman >/dev/null || groupadd -r foreman
+getent passwd foreman >/dev/null || \
+    useradd -r -g foreman -G puppet -d /usr/share/foreman -s /usr/sbin/nologin -c "Foreman" foreman
+
+#DEBHELPER# 
+    
+exit 0
diff --git a/extras/debian/prerm b/extras/debian/prerm
new file mode 100644
index 0000000..efab641
--- /dev/null
+++ b/extras/debian/prerm
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+
+#DEBHELPER# 
+    
+exit 0
diff --git a/extras/debian/rules b/extras/debian/rules
new file mode 100755
index 0000000..4bf860c
--- /dev/null
+++ b/extras/debian/rules
@@ -0,0 +1,38 @@
+#!/usr/bin/make -f
+# Uncomment this to turn on verbose mode.
+export DH_VERBOSE=1
+
+build: 
+	dh_testdir
+
+clean:
+	dh_testdir
+	dh_testroot
+	dh_clean
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_prep
+	dh_installdirs
+	dh_install
+
+binary-indep: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs
+	dh_installdocs
+	dh_installinit
+	dh_installlogrotate
+	dh_link
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary-arch:
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch install
diff --git a/extras/debian/source/format b/extras/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/extras/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/vendor/rails b/vendor/rails
deleted file mode 160000
index bfe0328..0000000
--- a/vendor/rails
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit bfe032858077bb2946abe25e95e485ba6da86bd5
diff --git a/vendor/rails b/vendor/rails
new file mode 120000
index 0000000..1a36224
--- /dev/null
+++ b/vendor/rails
@@ -0,0 +1 @@
+rails-2.3.8/
\ No newline at end of file
-- 
1.7.0.4

