lilalo

annotate l3bashrc @ 72:0ffdebbccfce

Убрал парочку лишних переменных в коде l3-agent

Более подробно описаны поля в README

Заготовка для будущего приглашения в l3bashrc
author devi
date Sat Feb 04 00:54:17 2006 +0200 (2006-02-04)
parents d499fa3b2af1
children a10db759e587
rev   line source
devi@70 1 #!/bin/sh
devi@70 2
devi@70 3
devi@70 4 _l3_start()
devi@70 5 {
devi@70 6 L3_TTY=`tty`
devi@70 7 proc_on_the_term=`w | grep "${L3_TTY##/dev/}" | awk '{print $8;}'`
devi@70 8 # freeBSD:
devi@70 9 [ -n "$bsd" ] && \
devi@70 10 proc_on_the_term=`w | grep "${L3_TTY##/dev/tty}" | awk '{print $6;}'`
devi@70 11
devi@70 12 if [ -n "$proc_on_the_term" ] && echo $proc_on_the_term | grep -qv script
devi@70 13 then
devi@70 14 _l3_start_session
devi@70 15 _l3_run_script
devi@70 16 else
devi@70 17 _l3_env
devi@70 18 _l3_prompt
devi@70 19 fi
devi@70 20 }
devi@70 21
devi@70 22 _l3_env()
devi@70 23 {
devi@71 24 trap _l3_close_session 2
devi@71 25 trap _l3_close_session EXIT
devi@70 26 true
devi@70 27 }
devi@70 28
devi@70 29 _l3_prompt()
devi@70 30 {
devi@72 31 #export PS1='\[v2_$(date +%s)_$?_$PWD_\!_\033[1024D\033[K\][\u@\h:\W]\$ '
devi@70 32 export PS1='\[`
devi@70 33 a="$?";
devi@70 34 HIDDEN=$([ "$a" = 0 ] || echo -n ^"$a")$(echo -n _${UID}_)$(echo -n _$$_)$(date\
devi@70 35 +"%j$(cat ${LMHOME}/lab 2>/dev/null) %H:%M:%S");
devi@70 36 echo $HIDDEN`\033[50D\033[K\][\u@\h:\W]\$ '
devi@70 37 }
devi@70 38
devi@70 39 _l3_start_session()
devi@70 40 {
devi@71 41 export L3_SESSION_ID=${L3_TTY##*/}-$$
devi@71 42 export L3_HOME=~/.lilalo/
devi@70 43 mkdir -p $L3_HOME
devi@70 44
devi@70 45 uname -a | grep -qi bsd && bsd=yes
devi@70 46 parent=`cat /proc/$PPID/cmdline 2> /dev/null`
devi@70 47 system=`uname -rs`
devi@70 48 login_from=`who | grep "${tty##/dev/}" | awk '{print $6;}' | tr -d '()'`
devi@70 49 #[ -n "$bsd" ] && login_from="" #FIXME!
devi@70 50 start_time=`date +%s`
devi@70 51 hostname=`hostname -f 2> /dev/null`
devi@70 52 [ -n "$bsd" ] && hostname=`hostname`
devi@70 53
devi@70 54 cat <<INFO > $L3_HOME/$L3_SESSION_ID.info
devi@70 55 <session>
devi@70 56 <local_session_id>$L3_SESSION_ID</local_session_id>
devi@70 57 <hostname>$hostname</hostname>
devi@70 58 <user>$USER</user>
devi@70 59 <uid>$UID</uid>
devi@70 60 <login_from>$login_from</login_from>
devi@70 61 <tty>$tty</tty>
devi@70 62 <system>$system</system>
devi@70 63 <parent>$parent</parent>
devi@70 64 <ppid>$PPID</ppid>
devi@70 65 <pid>$$</pid>
devi@70 66 <start_time>$start_time</start_time>
devi@70 67 </session>
devi@70 68 INFO
devi@70 69
devi@70 70 unset parent system login_from start_time hostname
devi@70 71 }
devi@70 72
devi@70 73 _l3_run_script()
devi@70 74 {
devi@70 75 uname -a | grep -qi bsd && bsd=yes
devi@70 76 flush="-f" #linux
devi@70 77 [ -n "$bsd" ] && flush="-t 0" #freebsd
devi@70 78 exec script $flush -q $L3_HOME/${L3_SESSION_ID}.script
devi@70 79 }
devi@70 80
devi@70 81 _l3_close_session()
devi@70 82 {
devi@71 83 (
devi@71 84 echo '<history>'
devi@71 85 history | sed 's/&/\&amp;/; s/</\&lt;/g; s/>/\&gt;/g'
devi@71 86 echo '</history>'
devi@71 87 ) >> $L3_HOME/$L3_SESSION_ID.info
devi@70 88 }
devi@70 89