lilalo

changeset 70:6f5ad37fc8d9

Добавлен файл l3bashrc, который настраивает среду интерпретатора
и включает запись lilalo-скриптов.
Настройка разбита по функциям.

ПОКА ЧТО НЕ РАБОТАЕТ!
author devi
date Fri Feb 03 22:49:46 2006 +0200 (2006-02-03)
parents 1e1422588716
children d499fa3b2af1
files l3bashrc
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/l3bashrc	Fri Feb 03 22:49:46 2006 +0200
     1.3 @@ -0,0 +1,82 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +
     1.7 +_l3_start()
     1.8 +{
     1.9 +    L3_TTY=`tty` 
    1.10 +    proc_on_the_term=`w | grep "${L3_TTY##/dev/}" | awk '{print $8;}'`
    1.11 +    # freeBSD: 
    1.12 +    [ -n "$bsd" ] && \
    1.13 +    proc_on_the_term=`w | grep "${L3_TTY##/dev/tty}" | awk '{print $6;}'`
    1.14 +
    1.15 +    if [ -n "$proc_on_the_term" ] && echo $proc_on_the_term | grep -qv script
    1.16 +    then
    1.17 +        _l3_start_session
    1.18 +        _l3_run_script
    1.19 +    else
    1.20 +        _l3_env
    1.21 +        _l3_prompt
    1.22 +    fi
    1.23 +}
    1.24 +
    1.25 +_l3_env()
    1.26 +{
    1.27 +    true
    1.28 +}
    1.29 +
    1.30 +_l3_prompt()
    1.31 +{
    1.32 +    export PS1='\[`
    1.33 +    a="$?";
    1.34 +    HIDDEN=$([ "$a" = 0 ] || echo -n ^"$a")$(echo -n _${UID}_)$(echo -n _$$_)$(date\
    1.35 +        +"%j$(cat ${LMHOME}/lab 2>/dev/null) %H:%M:%S");
    1.36 +    echo $HIDDEN`\033[50D\033[K\][\u@\h:\W]\$ '
    1.37 +}
    1.38 +
    1.39 +_l3_start_session()
    1.40 +{
    1.41 +    L3_SESSION_ID=${L3_TTY##*/}-$$
    1.42 +    L3_HOME=~/.lilalo/
    1.43 +    mkdir -p $L3_HOME
    1.44 +
    1.45 +    uname -a | grep -qi bsd && bsd=yes
    1.46 +    parent=`cat /proc/$PPID/cmdline 2> /dev/null`
    1.47 +    system=`uname -rs`
    1.48 +    login_from=`who | grep "${tty##/dev/}" | awk '{print $6;}' | tr -d '()'`
    1.49 +    #[ -n "$bsd" ] && login_from="" #FIXME!
    1.50 +    start_time=`date +%s`
    1.51 +    hostname=`hostname -f 2> /dev/null`
    1.52 +    [ -n "$bsd" ] && hostname=`hostname`
    1.53 +
    1.54 +    cat <<INFO > $L3_HOME/$L3_SESSION_ID.info
    1.55 +<session>
    1.56 +    <local_session_id>$L3_SESSION_ID</local_session_id>
    1.57 +    <hostname>$hostname</hostname>
    1.58 +    <user>$USER</user>
    1.59 +    <uid>$UID</uid>
    1.60 +    <login_from>$login_from</login_from>
    1.61 +    <tty>$tty</tty>
    1.62 +    <system>$system</system>
    1.63 +    <parent>$parent</parent>
    1.64 +    <ppid>$PPID</ppid>
    1.65 +    <pid>$$</pid>
    1.66 +    <start_time>$start_time</start_time>
    1.67 +</session>
    1.68 +INFO
    1.69 +
    1.70 +    unset parent system login_from start_time hostname 
    1.71 +}
    1.72 +
    1.73 +_l3_run_script()
    1.74 +{
    1.75 +    uname -a | grep -qi bsd && bsd=yes
    1.76 +    flush="-f"                          #linux
    1.77 +    [ -n "$bsd" ] && flush="-t 0"       #freebsd
    1.78 +    exec script $flush -q $L3_HOME/${L3_SESSION_ID}.script
    1.79 +}
    1.80 +
    1.81 +_l3_close_session()
    1.82 +{
    1.83 +    history > $L3_HOME/$L3_SESSION_ID.info
    1.84 +}
    1.85 +