devi@106: #!/bin/sh devi@106: devi@108: hostname=`hostname` devi@108: uname -a | grep -qi freebsd || hostname=`hostname -f` devi@108: devi@108: ############################################################################### devi@108: # devi@108: # Set this variables before installation: devi@108: devi@108: lilalo_user="YOUR-L3BACKEND-USER" devi@108: lab="SET-YOUR-FIRSTLAB-NAME-HERE" devi@108: install_l3bashrc_for_this_users="root user" # users who will use l3agent and l3script devi@108: lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" devi@108: devi@108: # devi@108: ############################################################################### devi@108: devi@108: 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 igor@115: url_l3config_pm="${url_lilalo}"/l3config.pm igor@115: url_l3config="${url_lilalo}"/l3-config igor@114: url_l3prompt="${url_lilalo}"/l3prompt devi@106: url_perl_modules=${url_lilalo}/ devi@106: perl_modules="Term-VT102 Text-Iconv" devi@106: igor@109: apt_get_install_this="perl make libmodule-build-perl libc6-dev gcc" devi@108: 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: igor@109: apt_get_install_deps() igor@109: { igor@109: if which apt-get >& /dev/null igor@109: then igor@109: apt-get install -y $apt_get_install_this igor@109: else igor@109: echo "Please install this dependencies manually:" igor@109: echo $apt_get_install_this igor@109: echo "Have you installed this already (y/n)?" igor@109: echo y | read answer igor@109: if echo $answer | grep -q ^[yY] igor@109: then igor@109: true igor@109: else igor@109: echo Please install the dependencies and rerun the script igor@109: exit 1 igor@109: fi igor@109: fi igor@109: } 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} igor@115: mkdir /etc/lilalo/ igor@115: cp l3config.pm /etc/lilalo/ devi@106: cp l3-agent /usr/local/bin igor@115: cp l3-config /usr/local/bin igor@115: chmod 755 /usr/local/bin/l3-{agent,config} devi@106: cp l3bashrc ${user_home}/${lilalo_home} igor@114: cp l3prompt ${user_home}/${lilalo_home} igor@114: chmod 755 ${user_home}/${lilalo_home}/l3prompt 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@108: || { echo >> ${user_home}/.bash_profile ; cat ${user_home}/.bash_profile | sed '1s/^/l3-agentX/' | tr X '\n' > /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 <