Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/customservice/templates/init-customservice.erb

Issue 29465602: #1574 - Update template syntax in customservice module (Closed)
Patch Set: Created June 14, 2017, 12:37 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh 1 #!/bin/sh
2 ### BEGIN INIT INFO 2 ### BEGIN INIT INFO
3 # Provides: 3 # Provides:
4 # Required-Start: $remote_fs $syslog 4 # Required-Start: $remote_fs $syslog
5 # Required-Stop: $remote_fs $syslog 5 # Required-Stop: $remote_fs $syslog
6 # Default-Start: 2 3 4 5 6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 1 6 7 # Default-Stop: 0 1 6
8 # Short-Description: Start daemon at boot time 8 # Short-Description: Start daemon at boot time
9 # Description: Enable service provided by daemon. 9 # Description: Enable service provided by daemon.
10 ### END INIT INFO 10 ### END INIT INFO
11 11
12 user="<%= user %>" 12 user="<%= @user %>"
13 name="<%= name %>" 13 name="<%= @name %>"
14 cmd="<%= command %>" 14 cmd="<%= @command %>"
15 15
16 pid_file="/var/run/$name.pid" 16 pid_file="/var/run/$name.pid"
17 stdout_log="/var/log/$name.log" 17 stdout_log="/var/log/$name.log"
18 stderr_log="/var/log/$name.err" 18 stderr_log="/var/log/$name.err"
19 19
20 get_pid() { 20 get_pid() {
21 cat "$pid_file" 21 cat "$pid_file"
22 } 22 }
23 23
24 is_running() { 24 is_running() {
25 [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1 25 [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
26 } 26 }
27 27
28 case "$1" in 28 case "$1" in
29 start) 29 start)
30 if is_running; then 30 if is_running; then
31 echo "Already started" 31 echo "Already started"
32 else 32 else
33 echo "Starting $name" 33 echo "Starting $name"
34 <% if workdir != :undef -%> 34 <% if @workdir != :undef -%>
35 cd "<%= workdir %>" 35 cd "<%= @workdir %>"
36 <% end -%> 36 <% end -%>
37 sudo -u "$user" \ 37 sudo -u "$user" \
38 <% for variable in @env -%> 38 <% for variable in @env -%>
39 <%= variable %> \ 39 <%= variable %> \
40 <% end -%> 40 <% end -%>
41 $cmd > "$stdout_log" 2> "$stderr_log" \ 41 $cmd > "$stdout_log" 2> "$stderr_log" \
42 & echo $! > "$pid_file" 42 & echo $! > "$pid_file"
43 if ! is_running; then 43 if ! is_running; then
44 echo "Unable to start, see $stdout_log and $stderr_log" 44 echo "Unable to start, see $stdout_log and $stderr_log"
45 exit 1 45 exit 1
(...skipping 21 matching lines...) Expand all
67 exit 1 67 exit 1
68 fi 68 fi
69 ;; 69 ;;
70 *) 70 *)
71 echo "Usage: $0 {start|stop|restart|status}" 71 echo "Usage: $0 {start|stop|restart|status}"
72 exit 1 72 exit 1
73 ;; 73 ;;
74 esac 74 esac
75 75
76 exit 0 76 exit 0
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld