Commit 85341ca3c33797da06a9838c36fa70c66bdf515f

Authored by AntonioTerceiro
1 parent 79fae59e

ActionItem154: finishing initscripts


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1431 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 2 changed files with 51 additions and 6 deletions   Show diff stats
etc/init.d/noosfero
@@ -32,14 +32,24 @@ SCRIPTNAME=/etc/init.d/$NAME @@ -32,14 +32,24 @@ SCRIPTNAME=/etc/init.d/$NAME
32 # Load the VERBOSE setting and other rcS variables 32 # Load the VERBOSE setting and other rcS variables
33 . /lib/init/vars.sh 33 . /lib/init/vars.sh
34 34
35 -if [ -z $NOOSFERO_DIR ]; then  
36 - echo "NOOSFERO_DIR not defined, noosfero not being started." 35 +if [ -z $NOOSFERO_DIR ] || [ -z $NOOSFERO_USER ]; then
  36 + echo "NOOSFERO_DIR or NOOSFERO_USER not defined, noosfero not being started."
  37 + echo "Both variables must be defined in /etc/default/noosfero"
37 exit 0 38 exit 0
38 fi 39 fi
39 40
40 ###################### 41 ######################
41 FERRET_PID_FILE=$NOOSFERO_DIR/log/ferret.pid 42 FERRET_PID_FILE=$NOOSFERO_DIR/log/ferret.pid
42 43
  44 +main_script() {
  45 + cd $NOOSFERO_DIR
  46 + if [ "$NOOSFERO_USER" != "$USER" ]; then
  47 + su $NOOSFERO_USER -c "./script/production $1"
  48 + else
  49 + ./script/production $1
  50 + fi
  51 +}
  52 +
43 do_start() { 53 do_start() {
44 54
45 # FIXME should not test for ferret only 55 # FIXME should not test for ferret only
@@ -48,8 +58,7 @@ do_start() { @@ -48,8 +58,7 @@ do_start() {
48 exit 2 58 exit 2
49 fi 59 fi
50 60
51 - cd $NOOSFERO_DIR  
52 - ./script/production start 61 + main_script start
53 } 62 }
54 63
55 do_stop() { 64 do_stop() {
@@ -60,8 +69,7 @@ do_stop() { @@ -60,8 +69,7 @@ do_stop() {
60 exit 2 69 exit 2
61 fi 70 fi
62 71
63 - cd $NOOSFERO_DIR  
64 - ./script/production stop 72 + main_script stop
65 } 73 }
66 74
67 do_restart() { 75 do_restart() {
script/production 0 → 100755
@@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
  1 +#!/bin/sh
  2 +
  3 +export RAILS_ENV=production
  4 +
  5 +ACTION=$1
  6 +shift
  7 +
  8 +do_start() {
  9 + ./script/ferret_start
  10 + sleep 1
  11 + mongrel_rails cluster::start
  12 + sleep 3
  13 +}
  14 +
  15 +do_stop() {
  16 + mongrel_rails cluster::stop
  17 + sleep 1
  18 + ./script/ferret_stop
  19 +}
  20 +
  21 +case "$ACTION" in
  22 + start|stop)
  23 + do_$ACTION
  24 + ;;
  25 +
  26 + restart)
  27 + do_stop
  28 + sleep 1
  29 + do_start
  30 + ;;
  31 +
  32 + *)
  33 + echo "usage: $0 start|stop|restart"
  34 + exit 1
  35 + ;;
  36 +esac
  37 +