lilalo

changeset 106:53b890d1ae90

small changes
author devi
date Fri Aug 04 17:41:31 2006 +0300 (2006-08-04)
parents 09ed722f2759
children 54fbf2041159
files install l3-backend l3-cgi-lite l3-frontend l3.css l3config.pm
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/install	Fri Aug 04 17:41:31 2006 +0300
     1.3 @@ -0,0 +1,148 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +lilalo_rc=.l3rc
     1.7 +lilalo_home=.lilalo
     1.8 +url_lilalo="http://xgu.ru/lilalo"
     1.9 +url_l3bashrc="${url_lilalo}"/l3bashrc
    1.10 +url_l3agent="${url_lilalo}"/l3-agent
    1.11 +url_l3config="${url_lilalo}"/l3config.pm
    1.12 +url_perl_modules=${url_lilalo}/
    1.13 +perl_modules="Term-VT102 Text-Iconv"
    1.14 +
    1.15 +wget=wget
    1.16 +uname -a | grep -qi bsd && wget=fetch
    1.17 +
    1.18 +normC='\033[0;39m'
    1.19 +whiteC='\033[1;37m'
    1.20 +redC='\033[0;31m'
    1.21 +greenC='\033[0;32m'
    1.22 +
    1.23 +hostname=`hostname`
    1.24 +uname -a | grep -qi freebsd || hostname=`hostname -f`
    1.25 +
    1.26 +
    1.27 +# Ask this variables:
    1.28 +
    1.29 +lilalo_user="devi"
    1.30 +lab="lilalo-installation"
    1.31 +install_l3bashrc_for_this_users="root ak devi"
    1.32 +lilalo_context="/users/${lilalo_user}/${lab}/${hostname}"
    1.33 +
    1.34 +
    1.35 +step()
    1.36 +{
    1.37 +
    1.38 +    msg="$1"
    1.39 +    shift
    1.40 +    printf "${whiteC}""$msg""...${normC}\n"
    1.41 +#    eval "$@" 2>&1 | sed 's/^/|\ \ \ /' && printf "Ok\n" || printf "Failed\n"
    1.42 +    eval "$@" 2>&1 > log 2>&1 && \
    1.43 +    {
    1.44 +          cat log | sed 's/^/|\ \ \ /'
    1.45 +          printf "${greenC}""Ok\n""${normC}" 
    1.46 +    } || \
    1.47 +    {
    1.48 +        cat log | sed 's/^/|\ \ \ /'
    1.49 +        printf "${redC}""Failed\n""${normC}"
    1.50 +    }
    1.51 +}
    1.52 +
    1.53 +get_user_home()
    1.54 +{
    1.55 +    uname -a | grep -qi freebsd && pw user show "$@"| awk -F: '{print $9}' || getent passwd "$@"| awk -F: '{print $6}'
    1.56 +}
    1.57 +
    1.58 +install_to_users_homes()
    1.59 +{
    1.60 +    . l3bashrc
    1.61 +    users="$@"
    1.62 +    set -x
    1.63 +    for user in $users
    1.64 +    do
    1.65 +        user_home=`get_user_home "$user"`
    1.66 +        mkdir -p ${user_home}/${lilalo_home}
    1.67 +        cp l3config.pm /usr/local/bin
    1.68 +        cp l3-agent /usr/local/bin
    1.69 +        chmod 755 /usr/local/bin/l3-agent
    1.70 +        cp l3bashrc ${user_home}/${lilalo_home}
    1.71 +        chown -R $user ${user_home}/${lilalo_home}
    1.72 +        echo l3cd=${lilalo_context}/$user > ${user_home}/${lilalo_rc}
    1.73 +        chown -R $user ${user_home}/${lilalo_rc}
    1.74 +    done
    1.75 +    set +x
    1.76 +}
    1.77 +
    1.78 +install_to_users_bashrc()
    1.79 +{
    1.80 +    users="$@"
    1.81 +    for user in $users
    1.82 +    do
    1.83 +        user_home=`get_user_home "$user"`
    1.84 +        grep -q lilalo ${user_home}/.bashrc 2> /dev/null\
    1.85 +        || echo ". ${user_home}/.lilalo/l3bashrc && _l3_start" >> ${user_home}/.bashrc; chown -R ${user} ${user_home}/.bashrc
    1.86 +    done
    1.87 +}
    1.88 +
    1.89 +install_to_users_bash_profile()
    1.90 +{
    1.91 +    users="$@"
    1.92 +    for user in $users
    1.93 +    do
    1.94 +        user_home=`get_user_home "$user"`
    1.95 +        grep -q l3-agent ${user_home}/.bash_profile 2> /dev/null \
    1.96 +        || { echo >> ${user_home}/.bash_profile ; cat ${user_home}/.bash_profile | sed '1s/^/l3-agent/' > /tmp/$$$$l3 ; mv /tmp/$$$$l3 ${user_home}/.bash_profile; chown -R ${user} ${user_home}/.bash_profile; }
    1.97 +    done
    1.98 +}
    1.99 +
   1.100 +show_usage()
   1.101 +{
   1.102 +    cat <<USAGE
   1.103 +Usage:
   1.104 +    $0 
   1.105 +USAGE
   1.106 +}
   1.107 +
   1.108 +show_final_message()
   1.109 +{
   1.110 +    cat <<FINAL_MESSAGE
   1.111 +
   1.112 +
   1.113 +Installation is successfully completed.
   1.114 +Now restart your shell or relogin
   1.115 +to start script writing.
   1.116 +
   1.117 +Your current lilalo context is ${lilalo_context}/USER
   1.118 +If you use xgu.ru backend, your labs will be available at
   1.119 +http://xgu.ru/l3/${lilalo_context}
   1.120 +
   1.121 +Use commands
   1.122 + $ l3cd ${lilalo_context%/*/*}/MY-NEW-CONTEXT/${hostname}/USER
   1.123 + $ l3pwd
   1.124 +to change and to know your current context.
   1.125 +
   1.126 +For further information see http://xgu.ru/lilalo/ (in Russian).
   1.127 +
   1.128 +Thank you gor using LiLaLo.
   1.129 +Happy Labbing!
   1.130 +
   1.131 +(don't forget to restart bash or relogin)
   1.132 +
   1.133 +FINAL_MESSAGE
   1.134 +}
   1.135 +
   1.136 +
   1.137 +temp_dir=/tmp/lilalo-install-temp-$$
   1.138 +mkdir -p ${temp_dir}
   1.139 +cd ${temp_dir}
   1.140 +step "Downloading l3bashrc" ${wget} ${url_l3bashrc} 
   1.141 +step "Downloading l3-agent" '${wget} ${url_l3agent}; ${wget} ${url_l3config}'
   1.142 +step "Downloading perl modules for l3-agent" '{ for i in ${perl_modules}; do ${wget} ${url_perl_modules}/$i.tar.gz; done; }'
   1.143 +step "Installing perl modules for l3-agent" '{ for i in ${perl_modules}; do tar xvfz $i.tar.gz; cd $i*[^z]; perl Makefile.PL; make; make install; cd ..; done; }'
   1.144 +step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users
   1.145 +step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users
   1.146 +step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users
   1.147 +cd /
   1.148 +rm -rf ${temp_dir}
   1.149 +
   1.150 +show_final_message
   1.151 +
     2.1 --- a/l3-backend	Tue Jun 27 18:00:09 2006 +0300
     2.2 +++ b/l3-backend	Fri Aug 04 17:41:31 2006 +0300
     2.3 @@ -121,7 +121,7 @@
     2.4  # Путь l3cd должен быть не пуст, 
     2.5  # и в нём могут быть только символы латинского алфавита, цифры и знаки _ и -
     2.6                  if ($l3cd && $l3cd =~ /^[a-zA-Z_\/0-9-]*/) {
     2.7 -                    system("mkdir -p $Config{backend_datadir}/$l3cd");
     2.8 +                    system("mkdir -m 770 -p $Config{backend_datadir}/$l3cd");
     2.9                      if (open(OUT, ">>", $Config{"backend_datadir"}."/$l3cd/data.xml")) {
    2.10                          print OUT "<$element_name>".$element."</$element_name>";
    2.11                          close(OUT);
     3.1 --- a/l3-cgi-lite	Tue Jun 27 18:00:09 2006 +0300
     3.2 +++ b/l3-cgi-lite	Fri Aug 04 17:41:31 2006 +0300
     3.3 @@ -129,7 +129,7 @@
     3.4  sub path_is_correct($)
     3.5  {
     3.6      my $path = $_[0];
     3.7 -    return 0 if $path =~ m@/../@;
     3.8 +   # return 0 if $path =~ m@/../@;
     3.9      return 0 unless $path =~ m@^[a-zA-Z0-9./\@\-]*$@;
    3.10      return 1;
    3.11  }
     4.1 --- a/l3-frontend	Tue Jun 27 18:00:09 2006 +0300
     4.2 +++ b/l3-frontend	Fri Aug 04 17:41:31 2006 +0300
     4.3 @@ -174,7 +174,7 @@
     4.4  
     4.5  sub mywi_client
     4.6  {
     4.7 -    #return "";
     4.8 +    return "";
     4.9      my $query = $_[0];
    4.10      my $mywi;
    4.11  
     5.1 --- a/l3.css	Tue Jun 27 18:00:09 2006 +0300
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,337 +0,0 @@
     5.4 -h1,h2,h3,h4 {
     5.5 -    color:  #485c9f;
     5.6 -    padding-top:    10pt;
     5.7 -    padding-bottom: 0pt;
     5.8 -    margin-left:    0pt;
     5.9 -    font-family:    sans-serif;
    5.10 -    /*    border: thin solid gray; */
    5.11 -}
    5.12 -
    5.13 -a {
    5.14 -    padding-left: 3pt;
    5.15 -    padding-right: 3pt;
    5.16 -    text-decoration: none;
    5.17 -}
    5.18 -
    5.19 -a:hover {
    5.20 -    background-color: #eeeecc;
    5.21 -}
    5.22 -
    5.23 -body {
    5.24 -    padding-left:   10pt;
    5.25 -    font-family:    sans-serif;
    5.26 -}
    5.27 -
    5.28 -tr.table_header {
    5.29 -    background-color    :   #98bcef;
    5.30 -    font-weight:    bold;
    5.31 -    font-size: 105%;
    5.32 -}
    5.33 -
    5.34 -td
    5.35 -{
    5.36 -    padding-left:5pt;
    5.37 -    padding-right:5pt;
    5.38 -
    5.39 -    margin-left:0pt;
    5.40 -    margin-right:0pt;
    5.41 -}
    5.42 -
    5.43 -.toc {
    5.44 -    border: 1px solid #aaa;
    5.45 -    background-color: #f9f9f9;
    5.46 -    padding: 10pt;
    5.47 -    padding-left: 0pt;
    5.48 -    padding-right: 15pt;
    5.49 -    font-size: 95%;
    5.50 -}
    5.51 -
    5.52 -.files_toc {
    5.53 -    padding : 10pt;
    5.54 -    columns: 50em;
    5.55 -}
    5.56 -.toc_title {
    5.57 -    font-weight: bold;
    5.58 -    text-align: center;
    5.59 -}
    5.60 -
    5.61 -.cline, .output
    5.62 -        { 
    5.63 -    margin      : 0px 0px 0px 0em;
    5.64 -    padding     : 0px 0px 0px 0px; 
    5.65 -    vertical-align  : top;
    5.66 -    /*display:inline;*/
    5.67 -}
    5.68 -
    5.69 -.cline
    5.70 -{   font-weight : bold;           }
    5.71 -
    5.72 -.wrong_cline, .wrong_root_cline,
    5.73 -.mistyped_cline, .mistyped_root_cline   
    5.74 -        {   
    5.75 -            /*
    5.76 -            color       : #ee7777;      
    5.77 -            */
    5.78 -            /* color        : #aa5555; */
    5.79 -        }
    5.80 -.wrong_output,              .wrong_root_output, 
    5.81 -.mistyped_output,           .mistyped_root_output   
    5.82 -        {   
    5.83 -            /*
    5.84 -            font-size   : 80%;
    5.85 -            color       : #cc6666;      
    5.86 -            */
    5.87 -        }
    5.88 -
    5.89 -.cblock_mistyped,
    5.90 -.cblock_mistyped_root
    5.91 -        {   
    5.92 -            text-decoration : line-through;
    5.93 -        }
    5.94 -
    5.95 -.cblock_interrupted > .output,
    5.96 -.cblock_interrupted_root > .output 
    5.97 -        {
    5.98 -            color       : #aaaaaa;
    5.99 -        }
   5.100 -
   5.101 -.cblock_interrupted > .cline
   5.102 -.cblock_interrupted_root > .cline
   5.103 -        {
   5.104 -            color       : #777777;
   5.105 -        }
   5.106 -
   5.107 -
   5.108 -.cblock_normal_root,
   5.109 -.cblock_wrong_root,
   5.110 -.cblock_mistyped_root,
   5.111 -.cblock_interrupted_root,
   5.112 -.cblock_tab_root
   5.113 -        {
   5.114 -            border-left : #ff0000 solid thin;
   5.115 -        }
   5.116 -
   5.117 -.command    {
   5.118 -    margin  : 0pt 0pt 0pt 0pt;
   5.119 -    padding : 0pt 0pt 0pt 0pt;
   5.120 -    /*border  : thin solid gray;*/
   5.121 -        }
   5.122 -
   5.123 -.with_hint  {
   5.124 -    background  :   #effdff;
   5.125 -}
   5.126 -
   5.127 -.without_hint   {
   5.128 -    background  :   #ffefef;
   5.129 -}
   5.130 -
   5.131 -.note       { 
   5.132 -    /*     
   5.133 -    color       : black;
   5.134 -    background  : #d8fcff; 
   5.135 -    margin      : 12px 12px 12px 12px;
   5.136 -        padding     : 6px 6px 6px 6px; 
   5.137 -        border-style    : dashed;
   5.138 -        border-width    : thin;
   5.139 -    border-color    : #a8eaff; 
   5.140 -    vertical-align  : top;
   5.141 -    */
   5.142 -    color       : black;
   5.143 -    background  : #d8f0ff;
   5.144 -    margin      : 2px 12px 12px 12px;
   5.145 -        padding     : 6px 6px 6px 6px; 
   5.146 -        border-style    : dotted;
   5.147 -        border-width    : thin;
   5.148 -    border-color    : #687cbf;
   5.149 -    vertical-align  : top;
   5.150 -}
   5.151 -
   5.152 -.note_title,.note_text,.note_search 
   5.153 -        { 
   5.154 -            color       : black;
   5.155 -                margin      : 0px 0px 0px 0px;
   5.156 -                padding     : 0px 0px 0px 0px; 
   5.157 -            vertical-align  : top;
   5.158 -                                }
   5.159 -.note_title {   
   5.160 -            font-size   : 120%;         
   5.161 -            font-family : sans-serif;
   5.162 -            padding-top : 2pt;
   5.163 -            padding-bottom  : 2pt;
   5.164 -        }
   5.165 -.note_text  {   
   5.166 -            font-family : sans-serif;       
   5.167 -            font-size   : 100%;         
   5.168 -        }
   5.169 -.note_search    {   text-align  : right;        }
   5.170 -
   5.171 -
   5.172 -.diff       { 
   5.173 -    color       : black;
   5.174 -    background  : #fdffcd;
   5.175 -        margin      : 16px 16px 16px 16px;
   5.176 -        padding     : 6px 6px 6px 6px; 
   5.177 -        border-style    : dashed;
   5.178 -        border-width    : thin;
   5.179 -}
   5.180 -
   5.181 -.ttychange      { 
   5.182 -    color       : #9a9a9a;
   5.183 -    background  : #fafafa;
   5.184 -    margin      : 0em 0px 0pt 0px;
   5.185 -    padding     : 0em 0pt 0em 0pt; 
   5.186 -    vertical-align  : top;
   5.187 -    font-family : monospace;
   5.188 -    min-width: 5em;
   5.189 -    position    : relative;
   5.190 -    left        : 0em;
   5.191 -    border-top  : thin dotted #cccccc;
   5.192 -    text-align  : right;
   5.193 -    font-size   : 50%;
   5.194 -}
   5.195 -
   5.196 -.time { 
   5.197 -    color       : #999999;
   5.198 -    margin      : 0px 0px 0px 0px;
   5.199 -    padding     : 2pt 5pt 0px 0px; 
   5.200 -    vertical-align  : top;
   5.201 -    font-size   : 80%;
   5.202 -    width       : 5em;
   5.203 -    float       : left; 
   5.204 -/*    height      : 100%; */
   5.205 -/*    border      : thin solid gray; */
   5.206 -}
   5.207 -
   5.208 -.cblock,
   5.209 -.cblock_normal,
   5.210 -.cblock_wrong,
   5.211 -.cblock_mistyped,
   5.212 -.cblock_interrupted,
   5.213 -.cblock_tab,
   5.214 -.cblock_normal_root,
   5.215 -.cblock_wrong_root,
   5.216 -.cblock_mistyped_root,
   5.217 -.cblock_interrupted_root,
   5.218 -.cblock_tab_root
   5.219 -{ 
   5.220 -    margin      : 0px 0px 0px 0em;
   5.221 -    padding     : 0px 0px 0px 5pt; 
   5.222 -    vertical-align  : top;
   5.223 -/*    border      : thin solid blue; */
   5.224 -}
   5.225 -
   5.226 -.visibility_form        { 
   5.227 -    position    : fixed;
   5.228 -    bottom: 10; right: 10;
   5.229 -    z-index     : 5;
   5.230 -    color       : #9a9a9a;
   5.231 -    background  : #e7e7e7;
   5.232 -    margin      : 0px 0px 0px 0px;
   5.233 -    padding     : 0px 0px 0px 0px; 
   5.234 -    vertical-align  : top;
   5.235 -    font-size   : 80%;
   5.236 -    font-family : sans-serif;
   5.237 -}
   5.238 -.visibility_form > .header {
   5.239 -    font-weight: bold;
   5.240 -}
   5.241 -.visibility_form > .window_controls {
   5.242 -    position : absolute;
   5.243 -    right : 1pt;
   5.244 -}
   5.245 -
   5.246 -.new_commands_table {
   5.247 -        padding     : 0px 0px 0px 0px;
   5.248 -        margin      : 20px 60px 60px 20px;
   5.249 -        background-color: #f9f9f9;
   5.250 -}
   5.251 -
   5.252 -.new_commands_header {
   5.253 -        font-weight: bold;
   5.254 -        background-color: #e9e9e9;
   5.255 -}
   5.256 -
   5.257 -.new_commands_caption {
   5.258 -        font-style: italic;
   5.259 -        background-color: #ffffff;
   5.260 -}
   5.261 -
   5.262 -.err_box {
   5.263 -    color       : white;
   5.264 -    background  : red;
   5.265 -    font-weight : bold;
   5.266 -    font-size   : 70%;
   5.267 -}
   5.268 -.filename, .file_navigation {
   5.269 -    background  : #f7f7ba;
   5.270 -    padding     : 1ex;
   5.271 -    padding-bottom: 1pt;
   5.272 -    display     : inline;
   5.273 -}
   5.274 -
   5.275 -.filename {
   5.276 -    font-weight : bold;
   5.277 -    margin      :  20pt 0pt 0pt 10pt;
   5.278 -}
   5.279 -
   5.280 -.file_navigation {
   5.281 -    font-weight : bold;
   5.282 -    margin      :  20pt 10pt 0pt 0pt;
   5.283 -}
   5.284 -
   5.285 -.filedata {
   5.286 -    padding: 5pt 10pt 5pt 10pt;
   5.287 -    margin:  0pt 10pt 30pt 10pt;
   5.288 -    border-left: 2pt;
   5.289 -    border-right: 2pt;
   5.290 -    border-bottom: 2pt;
   5.291 -    border-style: solid;
   5.292 -    border-color: #f7f7ba;
   5.293 -    background-color: #fffffa;
   5.294 -}
   5.295 -
   5.296 -.time_passed {
   5.297 -    padding: 1em 5em 1em 5em
   5.298 -}
   5.299 -
   5.300 -.much_time_passed {
   5.301 -    padding: 2em 5em 2em 5em
   5.302 -}
   5.303 -
   5.304 -.edit_link {
   5.305 -    float:      right;
   5.306 -    font-size:  80%;
   5.307 -    position: relative;
   5.308 -    bottom: 0;
   5.309 -    padding-top: 2em;
   5.310 -}
   5.311 -
   5.312 -.lined_header {
   5.313 -    border-bottom: 1pt solid gray;
   5.314 -    padding: 10pt 0pt 5pt 0pt;
   5.315 -    margin: 30pt 0pt 20pt 0pt;
   5.316 -}
   5.317 -
   5.318 -
   5.319 -.nav_bar {
   5.320 -    font-size: 80%;
   5.321 -    color: #222222;
   5.322 -    background-color: #eeeeee;
   5.323 -}
   5.324 -
   5.325 -/*
   5.326 -.nav_bar a {
   5.327 -    color: #222222;
   5.328 -    padding-left: 1pt;
   5.329 -    padding-right: 1pt;
   5.330 -}
   5.331 -*/
   5.332 -body {
   5.333 -    margin:0;
   5.334 -    padding:0 0 15px 0;
   5.335 -
   5.336 -}
   5.337 -.body {
   5.338 -    margin: 10;
   5.339 -    padding: 10;
   5.340 -}
     6.1 --- a/l3config.pm	Tue Jun 27 18:00:09 2006 +0300
     6.2 +++ b/l3config.pm	Fri Aug 04 17:41:31 2006 +0300
     6.3 @@ -86,7 +86,7 @@
     6.4      "detach"            => "yes",
     6.5      "agent_pidfile"     => "$ENV{HOME}/.lilalo/l3-agent.pid",
     6.6  
     6.7 -    "backend_address"   => "192.168.15.254",
     6.8 +    "backend_address"   => "xgu.ru",
     6.9      "backend_port"      => "18030",
    6.10      "backend_pidfile"   => "/tmp/l3-backend.pid",
    6.11      "backend_datafile"  => "/var/lilalo/lablogs-xml/backend.xml",