~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerheadd

  • Committer: Martin Albisetti
  • Date: 2008-11-25 02:55:57 UTC
  • mfrom: (245.1.1 initscript-non-root)
  • Revision ID: argentina@gmail.com-20081125025557-8es5u9e300s7pv01
Allow the script to run as root or another user, but start the loggerhead process as the correct user (Tom Haddon)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#   script might not be able to kill loggerhead)
15
15
#
16
16
 
 
17
LHUSER=loggerhead
 
18
 
 
19
if [ `whoami` = "$LHUSER" ]; then                                                                                   
 
20
    SUDO=""
 
21
else                                                                                                                
 
22
    SUDO="sudo -H -u $LHUSER"
 
23
fi
 
24
 
17
25
# If serve-branches is not in your path, you will need to specify the full path:
18
26
SERVE_BRANCHES_CMD=serve-branches
19
27
 
34
42
#
35
43
 
36
44
loggerhead_process(){
37
 
    pgrep -fl "$START_CMD"
 
45
    $SUDO pgrep -fl "$START_CMD"
38
46
}
39
47
 
40
48
loggerhead_status(){
58
66
    echo "Starting loggerhead.   (See $LOG_FOLDER for details.)"
59
67
 
60
68
    # make sure the log folder is created
61
 
    mkdir -p $LOG_FOLDER
 
69
    if [ ! -d $LOG_FOLDER ]
 
70
    then
 
71
        $SUDO mkdir -p $LOG_FOLDER
 
72
    fi
62
73
    echo "" > $LOG_FILE
63
 
    python $START_CMD > $LOG_FILE 2>&1 &
 
74
    $SUDO python $START_CMD > $LOG_FILE 2>&1 &
64
75
 
65
76
    #wait a little while of some logging to appear
66
77
    log=""
77
88
 
78
89
stop_loggerhead(){
79
90
    echo "Stopping loggerhead."
80
 
    pkill -f "$START_CMD"
 
91
    $SUDO pkill -f "$START_CMD"
81
92
    loggerhead_status
82
93
}
83
94