From 29cb573b6ced5cfeca0fc905040ff615e2d76835 Mon Sep 17 00:00:00 2001
From: Rovanion Luckey <rovanion.luckey@gmail.com>
Date: Mon, 9 Dec 2013 14:05:50 +0100
Subject: [PATCH] Added example defaults file and appropriate documentation.

---
 doc/install/installation.md               | 16 +++++++++-------
 lib/support/init.d/gitlab                 | 20 +++++++++++++-------
 lib/support/init.d/gitlab.default.example | 14 ++++++++++++++
 3 files changed, 36 insertions(+), 14 deletions(-)
 create mode 100755 lib/support/init.d/gitlab.default.example

diff --git a/doc/install/installation.md b/doc/install/installation.md
index 3e90663dbd8..2a86ef1e120 100644
--- a/doc/install/installation.md
+++ b/doc/install/installation.md
@@ -1,6 +1,6 @@
 # Select Version to Install
 Make sure you view this installation guide from the branch (version) of GitLab you would like to install. In most cases
-this should be the highest numbered stable branch (example shown below). 
+this should be the highest numbered stable branch (example shown below).
 
 ![capture](https://f.cloud.github.com/assets/1192780/564911/2f9f3e1e-c5b7-11e2-9f89-98e527d1adec.png)
 
@@ -105,7 +105,7 @@ Is the system packaged Git too old? Remove it and compile from source.
 mail server. By default, Debian is shipped with exim4 whereas Ubuntu
 does not ship with one. The recommended mail server is postfix and you can install it with:
 
-	sudo apt-get install -y postfix 
+	sudo apt-get install -y postfix
 
 Then select 'Internet Site' and press enter to confirm the hostname.
 
@@ -253,7 +253,7 @@ Make sure to edit both `gitlab.yml` and `unicorn.rb` to match your setup.
     # PostgreSQL
     sudo -u git cp config/database.yml.postgresql config/database.yml
 
-    
+
     # Make config/database.yml readable to git only
     sudo -u git -H chmod o-rwx config/database.yml
 
@@ -281,8 +281,10 @@ Make sure to edit both `gitlab.yml` and `unicorn.rb` to match your setup.
 
 Download the init script (will be /etc/init.d/gitlab):
 
-    sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
-    sudo chmod +x /etc/init.d/gitlab
+    sudo ln -s lib/support/init.d/gitlab /etc/init.d/gitlab
+    sudo cp lib/support/init.d/gitlab /etc/default/gitlab
+
+If you installed gitlab in another directory or as a user other than the default you should change these settings in /etc/default/gitlab. Do not edit /etc/init.d/gitlab as it will be changed on upgrade.
 
 Make GitLab start on boot:
 
@@ -370,7 +372,7 @@ a different host, you can configure its connection string via the
     # example
     production: redis://redis.example.tld:6379
 
-If you want to connect the Redis server via socket, then use the "unix:" URL scheme 
+If you want to connect the Redis server via socket, then use the "unix:" URL scheme
 and the path to the Redis socket file in the `config/resque.yml` file.
 
     # example
@@ -406,7 +408,7 @@ These steps are fairly general and you will need to figure out the exact details
 * Add provider specific configuration options to your `config/gitlab.yml` (you can use the [auth providers section of the example config](https://github.com/gitlabhq/gitlabhq/blob/master/config/gitlab.yml.example) as a reference)
 
 * Add the gem to your [Gemfile](https://github.com/gitlabhq/gitlabhq/blob/master/Gemfile)
-                `gem "omniauth-your-auth-provider"` 
+                `gem "omniauth-your-auth-provider"`
 * If you're using MySQL, install the new Omniauth provider gem by running the following command:
 		`sudo -u git -H bundle install --without development test postgres --path vendor/bundle --no-deployment`
 
diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab
index 9cf3aa5fe85..f1b94087b6a 100755
--- a/lib/support/init.d/gitlab
+++ b/lib/support/init.d/gitlab
@@ -15,11 +15,20 @@
 # Description:       GitLab git repository management
 ### END INIT INFO
 
+
+###
+# DO NOT EDIT THIS FILE!
+# This file will be overwritten on update.
+# Instead add/change your variables in /etc/default/gitlab
+# An example defaults file can be found in lib/support/default/gitlab
+###
+
+
 ### Environment variables
 RAILS_ENV="production"
 
-# Script variable names should be lower-case not to conflict with internal
-# /bin/sh variables such as PATH, EDITOR or SHELL.
+# Script variable names should be lower-case not to conflict with
+# internal /bin/sh variables such as PATH, EDITOR or SHELL.
 app_user="git"
 app_root="/home/$app_user/gitlab"
 pid_path="$app_root/tmp/pids"
@@ -27,10 +36,6 @@ socket_path="$app_root/tmp/sockets"
 web_server_pid_path="$pid_path/unicorn.pid"
 sidekiq_pid_path="$pid_path/sidekiq.pid"
 
-
-
-### Here ends user configuration ###
-
 # Read configuration variable file if it is present
 test -f /etc/default/gitlab && . /etc/default/gitlab
 
@@ -39,11 +44,12 @@ if [ "$USER" != "$app_user" ]; then
   sudo -u "$app_user" -H -i $0 "$@"; exit;
 fi
 
-# Switch to the gitlab path, if it fails exit with an error.
+# Switch to the gitlab path, exit on failure.
 if ! cd "$app_root" ; then
  echo "Failed to cd into $app_root, exiting!";  exit 1
 fi
 
+
 ### Init Script functions
 
 ## Gets the pids from the files
diff --git a/lib/support/init.d/gitlab.default.example b/lib/support/init.d/gitlab.default.example
new file mode 100755
index 00000000000..4230783a9d7
--- /dev/null
+++ b/lib/support/init.d/gitlab.default.example
@@ -0,0 +1,14 @@
+# Copy this lib/support/init.d/gitlab.default.example file to
+# /etc/default/gitlab in order for it to apply to your system.
+
+# RAILS_ENV defines the type of installation that is running.
+# Normal values are "production", "test" and "development".
+RAILS_ENV="production"
+
+# app_user defines the user that GitLab is run as.
+# The default is "git".
+app_user="git"
+
+# app_root defines the folder in which gitlab and it's components are installed.
+# The default is "/home/$app_user/gitlab"
+app_root="/home/$app_user/gitlab"
-- 
GitLab