Changeset 978


Ignore:
Timestamp:
Feb 18, 2008, 2:30:56 PM (10 years ago)
Author:
jrollins
Message:

Update system to use new runit update-service script (see changelog).
Unfortunate fixing of manpage newlines.

Location:
trunk/cereal
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/cereal/debian/changelog

    r944 r978  
     1cereal (0.18-1) unstable; urgency=low
     2
     3  * use new runit command "update-service" (Closes: #466380)
     4  * changed terminology of runit-controller sessions from "linked" to
     5    "registered".
     6
     7 -- Jameson Rollins <jrollins@fifthhorseman.net>  Mon, 18 Feb 2008 14:25:28 -0500
     8
    19cereal (0.17-1) unstable; urgency=low
    210
  • trunk/cereal/fs/etc/cereal/cereal-admin.conf

    r545 r978  
    11# /etc/cereal/cereal-admin.conf
    22
    3 # If set to 'yes', create sessions with world accessbile supervise directory.
    4 # This lets all users test the running state of linked sessions.  However, this
    5 # may be a security vulnerability on systems that do not respect FIFO file
    6 # permissions.
     3# If set to 'yes', create sessions with world accessbile supervise
     4# directory.  This lets all users test the running state of registered
     5# sessions.  However, this may be a security vulnerability on systems
     6# that do not respect FIFO file permissions.
    77SUPERVISE_WORLD_ACCESSIBLE=yes
  • trunk/cereal/fs/usr/sbin/cereal-admin

    r669 r978  
    114114start_session() {
    115115    local SESSION="$1"
    116     ln -s "$SESSIONDIR/$SESSION" "$SERVICE.$SESSION"
     116    update-service --add "$SESSIONDIR/$SESSION" "cereal.$SESSION"
    117117    log_write "$SESSION" "session '$SESSION' started."
    118118}
     
    133133        if ! is_session "$SESSION" ; then
    134134            error "Session '$SESSION' not found." 1
    135         elif is_linked "$SESSION" ; then
    136             error "Session '$SESSION' is already running." 1
    137         elif [ ! -w "$SERVICEDIR" ] ; then
    138             error "You do not have permission to start session '$SESSION'." 2
     135        elif update-service --check "cereal.$SESSION" ; then
     136            error "Session '$SESSION' is already registered." 1
    139137        elif ! chpst -e "$SESSIONDIR/$SESSION/env/" bash -c start_check ; then
    140138            error "Session '$SESSION' not properly configured." 2
     
    153151    local SESSION="$1"
    154152    log_write "$SESSION" "stopping session '$SESSION'..."
    155     sv exit "$SERVICE.$SESSION"
    156     rm "$SERVICE.$SESSION"
     153    update-service --remove "$SESSIONDIR/$SESSION" "cereal.$SESSION"
    157154}
    158155export -f stop_session
     
    172169        if ! is_session "$SESSION" ; then
    173170            error "Session '$SESSION' not found." 1
    174         elif ! is_linked "$SESSION" ; then
    175             error "Session '$SESSION' not linked." 1
     171        elif ! update-service --check "cereal.$SESSION" ; then
     172            error "Session '$SESSION' not registered." 1
    176173        elif ! is_controllable "$SESSION" ; then
    177174            error "You do not have permission to stop session '$SESSION'." 2
     
    190187    local SESSION="$1"
    191188    log_write "$SESSION" "restarting session '$SESSION'..."
    192     sv restart "$SERVICE.$SESSION"
     189    sv restart "cereal.$SESSION"
    193190}
    194191export -f restart_session
     
    210207    for SESSION in $SESSIONS ; do
    211208        if ! is_session "$SESSION" ; then
    212             echo "Session '$SESSION' not found."
    213         elif ! is_linked "$SESSION" ; then
     209            error "Session '$SESSION' not found." 1
     210        elif ! update-service --check "cereal.$SESSION" ; then
    214211            start "$SESSION"
    215212        elif ! is_controllable "$SESSION" ; then
     
    247244        elif [ ! -w "$SESSIONDIR/$SESSION" ] ; then
    248245            error "You do not have permission to destroy session '$SESSION'." 2
    249         elif is_linked "$SESSION" ; then
    250             echo "Session '$SESSION' is currently linked."
    251             read -p "Really stop and destroy session? [Y|n]: " OK
    252             if [ -z "$OK" -o "${OK/y/Y}" = 'Y' ] ; then
     246        elif update-service --check "cereal.$SESSION" ; then
     247            echo "Session '$SESSION' is currently registered."
     248            read -p "Really stop and destroy session? [Y|n]: " OK; OK=${OK:=Y}
     249            if [ "${OK/y/Y}" = 'Y' ] ; then
    253250                if stop_session "$SESSION" ; then
    254251                    if destroy_session "$SESSION" ; then
     
    264261            fi
    265262        else
    266             read -p "Really destroy session '$SESSION'? [Y|n]: " OK
    267             if [ -z "$OK" -o "${OK/y/Y}" = 'Y' ] ; then
     263            read -p "Really destroy session '$SESSION'? [Y|n]: " OK; OK=${OK:=Y}
     264            if [ "${OK/y/Y}" = 'Y' ] ; then
    268265                if destroy_session "$SESSION" ; then
    269266                    echo "Destroyed session '$SESSION'."
  • trunk/cereal/fs/usr/share/cereal/common

    r669 r978  
    1313export ETC="/etc/cereal"
    1414export SESSIONDIR="/var/lib/cereal/sessions"
    15 export SERVICEDIR="/var/service"
    16 export SERVICE="$SERVICEDIR/cereal"
    1715export ERR=0
    1816##################################################
     
    7876export -f is_session
    7977
    80 # is_linked SESSION
    81 is_linked() {
    82     test -L "$SERVICE.$1"
    83 }
    84 export -f is_linked
    85 
    8678# is_running SESSION
    8779is_running() {
    88     local SD="$SERVICE.$1"
    89     # if session is linked in service dir...
    90     if [ -L "$SD" ] ; then
    91         # return 2 if supervise/stat says that the service is *not* running
    92         if [ -r "$SD/supervise/stat" ] && ! grep -q run "$SD/supervise/stat" ; then
    93             return 2
     80    local SESSION="$1"
     81    if update-service --check "cereal.$SESSION" ; then
     82        if sv status "cereal.$SESSION" > /dev/null ; then
     83            if sv status "cereal.$SESSION" | grep -q "^run:" ; then
     84                # return 0 if sv says the service is running
     85                return 0
     86            else
     87                # return 2 if sv says the service is *not* running
     88                return 2
     89            fi
     90        else
     91            # return 0 if we can't read the status, in which case we will assume
     92            # it is running if it is registered
     93            return 0
    9494        fi
    95         # otherwise return 0 since either it is running, or we can't tell
    96         # whether the service is actually running or not, so assume that it is
    97         # if it's linked.
    98         return 0
    99     else
    100         # return 1 if it's not linked
     95    else
     96        # return 1 if it's not registered
    10197        return 1
    10298    fi
     
    107103# is_controllable SESSION
    108104is_controllable() {
    109     test -w "$SERVICE.$1/supervise/control"
     105    test -w "$SESSIONDIR/$1/supervise/control"
     106    # should this instead be something like this?:
     107    #sv ignore "cereal.$SESSION"
    110108}
    111109export -f is_controllable
     
    146144    USER=${2:-"$USER"}
    147145
    148     # set state flag ('+' linked (0), '-' stopped (1), '!' linked but stopped(2))
     146    # set state flag
    149147    # last flag works only for users that can read supervise/stat
    150148    is_running "$SESSION"
    151149    case $? in
    152150        0)
    153             SFLAG='+'
     151            SFLAG='+' # registered
    154152            ;;
    155153        1)
    156             SFLAG='-'
     154            SFLAG='-' # stopped
    157155            ;;
    158156        2)
    159             SFLAG='!'
     157            SFLAG='!' # registered but stopped
    160158            ;;
    161159    esac
  • trunk/cereal/fs/usr/share/man/man1/cereal.1

    r651 r978  
    1212.TP
    1313.B attach SESSION
    14 Attach to (take control of) cereal session SESSION.  This puts the user into a
    15 cereal console, provided by a command-restricted screen session.  To detach from
    16 an attached session, use "C-\\ d".  For help on other available commands, use
    17 "C-\\ ?".  Cereal uses a limited instance of screen to provide the console.  See
    18 \fBscreen\fP(1) for more info on the available commands.  `a' may be used in
    19 place of `attach'.
     14Attach to (take control of) cereal session SESSION.  This puts the
     15user into a cereal console, provided by a command-restricted screen
     16session.  To detach from an attached session, use "C-\\ d".  For help
     17on other available commands, use "C-\\ ?".  Cereal uses a limited
     18instance of screen to provide the console.  See \fBscreen\fP(1) for
     19more info on the available commands.  `a' may be used in place of
     20`attach'.
    2021.TP
    2122.B follow [options] SESSION
    22 Follow (watch, without being able to intervene) a cereal session SESSION.  The
    23 options are:  -c [--cat] to cat log instead of follow; -p [--path] to output
    24 just the path to the log file and exit.  `f' may be used in place of `follow'.
     23Follow (watch, without being able to intervene) a cereal session
     24SESSION.  The options are: -c [--cat] to cat log instead of follow; -p
     25[--path] to output just the path to the log file and exit.  `f' may be
     26used in place of `follow'.
    2527.TP
    2628.B list [SESSION]...
    27 List session(s).  With no arguments, will list all sessions.  The leading three
    28 characters in the list indicate:
    29 whether the session is running (+) or not (-) or in some unusual state (!),
    30 whether the user can attach to the session (a) or not (-),
    31 whether the user can follow the session (f) or not (-).
    32 `l' may be used in place of `list'.
     29List session(s).  With no arguments, will list all sessions.  The
     30leading three characters in the list indicate: whether the session is
     31running (+) or not (-) or in some unusual state (!), whether the user
     32can attach to the session (a) or not (-), whether the user can follow
     33the session (f) or not (-).  `l' may be used in place of `list'.
    3334.TP
    3435.B help
    35 Output a brief usage summary.  `h' or `?' may be used in place of `help'.
     36Output a brief usage summary.  `h' or `?' may be used in place of
     37`help'.
    3638.PD
    3739.SH EXIT STATUS
     
    4951Copyright \(co 2007 Jameson Rollins and Daniel Kahn Gillmor
    5052.br
    51 This is free software.  You may redistribute copies of it under the terms of
    52 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
    53 There is NO WARRANTY, to the extent permitted by law.
     53This is free software.  You may redistribute copies of it under the
     54terms of the GNU General Public License
     55<http://www.gnu.org/licenses/gpl.html>.  There is NO WARRANTY, to the
     56extent permitted by law.
    5457.SH "SEE ALSO"
    5558.BR screen (1),
  • trunk/cereal/fs/usr/share/man/man8/cereal-admin.8

    r653 r978  
    55.B cereal-admin \fIcommand\fP [\fIargs\fP]
    66.SH DESCRIPTION
    7 \fBcereal-admin\fP is a program to administer cereal sessions.  A cereal session
    8 is a special (restricted) screen(1) session attached to a serial terminal.  Each
    9 cereal session is owned by a particular user (USER) who is allowed to "attach"
    10 to the cereal screen session and interact with the specified serial terminal via
    11 screen.  Each cereal session is also associated with a particular log group
    12 (LOGGROUP) whose members are allowed to "follow" the logs of the session.
     7\fBcereal-admin\fP is a program to administer cereal sessions.  A
     8cereal session is a special (restricted) screen(1) session attached to
     9a serial terminal.  Each cereal session is owned by a particular user
     10(USER) who is allowed to "attach" to the cereal screen session and
     11interact with the specified serial terminal via screen.  Each cereal
     12session is also associated with a particular log group (LOGGROUP)
     13whose members are allowed to "follow" the logs of the session.
    1314.PP
    14 Cereal was designed to monitor serial lines connected to the serial consoles of
    15 remote machines.  The cereal system is outlined at:
     15Cereal was designed to monitor serial lines connected to the serial
     16consoles of remote machines.  The cereal system is outlined at:
    1617.PP
    1718   http://cmrg.fifthhorseman.net/wiki/cereal
     
    2122.TP
    2223.B create SESSION TTY BAUD USER LOGGROUP
    23 Create a new session named SESSION on tty TTY, with baud rate BAUD.  USER is the
    24 user that will own the session, and LOGGROUP is the group that will be able to
    25 follow the session non-interactively (ie. read the logs).  Once created, the
    26 session will be in a "stopped" state.  `c' may be used in place of `create'.
     24Create a new session named SESSION on tty TTY, with baud rate BAUD.
     25USER is the user that will own the session, and LOGGROUP is the group
     26that will be able to follow the session non-interactively (ie. read
     27the logs).  Once created, the session will be in a "stopped" state.
     28`c' may be used in place of `create'.
    2729.TP
    2830.B start [options] SESSION [SESSION]...
    29 Start session(s).  For each session specified, the session directory is linked
    30 into the runsvdir directory.  The screen session will be attached to the serial
    31 terminal and logging of the terminal will begin.  `s' may be used in place of
    32 `start'.  options: -a (--all) to enable all sessions.
     31Start session(s).  For each session specified, the session directory
     32is registered in the runsvdir directory.  The screen session will be
     33attached to the serial terminal and logging of the terminal will
     34begin.  `s' may be used in place of `start'.  options: -a (--all) to
     35enable all sessions.
    3336.TP
    3437.B stop [options] SESSION [SESSION]...
    35 Stop session(s).  This kills the screen session attached to the serial terminal
    36 by sending it an "exit" signal, and the session directory is unlinked from
    37 runsvdir directory.  `k' may be used in place of `stop'.  options: -a (--all) to
    38 disable all sessions.
     38Stop session(s).  This kills the screen session attached to the serial
     39terminal by sending it an "exit" signal, and the session directory is
     40unregistered from runsvdir directory.  `k' may be used in place of
     41`stop'.  options: -a (--all) to disable all sessions.
    3942.TP
    4043.B restart [options] SESSION [SESSION]...
    41 Restart session(s).  This sends running sessions a "restart" signal, and starts
    42 session that are not running.  This can be used when changes have been made to
    43 the screenrc, for instance.  `r' may be used in place of `restart'.  options: -a
    44 (--all) to disable all sessions, -r (--running) to restart just the currently
    45 running sessions.
     44Restart session(s).  This sends running sessions a "restart" signal,
     45and starts session that are not running.  This can be used when
     46changes have been made to the screenrc, for instance.  `r' may be used
     47in place of `restart'.  options: -a (--all) to disable all sessions,
     48-r (--running) to restart just the currently running sessions.
    4649.TP
    4750.B destroy [options] SESSION [SESSION]...
    48 Destroy session(s) entirely.  This will destroy the session directory, including
    49 all history of the session and the logs.  `d' may be used in place of `destroy'.
    50 options: -a (--all) to remove all sessions.
     51Destroy session(s) entirely.  This will destroy the session directory,
     52including all history of the session and the logs.  `d' may be used in
     53place of `destroy'.  options: -a (--all) to remove all sessions.
    5154.TP
    5255.B list [SESSION]...
    53 List session(s).  With no arguments will list all sessions.  The leading three
    54 characters in the list indicate:
    55 whether the session is running (+) or not (-) or in some unusual state (!),
    56 whether the user can attach to the session (a) or not (-),
    57 whether the user can follow the session (f) or not (-).
    58 `l' may be used in place of `list'.
     56List session(s).  With no arguments will list all sessions.  The
     57leading three characters in the list indicate: whether the session is
     58running (+) or not (-) or in some unusual state (!), whether the user
     59can attach to the session (a) or not (-), whether the user can follow
     60the session (f) or not (-).  `l' may be used in place of `list'.
    5961.TP
    6062.B help
    61 Output a brief usage summary.  `h' or `?' may be used in place of `help'.
     63Output a brief usage summary.  `h' or `?' may be used in place of
     64`help'.
    6265.PD
    6366.SH LOGS
     
    7578.TP
    7679/etc/cereal/cereal-admin.conf
    77 Configuration file to set parameters for session creation and management.
     80Configuration file to set parameters for session creation and
     81management.
    7882.TP
    7983/var/lib/cereal/sessions/$SESSION/screenrc
    80 Special screenrc file for session SESSION.  The presence of this file overrides
    81 the default screenrc file /etc/cereal/screenrc.
     84Special screenrc file for session SESSION.  The presence of this file
     85overrides the default screenrc file /etc/cereal/screenrc.
    8286.PD
    8387.SH EXIT STATUS
     
    9599Copyright \(co 2007 Jameson Rollins and Daniel Kahn Gillmor
    96100.br
    97 This is free software.  You may redistribute copies of it under the terms of
    98 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
    99 There is NO WARRANTY, to the extent permitted by law.
     101This is free software.  You may redistribute copies of it under the
     102terms of the GNU General Public License
     103<http://www.gnu.org/licenses/gpl.html>.  There is NO WARRANTY, to the
     104extent permitted by law.
    100105.SH "SEE ALSO"
    101106.BR cereal (1),
Note: See TracChangeset for help on using the changeset viewer.