source: branches/gsoc09-logging/base/src/port1.0/portstartupitem.tcl @ 52218

Last change on this file since 52218 was 52218, checked in by enl@…, 11 years ago

Merge from trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 22.0 KB
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
2# portstartupitem.tcl
3#
4# $Id: portstartupitem.tcl 52218 2009-06-12 08:57:53Z enl@macports.org $
5#
6# Copyright (c) 2004-2007 MacPorts Project
7# Copyright (c) 2006-2007 James D. Berry
8# Copyright (c) 2004,2005 Markus W. Weissman <mww@macports.org>
9# All rights reserved.
10#
11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions are
13# met:
14#
15# 1. Redistributions of source code must retain the above copyright
16#    notice, this list of conditions and the following disclaimer.
17# 2. Redistributions in binary form must reproduce the above copyright
18#    notice, this list of conditions and the following disclaimer in the
19#    documentation and/or other materials provided with the distribution.
20# 3. Neither the name of Apple Computer, Inc. nor the names of its
21#    contributors may be used to endorse or promote products derived from
22#    this software without specific prior written permission.
23#
24# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35#
36
37
38#
39#   Newly added keys:
40#
41#   startupitem.executable  the command to start the executable
42#       This is exclusive of init, start, stop, restart
43#       - This may be composed of exec arguments only--not shell code
44#
45#   startupitem.pidfile     none
46#       There is no pidfile we can track
47#
48#   startupitem.pidfile     auto [filename.pid]
49#       The daemon is responsible for creating/deleting the pidfile
50#
51#   startupitem.pidfile     clean [filename.pid]
52#       The daemon creates the pidfile, but we must delete it
53#
54#   startupitem.pidfile     manual [filename.pid]
55#       We create and destroy the pidfile to track the pid we receive from the executable
56#
57#   startupitem.logfile     logpath
58#       Log to the specified file -- if not specified then output to /dev/null
59#       - for launchd, just set this as the standard out key
60#       - for systemstarter, redirect to this
61#
62#   startupitem.logevents   yes/no
63#       Log events to the log
64#       - for launchd, generate log messages inside daemondo
65#       - for systemstarter, generate log messages in our generated script
66#
67
68package provide portstartupitem 1.0
69package require portutil 1.0
70
71namespace eval portstartupitem {
72}
73
74set_ui_prefix
75
76proc portstartupitem::startupitem_create_rcng {args} {
77    global prefix destroot name os.platform
78    global startupitem.name startupitem.requires
79    global startupitem.start startupitem.stop startupitem.restart
80    global startupitem.type
81
82    set scriptdir ${destroot}/${prefix}/etc/rc.d
83
84    if { ![exists startupitem.requires] } {
85        set startupitem.requires ""
86    }
87
88    # XXX We can't share defaults with startupitem_create_darwin
89    foreach item {startupitem.start startupitem.stop startupitem.restart} {
90        if {![info exists $item]} {
91            return -code error "Missing required option $item"
92        }
93    }
94
95    file mkdir ${destroot} ${scriptdir}
96    set fd [open [file join ${scriptdir} ${startupitem.name}.sh] w 0755]
97
98    puts ${fd} "#!/bin/sh"
99    puts ${fd} "#"
100    puts ${fd} "# MacPorts generated RCng Script"
101    puts ${fd} "#"
102    puts ${fd} ""
103    puts ${fd} "# PROVIDE: ${startupitem.name}"
104    puts ${fd} "# REQUIRE: ${startupitem.requires}"
105    # TODO: Implement BEFORE support
106    puts ${fd} "# BEFORE:"
107    puts ${fd} "# KEYWORD: MacPorts"
108    puts ${fd} ""
109    puts ${fd} ". ${prefix}/etc/rc.subr"
110    puts ${fd} ""
111    puts ${fd} "name=\"${startupitem.name}\""
112    puts ${fd} "start_cmd=\"${startupitem.start}\""
113    puts ${fd} "stop_cmd=\"${startupitem.stop}\""
114    puts ${fd} "restart_cmd=\"${startupitem.restart}\""
115    puts ${fd} ""
116    puts ${fd} "load_rc_config \"${startupitem.name}\""
117    puts ${fd} ""
118    puts ${fd} "run_rc_command \"\$1\""
119    close ${fd}
120}
121
122proc portstartupitem::startupitem_create_darwin_systemstarter {args} {
123    global UI_PREFIX prefix destroot destroot.keepdirs name os.platform
124    global startupitem.name startupitem.requires startupitem.init
125    global startupitem.start startupitem.stop startupitem.restart startupitem.executable
126    global startupitem.pidfile startupitem.logfile startupitem.logevents
127   
128    set scriptdir ${prefix}/etc/startup
129   
130    set itemname            ${startupitem.name}
131    set uppername           [string toupper ${startupitem.name}]
132    set itemdir             /Library/StartupItems/${itemname}
133    set startupItemDir      ${destroot}${itemdir}
134    set startupItemScript   ${startupItemDir}/${itemname}
135    set startupItemPlist    ${startupItemDir}/StartupParameters.plist
136   
137    # Interpret the pidfile spec
138    #
139    # There are four cases:
140    #   (1) none (or none specified)
141    #   (2) auto [pidfilename]
142    #   (3) clean [pidfilename]
143    #   (4) manual [pidfilename]
144    #
145    set createPidFile false
146    set deletePidFile false
147    set pidFile ""
148    set pidfileArgCnt [llength ${startupitem.pidfile}]
149    if { ${pidfileArgCnt} > 0 } {
150        if { $pidfileArgCnt == 1 } {
151            set pidFile "${prefix}/var/run/${itemname}.pid"
152            lappend destroot.keepdirs "${destroot}${prefix}/var/run"
153        } else {
154            set pidFile [lindex ${startupitem.pidfile} 1]
155        }
156        if { $pidfileArgCnt > 2 } {
157            ui_error "$UI_PREFIX [msgcat::mc "Invalid parameter count to startupitem.pidfile: 2 expected, %d found" ${pidfileArgCnt}]"
158        }
159       
160        set pidStyle [lindex ${startupitem.pidfile} 0]
161        switch ${pidStyle} {
162            none    { set createPidFile false; set deletePidFile false; set pidFile ""  }
163            auto    { set createPidFile false; set deletePidFile false  }
164            clean   { set createPidFile false; set deletePidFile true   }
165            manual  { set createPidFile true;  set deletePidFile true   }
166            default {
167                ui_error "$UI_PREFIX [msgcat::mc "Unknown pidfile style %s presented to startupitem.pidfile" ${pidStyle}]"
168            }
169        }
170    }
171
172    if { [llength ${startupitem.executable}] && 
173      ![llength ${startupitem.init}] &&
174      ![llength ${startupitem.start}] &&
175      ![llength ${startupitem.stop}] &&
176      ![llength ${startupitem.restart}] } {
177        # An executable is specified, and there is no init, start, stop, or restart
178    } else {
179        if { ![llength ${startupitem.start} ] } {
180            set startupitem.start [list "sh ${scriptdir}/${name}.sh start"]
181        }
182        if { ![llength ${startupitem.stop} ] } {
183            set startupitem.stop [list "sh ${scriptdir}/${name}.sh stop"]
184        }
185    }
186    if { ![llength ${startupitem.requires} ] } {
187        set startupitem.requires [list Disks NFS]
188    }
189    if { ![llength ${startupitem.logfile} ] } {
190        set startupitem.logfile "/dev/null"
191    }
192   
193    ########################
194    # Create the startup item directory
195    file mkdir ${startupItemDir}
196    file attributes ${startupItemDir} -owner root -group wheel
197   
198    ########################
199    # Generate the startup item script
200    set item [open "${startupItemScript}" w 0755]
201    file attributes "${startupItemScript}" -owner root -group wheel
202   
203    # Emit the header
204    puts ${item} {#!/bin/sh
205#
206# MacPorts generated StartupItem
207#
208
209    }
210    puts ${item} "prefix=$prefix"
211    # Source the utilities package and the MacPorts config file
212    puts ${item} {[ -r "/etc/rc.common" ] && . "/etc/rc.common"}
213    puts ${item} {[ -r "${prefix}/etc/rc.conf" ] && . "${prefix}/etc/rc.conf"}
214
215    # Emit the Configuration Section
216    puts ${item} "NAME=${itemname}"
217    puts ${item} "ENABLE_FLAG=\${${uppername}:=-NO-}"
218    puts ${item} "PIDFILE=\"${pidFile}\""
219    puts ${item} "LOGFILE=\"${startupitem.logfile}\""
220    puts ${item} "EXECUTABLE=\"${startupitem.executable}\""
221    puts ${item} ""
222    puts ${item} "HAVE_STARTCMDS=[expr [llength ${startupitem.start}] ? "true" : "false"]"
223    puts ${item} "HAVE_STOPCMDS=[expr [llength ${startupitem.stop}] ? "true" : "false"]"
224    puts ${item} "HAVE_RESTARTCMDS=[expr [llength ${startupitem.restart}] ? "true" : "false"]"
225    puts ${item} "DELETE_PIDFILE=${createPidFile}"
226    puts ${item} "CREATE_PIDFILE=${deletePidFile}"
227    puts ${item} "LOG_EVENTS=[expr [tbool ${startupitem.logevents}] ? "true" : "false"]"
228    puts ${item} ""
229
230    # Emit the init lines
231    foreach line ${startupitem.init} { puts ${item} ${line} }
232    puts ${item} ""
233   
234    # Emit the _Cmds
235    foreach kind { start stop restart } {
236        if {[llength [set "startupitem.$kind"]]} {
237            puts ${item} "${kind}Cmds () \{"
238            foreach line [set "startupitem.$kind"] {
239                puts ${item} "\t${line}"
240            }
241            puts ${item} "\}\n"
242        }
243    }
244   
245    # vvvvv START BOILERPLATE vvvvvv
246    # Emit the static boilerplate section
247    puts ${item} {
248IsEnabled () {
249    [ "${ENABLE_FLAG}" = "-YES-" ]
250    return $?
251}
252
253CreatePIDFile () {
254    echo $1 > "$PIDFILE"
255}
256
257DeletePIDFile () {
258    rm -f "$PIDFILE"
259}
260
261ReadPID () {
262    if [ -r "$PIDFILE" ]; then
263        read pid < "$PIDFILE"
264    else
265        pid=0
266    fi
267    echo $pid
268}
269
270CheckPID () {
271    pid=$(ReadPID)
272    if (($pid)); then
273        kill -0 $pid >& /dev/null || pid=0
274    fi
275    echo $pid
276}
277
278NoteEvent () {
279    ConsoleMessage "$1"
280    $LOG_EVENTS && [ -n "$LOGFILE" ] && echo "$(date) $NAME: $1" >> $LOGFILE
281}
282
283StartService () {
284    if IsEnabled; then
285        NoteEvent "Starting $NAME"
286       
287        if $HAVE_STARTCMDS; then
288            startCmds
289        elif [ -n "$EXECUTABLE" ]; then
290            $EXECUTABLE &
291            pid=$!
292            if $CREATE_PIDFILE; then
293                CreatePIDFile $pid
294            fi
295        fi
296       
297    fi
298}
299
300StopService () {
301    NoteEvent "Stopping $NAME"
302   
303    gaveup=false
304    if $HAVE_STOPCMDS; then
305        # If we have stop cmds, use them
306        stopCmds
307    else       
308        # Otherwise, get the pid and try to stop the program
309        echo -n "Stopping $NAME..."
310       
311        pid=$(CheckPID)
312        if (($pid)); then
313            # Try to kill the process with SIGTERM
314            kill $pid
315           
316            # Wait for it to really stop
317            for ((CNT=0; CNT < 15 && $(CheckPID); ++CNT)); do
318                echo -n "."
319                sleep 1
320            done
321           
322            # Report status
323            if (($(CheckPID))); then
324                gaveup=true
325                echo "giving up."
326            else
327                echo "stopped."
328            fi
329        else
330            echo "it's not running."
331        fi
332    fi
333   
334    # Cleanup the pidfile if we've been asked to
335    if ! $gaveup && $DELETE_PIDFILE; then
336        DeletePIDFile
337    fi
338}
339
340RestartService () {
341    if IsEnabled; then
342        NoteEvent "Restarting $NAME"
343       
344        if $HAVE_RESTARTCMDS; then
345            # If we have restart cmds, use them
346            restartCmds
347        else
348            # Otherwise just stop/start it
349            StopService
350            StartService
351        fi
352       
353    fi
354}
355
356RunService "$1"
357    }
358    # ^^^^^^ END BOILERPLATE ^^^^^^
359   
360    close ${item}
361   
362    ########################
363    # Generate the plist
364    set para [open "${startupItemPlist}" w 0644]
365    file attributes "${startupItemPlist}" -owner root -group wheel
366   
367    puts ${para} "\{"
368    puts ${para} "\tDescription\t= \"${itemname}\";"
369    puts ${para} "\tProvides\t= (\"${itemname}\");"
370    puts -nonewline ${para} "\tRequires\t= ("
371    puts -nonewline ${para} [format {"%s"} [join ${startupitem.requires} {", "}]]
372    puts ${para} ");"
373    puts ${para} "\tOrderPreference\t= \"None\";"
374    puts ${para} "\}"
375    close ${para}
376   
377    # Emit some information for the user
378    ui_msg "###########################################################"
379    ui_msg "# A startup item has been generated that will aid in"
380    ui_msg "# starting ${name} with SystemStarter. It is disabled"
381    ui_msg "# by default. Add the following line to /etc/hostconfig"
382    ui_msg "# or ${prefix}/etc/rc.conf to start it at startup:"
383    ui_msg "#"
384    ui_msg "# ${uppername}=-YES-"
385    ui_msg "###########################################################"
386}
387
388proc portstartupitem::startupitem_create_darwin_launchd {args} {
389    global UI_PREFIX prefix destroot destroot.keepdirs name os.platform
390    global startupitem.name startupitem.uniquename startupitem.plist startupitem.location
391    global startupitem.init startupitem.start startupitem.stop startupitem.restart startupitem.executable
392    global startupitem.pidfile startupitem.logfile startupitem.logevents startupitem.netchange
393
394    set scriptdir ${prefix}/etc/startup
395   
396    set itemname        ${startupitem.name}
397    set uniquename      ${startupitem.uniquename}
398    set plistname       ${startupitem.plist}
399    set daemondest      ${startupitem.location}
400    set itemdir         ${prefix}/etc/${daemondest}/${uniquename}
401    set args            [list \
402                          "${prefix}/bin/daemondo" \
403                          "--label=${itemname}" \
404                        ]
405   
406    file mkdir ${destroot}${itemdir}
407    file attributes ${destroot}${itemdir} -owner root -group wheel
408       
409    if { [llength ${startupitem.executable}] && 
410      ![llength ${startupitem.init}] &&
411      ![llength ${startupitem.start}] &&
412      ![llength ${startupitem.stop}] &&
413      ![llength ${startupitem.restart}] } {
414           
415        # An executable is specified, and there is no init, start, stop, or restart
416        # code; so we don't need a wrapper script
417        set args [concat $args "--start-cmd" ${startupitem.executable} ";"]
418       
419    } else {
420   
421        # No executable was specified, or there was an init, start, stop, or restart
422        # option, so we do need a wrapper script
423       
424        set wrappername     ${itemname}.wrapper
425        set wrapper         "${itemdir}/${wrappername}"
426
427        if { ![llength ${startupitem.start}] } {
428            set startupitem.start [list "sh ${scriptdir}/${name}.sh start"]
429        }
430        if { ![llength ${startupitem.stop}] } {
431            set startupitem.stop [list "sh ${scriptdir}/${name}.sh stop"]
432        }
433        if { ![llength ${startupitem.restart}] } {
434            set startupitem.restart [list Stop Start]
435        }
436
437        lappend args \
438          "--start-cmd"   ${wrapper} start   ";" \
439          "--stop-cmd"    ${wrapper} stop    ";" \
440          "--restart-cmd" ${wrapper} restart ";"
441
442        # Create the wrapper script
443        set item [open "${destroot}${wrapper}" w 0755]
444        file attributes "${destroot}${wrapper}" -owner root -group wheel
445
446        puts ${item} "#!/bin/sh"
447        puts ${item} "#"
448        puts ${item} "# MacPorts generated daemondo support script"
449        puts ${item} "#"
450        puts ${item} ""
451       
452        puts ${item} "#"
453        puts ${item} "# Init"
454        puts ${item} "#"
455        puts ${item} "prefix=$prefix"
456        foreach line ${startupitem.init}    { puts ${item} ${line} }
457        puts ${item} ""
458
459        puts ${item} "#"
460        puts ${item} "# Start"
461        puts ${item} "#"
462        puts ${item} "Start()"
463        puts ${item} "\{"
464        foreach line ${startupitem.start}   { puts ${item} "\t${line}" }
465        puts ${item} "\}"
466        puts ${item} ""
467       
468        puts ${item} "#"
469        puts ${item} "# Stop"
470        puts ${item} "#"
471        puts ${item} "Stop()"
472        puts ${item} "\{"
473        foreach line ${startupitem.stop}    { puts ${item} "\t${line}" }
474        puts ${item} "\}"
475        puts ${item} ""
476   
477        puts ${item} "#"
478        puts ${item} "# Restart"
479        puts ${item} "#"
480        puts ${item} "Restart()"
481        puts ${item} "\{"
482        foreach line ${startupitem.restart} { puts ${item} "\t${line}" }
483        puts ${item} "\}"
484        puts ${item} ""
485
486        puts ${item} "#"
487        puts ${item} "# Run"
488        puts ${item} "#"
489        puts ${item} "Run()"
490        puts ${item} "\{"
491        puts ${item} "case \$1 in"
492        puts ${item} "  start  ) Start   ;;"
493        puts ${item} "  stop   ) Stop    ;;"
494        puts ${item} "  restart) Restart ;;"
495        puts ${item} "  *      ) echo \"\$0: unknown argument: \$1\";;"
496        puts ${item} "esac"
497        puts ${item} "\}"
498        puts ${item} ""
499
500        puts ${item} "#"
501        puts ${item} "# Run a phase based on the selector"
502        puts ${item} "#"
503        puts ${item} "Run \$1"
504        puts ${item} ""
505
506        close ${item}
507    }
508   
509    if {[tbool startupitem.netchange]} {
510        lappend args "--restart-netchange"
511    }
512   
513    # To log events then tell daemondo to log at verbosity=1
514    if { [tbool startupitem.logevents] } {
515        lappend args "--verbosity=1"
516    }
517   
518    # If pidfile was specified, translate it for daemondo.
519    #
520    # There are four cases:
521    #   (1) none
522    #   (2) auto [pidfilename]
523    #   (3) clean [pidfilename]
524    #   (4) manual [pidfilename]
525    #
526    set pidfileArgCnt [llength ${startupitem.pidfile}]
527    if { ${pidfileArgCnt} > 0 } {
528        if { $pidfileArgCnt == 1 } {
529            set pidFile "${prefix}/var/run/${itemname}.pid"
530            lappend destroot.keepdirs "${destroot}${prefix}/var/run"
531        } else {
532            set pidFile [lindex ${startupitem.pidfile} 1]
533        }
534
535        if { ${pidfileArgCnt} > 2 } {
536            ui_error "$UI_PREFIX [msgcat::mc "Invalid parameter count to startupitem.pidfile: 2 expected, %d found" ${pidfileArgCnt}]"
537        }
538       
539        # Translate into appropriate arguments to daemondo
540        set pidStyle [lindex ${startupitem.pidfile} 0]
541        switch ${pidStyle} {
542            none    { lappend args "--pid=none" }
543            auto    { lappend args "--pid=fileauto" "--pidfile" ${pidFile} }
544            clean   { lappend args "--pid=fileclean" "--pidfile" ${pidFile} }
545            manual  { lappend args "--pid=exec" "--pidfile" ${pidFile} }
546            default {
547                ui_error "$UI_PREFIX [msgcat::mc "Unknown pidfile style %s presented to startupitem.pidfile" ${pidStyle}]"
548            }
549        }
550    } else {
551        if { [llength ${startupitem.executable}] } {
552            lappend args "--pid=exec"
553        } else {
554            lappend args "--pid=none"
555        }
556    }
557   
558    # Create the plist file
559    set plist [open "${destroot}${itemdir}/${plistname}" w 0644]
560   
561    puts ${plist} "<?xml version='1.0' encoding='UTF-8'?>"
562    puts ${plist} "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\""
563    puts ${plist} "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\" >"
564    puts ${plist} "<plist version='1.0'>"
565    puts ${plist} "<dict>"
566   
567    puts ${plist} "<key>Label</key><string>${uniquename}</string>"
568   
569    puts ${plist} "<key>ProgramArguments</key>"
570    puts ${plist} "<array>"
571    foreach arg ${args} { puts ${plist} "\t<string>${arg}</string>" }
572    puts ${plist} "</array>"
573   
574    puts ${plist} "<key>Debug</key><false/>"
575    puts ${plist} "<key>Disabled</key><true/>"
576    puts ${plist} "<key>OnDemand</key><false/>"
577    puts ${plist} "<key>RunAtLoad</key><false/>"
578   
579    if { [llength ${startupitem.logfile}] } {
580        puts ${plist} "<key>StandardOutPath</key><string>${startupitem.logfile}</string>"
581    }
582   
583    puts ${plist} "</dict>"
584    puts ${plist} "</plist>"
585
586    close ${plist}
587
588    # Make a symlink to the plist file
589    file mkdir "${destroot}/Library/${daemondest}"
590    ln -sf "${itemdir}/${plistname}" "${destroot}/Library/${daemondest}"
591   
592    # If launchd is not available, warn the user
593    set haveLaunchd ${portutil::autoconf::have_launchd}
594    if {![tbool haveLaunchd]} {
595        ui_msg "###########################################################"
596        ui_msg "# WARNING:"
597        ui_msg "# We're building a launchd startup item, but launchd wasn't"
598        ui_msg "# found by configure. Are you sure you didn't mess up your"
599        ui_msg "# ports.conf settings?"
600        ui_msg "###########################################################"
601    }
602   
603    # Emit some information for the user
604    ui_msg "###########################################################"
605    ui_msg "# A startup item has been generated that will aid in"
606    ui_msg "# starting ${name} with launchd. It is disabled"
607    ui_msg "# by default. Execute the following command to start it,"
608    ui_msg "# and to cause it to launch at startup:"
609    ui_msg "#"
610    ui_msg "# sudo launchctl load -w /Library/${daemondest}/${plistname}"
611    ui_msg "###########################################################"
612}
613
614proc portstartupitem::startupitem_create {args} {
615    global UI_PREFIX
616    global startupitem.type os.platform
617   
618    set startupitem.type [string tolower ${startupitem.type}]
619   
620    # Calculate a default value for startupitem.type
621    if {${startupitem.type} == "default" || ${startupitem.type} == ""} {
622        switch -exact ${os.platform} {
623            darwin {
624                set haveLaunchd ${portutil::autoconf::have_launchd}
625                if { [tbool haveLaunchd] } {
626                    set startupitem.type "launchd"
627                } else {
628                    set startupitem.type "systemstarter"
629                }
630            }
631            default {
632                set startupitem.type "rcng"
633            }
634        }
635    }
636
637    if { ${startupitem.type} == "none" } {
638        ui_msg "$UI_PREFIX [msgcat::mc "Skipping creation of control script"]"
639    } else {
640        ui_msg "$UI_PREFIX [msgcat::mc "Creating ${startupitem.type} control script"]"
641
642        switch -- ${startupitem.type} {
643            launchd         { startupitem_create_darwin_launchd }
644            systemstarter   { startupitem_create_darwin_systemstarter }
645            rcng            { startupitem_create_rcng }
646            default         { ui_error "$UI_PREFIX [msgcat::mc "Unrecognized startupitem type %s" ${startupitem.type}]" }
647        }
648    }
649}
Note: See TracBrowser for help on using the repository browser.