среда, 15 февраля 2012 г.

Linux febr.15.

#!/bin/bash
vhost=$1
vhostsdir="/var/vhosts/"
apacheconf="/etc/apache2/sites-enabled/"

cd $vhostsdir
pwd
mkdir $vhost -m 755 -v
echo "<h1>This is $vhost</h1>" > $vhost/$vhost.html

cd $apacheconf
pwd
# http://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/
sed "s/{wordpress}/$vhost/g" .conf.tpl > $vhost

cp -v /etc/hosts /etc/hosts_bak_$(date +%Y-%m-%d_%H-%M-%S)

echo -e "127.0.0.1\t$vhost" >> /etc/hosts
echo "+-----------------------------------+"
echo -e "Ir pielikts:\n\n\t127.0.0.1\t$vhost"
echo "+-----------------------------------+"
echo


# ekvivalents DOS pause komandai
# http://stackoverflow.com/questions/92802/what-is-the-linux-equivalent-to-dos-pause
read -n1 -r -p "Press any key to continue..." key

nano /etc/hosts
/etc/init.d/apache2 restart
echo -e "\n\nHosti:\n"
ls /var/vhosts/

-----------------------------------------------------------------------------

Комментариев нет:

Отправить комментарий