devi@106: #!/bin/sh devi@106: devi@106: lilalo_rc=.l3rc devi@106: lilalo_home=.lilalo devi@106: url_lilalo="http://xgu.ru/lilalo" devi@106: url_l3bashrc="${url_lilalo}"/l3bashrc devi@106: url_l3agent="${url_lilalo}"/l3-agent devi@106: url_l3config="${url_lilalo}"/l3config.pm devi@106: url_perl_modules=${url_lilalo}/ devi@106: perl_modules="Term-VT102 Text-Iconv" devi@106: devi@106: wget=wget devi@106: uname -a | grep -qi bsd && wget=fetch devi@106: devi@106: normC='\033[0;39m' devi@106: whiteC='\033[1;37m' devi@106: redC='\033[0;31m' devi@106: greenC='\033[0;32m' devi@106: devi@106: hostname=`hostname` devi@106: uname -a | grep -qi freebsd || hostname=`hostname -f` devi@106: devi@106: devi@106: # Ask this variables: devi@106: devi@106: lilalo_user="devi" devi@106: lab="lilalo-installation" devi@106: install_l3bashrc_for_this_users="root ak devi" devi@106: lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" devi@106: devi@106: devi@106: step() devi@106: { devi@106: devi@106: msg="$1" devi@106: shift devi@106: printf "${whiteC}""$msg""...${normC}\n" devi@106: # eval "$@" 2>&1 | sed 's/^/|\ \ \ /' && printf "Ok\n" || printf "Failed\n" devi@106: eval "$@" 2>&1 > log 2>&1 && \ devi@106: { devi@106: cat log | sed 's/^/|\ \ \ /' devi@106: printf "${greenC}""Ok\n""${normC}" devi@106: } || \ devi@106: { devi@106: cat log | sed 's/^/|\ \ \ /' devi@106: printf "${redC}""Failed\n""${normC}" devi@106: } devi@106: } devi@106: devi@106: get_user_home() devi@106: { devi@106: uname -a | grep -qi freebsd && pw user show "$@"| awk -F: '{print $9}' || getent passwd "$@"| awk -F: '{print $6}' devi@106: } devi@106: devi@106: install_to_users_homes() devi@106: { devi@106: . l3bashrc devi@106: users="$@" devi@106: set -x devi@106: for user in $users devi@106: do devi@106: user_home=`get_user_home "$user"` devi@106: mkdir -p ${user_home}/${lilalo_home} devi@106: cp l3config.pm /usr/local/bin devi@106: cp l3-agent /usr/local/bin devi@106: chmod 755 /usr/local/bin/l3-agent devi@106: cp l3bashrc ${user_home}/${lilalo_home} devi@106: chown -R $user ${user_home}/${lilalo_home} devi@106: echo l3cd=${lilalo_context}/$user > ${user_home}/${lilalo_rc} devi@106: chown -R $user ${user_home}/${lilalo_rc} devi@106: done devi@106: set +x devi@106: } devi@106: devi@106: install_to_users_bashrc() devi@106: { devi@106: users="$@" devi@106: for user in $users devi@106: do devi@106: user_home=`get_user_home "$user"` devi@106: grep -q lilalo ${user_home}/.bashrc 2> /dev/null\ devi@106: || echo ". ${user_home}/.lilalo/l3bashrc && _l3_start" >> ${user_home}/.bashrc; chown -R ${user} ${user_home}/.bashrc devi@106: done devi@106: } devi@106: devi@106: install_to_users_bash_profile() devi@106: { devi@106: users="$@" devi@106: for user in $users devi@106: do devi@106: user_home=`get_user_home "$user"` devi@106: grep -q l3-agent ${user_home}/.bash_profile 2> /dev/null \ devi@106: || { 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; } devi@106: done devi@106: } devi@106: devi@106: show_usage() devi@106: { devi@106: cat <