lilalo

diff install @ 106:53b890d1ae90

small changes
author devi
date Fri Aug 04 17:41:31 2006 +0300 (2006-08-04)
parents
children 0d49f33696b3
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 +