lilalo
changeset 79:44973d76ba4d
Подправлен скрипт l3bashrc.
Теперь определение запущен ли скрипт на текущем терминале или нет,
выполняется через PPID
Идентификатор сессии изменён.
Теперь это просто 8байтоное случайное число + время начала сессии.
l3scripts:
Вместо процедуры инсталляции lm-install
мы теперь просто копируем l3bashrc в lilalo и всё
Теперь определение запущен ли скрипт на текущем терминале или нет,
выполняется через 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 |
files | l3bashrc l3config.pm l3scripts |
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()
2.1 --- a/l3config.pm Sun Feb 19 14:36:33 2006 +0200 2.2 +++ b/l3config.pm Sun Feb 19 16:02:42 2006 +0200 2.3 @@ -81,7 +81,7 @@ 2.4 "detach" => "yes", 2.5 "agent_pidfile" => "$ENV{HOME}/.lilalo/l3-agent.pid", 2.6 2.7 - "backend_address" => "192.168.18.254", 2.8 + "backend_address" => "192.168.15.254", 2.9 "backend_port" => "18030", 2.10 "backend_pidfile" => "/tmp/l3-backend.pid", 2.11 "backend_datafile" => "/var/lilalo/lablogs-xml/backend.xml", 2.12 @@ -124,7 +124,7 @@ 2.13 "sshkey" => "$ENV{HOME}/.ssh/id_dsa.pub", 2.14 "lmssh" => "./lm-ssh", 2.15 "lminstall" => "./lm-install", 2.16 - "ssh_user" => "root", 2.17 + "ssh_user" => "r", 2.18 2.19 "l3scripts" => "l3scripts", 2.20
3.1 --- a/l3scripts Sun Feb 19 14:36:33 2006 +0200 3.2 +++ b/l3scripts Sun Feb 19 16:02:42 2006 +0200 3.3 @@ -3,12 +3,17 @@ 3.4 cat $sshkey | $lmssh $ssh_user@$host /bin/sh -c '"cat >>~/.ssh/authorized_keys; chmod 600 ~/.ssh/authorized_keys"' 3.5 3.6 ###install-lm 3.7 -cat $lminstall | ssh $ssh_user@$host /bin/sh -s $dirs 3.8 +#cat $lminstall | ssh $ssh_user@$host /bin/sh -s $dirs 3.9 scp l3config.pm l3-agent $ssh_user@$host:/usr/local/bin 3.10 +for i in $dirs 3.11 +do 3.12 + ssh $ssh_user@$host mkdir -p ${i}/.lilalo/ 3.13 + scp l3bashrc $ssh_user@$host:${i}/.lilalo/ 3.14 +done 3.15 3.16 ###install-pm 3.17 scp PM/* $ssh_user@$host:/tmp 3.18 -ssh $ssh_user@$host 'cd /tmp; tar xfz Term-VT102*.gz; cd Term-VT102*[^z]; perl Makefile.PL; make ; make install' 3.19 +#ssh $ssh_user@$host 'cd /tmp; tar xfz Term-VT102*.gz; cd Term-VT102*[^z]; perl Makefile.PL; make ; make install' 3.20 ssh $ssh_user@$host 'cd /tmp; tar xfz Text-Iconv*.gz; cd Text-Iconv*[^z]; perl Makefile.PL; make ; make install' 3.21 3.22 ###copy-lablogs