Changeset 555


Ignore:
Timestamp:
Sep 6, 2007 2:01:37 PM (6 years ago)
Author:
jrollins
Message:

cereal: small update to is_running function to provide better return codes with
more information about running state.

Location:
trunk/cereal
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/cereal/debian/changelog

    r553 r555  
     1cereal (0.13-1) unstable; urgency=low 
     2 
     3  * update of is_running function with better tests/return 
     4 
     5 -- Jameson Rollins <jrollins@fifthhorseman.net>  Thu, 06 Sep 2007 14:00:12 -0400 
     6 
    17cereal (0.12-1) unstable; urgency=high 
    28 
  • trunk/cereal/fs/usr/bin/cereal

    r553 r555  
    4343        failure "Session '$SESSION' not found. 
    4444Type 'cereal list' to list sessions." 
    45     elif ! is_linked "$SESSION" ; then 
    46         failure "Session '$SESSION' does not appear to be running." 
     45    elif ! is_running "$SESSION" ; then 
     46        failure "Session '$SESSION' not running." 
    4747    elif ! can_attach "$SESSION" "$USER" ; then 
    4848        failure "You are not allowed to attach to session '$SESSION'." 
  • trunk/cereal/fs/usr/sbin/cereal-admin

    r551 r555  
    140140            continue 
    141141        elif ! chpst -e "$SESSIONDIR/$SESSION/env/" sh -c start_check ; then 
    142             echo "Session '$SESSION' no properly configured." 
     142            echo "Session '$SESSION' not properly configured." 
    143143            ((ERR++)) 
    144144            continue 
     
    179179            continue 
    180180        elif ! is_linked "$SESSION" ; then 
    181             echo "Session '$SESSION' not running." 
     181            echo "Session '$SESSION' not linked." 
    182182            ((ERR++)) 
    183183            continue 
  • trunk/cereal/fs/usr/share/cereal/common

    r551 r555  
    7979# is_running SESSION 
    8080is_running() { 
    81     grep -q run "$SERVICE.$1/supervise/stat" 
     81    local SD="$SERVICE.$1" 
     82    # if session is linked in service dir... 
     83    if [ -L "$SD" ] ; then 
     84        # return 2 if supervise/stat says that the service is *not* running 
     85        if [ -r "$SD/supervise/stat" ] && ! grep -q run "$SD/supervise/stat" ; then 
     86            return 2 
     87        fi 
     88        # otherwise return 0 since either it is running, or we can't tell 
     89        # whether the service is actually running or not, so assume that it is 
     90        # if it's linked. 
     91        return 0 
     92    else 
     93        # return 1 if it's not linked 
     94        return 1 
     95    fi 
    8296} 
    8397export -f is_running 
     
    119133    is_session "$SESSION" || failure "Session '$SESSION' not found." 
    120134 
    121     # set state flag ('+' linked, '-' stopped, '!' linked but stopped) 
    122     # (last flag works only for users that can read supervise/stat) 
     135    # set state flag ('+' linked (0), '-' stopped (1), '!' linked but stopped(2)) 
     136    # last flag works only for users that can read supervise/stat 
    123137    SFLAG='-' 
    124     if is_linked "$SESSION" ; then 
    125         SFLAG='+' 
    126         if [ -r "$SERVICE.$SESSION/supervise/stat" ] && ! is_running "$SESSION" ; then 
     138    is_running "$SESSION" 
     139    case $? in 
     140        0) 
     141            SFLAG='+' 
     142            ;; 
     143        1) 
     144            SFLAG='-' 
     145            ;; 
     146        2) 
    127147            SFLAG='!' 
    128         fi 
    129     fi 
     148            ;; 
     149    esac 
    130150    # set attach flag 
    131151    AFLAG='-' 
Note: See TracChangeset for help on using the changeset viewer.