cirandas.net-etc

commit fbd45befb477b7b6e02932e7f15c8be60ff1c4f5

Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>

scripts: cirandas add original cirandas init.d script

 scripts/cirandas | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++


diff --git a/scripts/cirandas b/scripts/cirandas
new file mode 100755
index 0000000000000000000000000000000000000000..2a212f3ba8ddc0321d6865e9d9531e5a8cee9d6b
--- /dev/null
+++ b/scripts/cirandas
@@ -0,0 +1,130 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          cirandas
+# Required-Start:    $remote_fs
+# Required-Stop:     $remote_fs
+# Should-Start:      postgresql
+# Should-Stop:       postgresql
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Example initscript
+# Description:       This file should be used to construct scripts to be
+#                    placed in /etc/init.d.
+### END INIT INFO
+
+# Sample init.d script for cirandas
+#
+# This script was based on the skeleton init.d script present in a Debian
+# GNU/Linux system (sid), on Sat Feb 16 11:12:03 BRT 2008. It must be placed in
+#
+# Author: Antonio Terceiro <terceiro@colivre.coop.br>
+
+# Do NOT "set -e"
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="Noosfero web platform"
+NAME=cirandas
+SCRIPTNAME=/etc/init.d/$NAME
+
+# default values
+NOOSFERO_DIR=/home/cirandas/noosfero-ecosol
+NOOSFERO_USER=cirandas
+
+PIDFILE="$NOOSFERO_DIR/tmp/pids/unicorn.pid"
+
+. /lib/lsb/init-functions
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+if test -x /usr/sbin/noosfero-check-dbconfig ; then
+  if ! noosfero-check-dbconfig; then
+    echo "Noosfero database access not configured, service disabled."
+    exit 0
+  fi
+fi
+
+######################
+
+
+noosfero_run() {
+  if [ "$NOOSFERO_USER" != "$USER" ]; then
+    # su -l is buggy to load rc and profile
+    su $NOOSFERO_USER -l -c "bash -l -c \"cd $NOOSFERO_DIR &&
+      rbenv shell 2.3.4 &&
+      export RUBY_GC_MALLOC_LIMIT='90000000'
+export LD_PRELOAD='/usr/lib/x86_64-linux-gnu/libjemalloc.so.1'
+      $*\""
+  else
+    cd $NOOSFERO_DIR && \
+      rbenv shell 2.3.4 &&
+      export RUBY_GC_MALLOC_LIMIT='90000000'
+export LD_PRELOAD='/usr/lib/x86_64-linux-gnu/libjemalloc.so.1'
+      $*
+  fi
+}
+
+main_script() {
+  # WARN: Solr doesn't need a restart
+  if [ "$1" != "restart" ]; then
+    noosfero_run RAILS_ENV=production rake solr:$1
+  fi
+  if [ "$1" = "restart" ]; then
+    kill -USR2 `cat $NOOSFERO_DIR/tmp/pids/unicorn.pid` 2>&1 > /dev/null
+  elif [ "$1" = "start" ]; then
+    noosfero_run bundle exec unicorn -D -c config/unicorn.conf.rb -E production
+  elif [ "$1" = "stop" ]; then
+    kill `cat $NOOSFERO_DIR/tmp/pids/unicorn.pid` 2>&1 > /dev/null
+  fi
+}
+
+
+do_start() {
+  if ! running; then
+    # actually start the service
+    main_script start
+  else
+    echo 'Noosfero is already running, nothing to do...'
+  fi
+}
+
+do_stop() {
+  if running; then
+    main_script stop
+  else
+    echo 'Noosfero is already stopped, nothing to do...'
+  fi
+}
+
+do_restart() {
+  if ! running; then
+    do_start
+  else
+    main_script restart
+  fi
+}
+
+do_status() {
+  status_of_proc -p $PIDFILE "noosfero" "$NAME"
+}
+
+running(){
+  status_of_proc -p $PIDFILE "noosfero" "$NAME" 2>&1 > /dev/null
+}
+
+
+case "$1" in
+  start|stop|restart|status)
+    do_$1
+    exit $?
+    ;;
+  force-reload)
+    do_restart
+    ;;
+  *)
+    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
+    exit 3
+    ;;
+esac
+
+: