lilalo

diff l3bashrc @ 79:44973d76ba4d

Подправлен скрипт l3bashrc.
Теперь определение запущен ли скрипт на текущем терминале или нет,
выполняется через PPID
Идентификатор сессии изменён.
Теперь это просто 8байтоное случайное число + время начала сессии.

l3scripts:
Вместо процедуры инсталляции lm-install
мы теперь просто копируем l3bashrc в lilalo и всё
author devi
date Sun Feb 19 16:02:42 2006 +0200 (2006-02-19)
parents 147fb109c012
children d28dda8ea18f
line diff
     1.1 --- a/l3bashrc	Sun Feb 19 14:36:33 2006 +0200
     1.2 +++ b/l3bashrc	Sun Feb 19 16:02:42 2006 +0200
     1.3 @@ -5,7 +5,6 @@
     1.4  #
     1.5  #       L3_SESSION_ID   - uniq id of the LiLaLo-session
     1.6  #       L3_PARENT_TTY   - name of tty on which script is running
     1.7 -#       L3_TTY          - current tty
     1.8  #       PS1             - intercative shell prompt in which LiLaLo hides
     1.9  #                         various information about the command
    1.10  #       L3_TAMPERED_EDITORS - list of editors which are tampered with functions
    1.11 @@ -18,43 +17,52 @@
    1.12  
    1.13  _l3_start()
    1.14  {
    1.15 -    if _l3_is_not_running_here
    1.16 +    if _l3_is_running_here
    1.17      then
    1.18 -        _l3_start_session
    1.19 -        _l3_run_script
    1.20 -    else
    1.21          _l3_env
    1.22          _l3_init_prompt
    1.23           l3_fix_prompt
    1.24          _l3_tamper_editors
    1.25          _l3_tamper_commands
    1.26          _l3_unset_internal
    1.27 +    else
    1.28 +        _l3_start_session
    1.29 +        _l3_run_script
    1.30      fi
    1.31  }
    1.32  
    1.33  # ===================== STAGE 1 ============================
    1.34  
    1.35 -_l3_is_not_running_here()
    1.36 +_l3_is_running_here()
    1.37  {
    1.38 +	ps waux | awk '{print $2" "$11 }' | grep -q ^$PPID" "script 
    1.39 +	return $?
    1.40 +
    1.41 +# Check if ^^^^ run on Linux
    1.42 +# and del  vvvv this if it does
    1.43 +
    1.44      export L3_TTY=`/usr/bin/tty` 
    1.45 +    uname -a | grep -qi bsd && bsd=yes
    1.46      proc_on_the_term=`w | grep "${L3_TTY##/dev/}" | awk '{print $8;}'`
    1.47      # freeBSD: 
    1.48      [ -n "$bsd" ] && \
    1.49      proc_on_the_term=`w | grep "${L3_TTY##/dev/tty}" | awk '{print $6;}'`
    1.50  
    1.51 -    [ -n "$proc_on_the_term" ] && echo $proc_on_the_term | grep -qv script
    1.52 +    [ -n "$proc_on_the_term" ] && echo $proc_on_the_term | grep -q script
    1.53  }
    1.54  
    1.55  _l3_start_session()
    1.56  {
    1.57 -    export L3_SESSION_ID=${L3_TTY##*/}-$$
    1.58 +    export L3_SESSION_ID=${RANDOM}${RANDOM}${RANDOM}${RANDOM}-`date +%s`
    1.59      export L3_HOME=~/.lilalo/
    1.60      mkdir -p $L3_HOME
    1.61  
    1.62 +    tty=`/usr/bin/tty`
    1.63      uname -a | grep -qi bsd && bsd=yes
    1.64      parent=`cat /proc/$PPID/cmdline 2> /dev/null`
    1.65 +    [ -z "$parent" ] && parent="`ps waux | awk '{if ($2 == '$PPID') print $11; }'`"
    1.66      system=`uname -rs`
    1.67 -    login_from=`who | grep "${L3_TTY##/dev/}" | awk '{print $6;}' | tr -d '()'`
    1.68 +    login_from=`who | grep "${tty##/dev/}" | awk '{print $6;}' | tr -d '()'`
    1.69      #[ -n "$bsd" ] && login_from="" #FIXME!
    1.70      start_time=`date +%s`
    1.71      hostname=`hostname -f 2> /dev/null`
    1.72 @@ -67,7 +75,7 @@
    1.73      <user>$USER</user>
    1.74      <uid>$UID</uid>
    1.75      <login_from>$login_from</login_from>
    1.76 -    <tty>$L3_TTY</tty>
    1.77 +    <tty>$tty</tty>
    1.78      <system>$system</system>
    1.79      <parent>$parent</parent>
    1.80      <ppid>$PPID</ppid>
    1.81 @@ -77,7 +85,7 @@
    1.82  </session>
    1.83  INFO
    1.84  
    1.85 -    unset parent system login_from start_time hostname 
    1.86 +    unset parent system login_from start_time hostname tty
    1.87  }
    1.88  
    1.89  _l3_run_script()