]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
- utility functions for upstart event-based boot
authorJacek Konieczny <jajcus@pld-linux.org>
Thu, 6 May 2010 09:31:17 +0000 (09:31 +0000)
committerJacek Konieczny <jajcus@pld-linux.org>
Thu, 6 May 2010 09:31:17 +0000 (09:31 +0000)
svn-id: @11380

rc.d/init.d/functions

index b658e3b8d0400ac2be85664e73b713f5ae71a66c..bdb395a28c932b0bb8df073d92289e0ad798fd67 100644 (file)
@@ -1078,6 +1078,58 @@ rc_gettext_init() {
        fi
 }
 
+use_upstart () {
+       # True when upstart-event-based boot should be used
+       is_yes "$USE_UPSTART" && return 0
+       is_no "$USE_UPSTART" && return 1
+       if [ ! -x /sbin/initctl ] ; then
+               USE_UPSTART="no"
+               return 1
+       fi
+       local cmdline=$(cat /proc/cmdline)
+       if strstr "$cmdline" "pld.no-upstart" ; then
+               USE_UPSTART="no"
+               return 1
+       else
+               USE_UPSTART="yes"
+               return 0
+       fi
+}
+
+emit () {
+       # emit upstart signal
+       # only when 'upstart' boot is enabled
+       use_upstart || return 0
+       /sbin/initctl emit "$@"
+}
+
+_check_init () {
+       # check if the init script can be run this way
+       # make sure the old-styl init scripts are not
+       # used
+       if ! use_upstart ; then
+               return 0
+       fi      
+       if is_yes $CHECK_INIT_OVERRIDE ; then
+               return 0
+       fi
+       local name=$(basename "$1")
+       local command=$(basename "$2")
+       if [ ! -f /etc/init/${name}.conf ] ; then
+               return 0
+       fi
+       case "$command" in
+               start|stop|status)
+                       echo "Use 'initctl $command $name' to control this service"
+                       exit 1
+                       ;;
+               *)
+                       ;;
+       esac
+       return 0
+}
+alias check_init='_check_init $0 "$@"'
+
 rc_gettext_init
 rc_cache_init
 
This page took 0.104059 seconds and 4 git commands to generate.