Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Shara 2012
- # free4all
- sitesDir="/home/shara/Sites"
- hostsFile="/etc/hosts"
- xamppVHosts="/opt/lampp/etc/extra/httpd-vhosts.conf"
- if [[ "$(pgrep httpd)" && "$(pgrep mysql)" && "$(pgrep ftpd)" ]]
- then
- action="XAMPP stoped..."
- answer=`/opt/lampp/lampp stop`
- else
- # Clear hostsFile
- clearhosts=`sed '/#XAMPP virtual hosts/ {N; /.*\n.*/d}' $hostsFile`
- echo "$clearhosts" > $hostsFile
- # Set hostsFile
- cd $sitesDir
- siteNames=`ls -d *`
- hostsLine="127.0.0.1 $siteNames"
- echo -e "#XAMPP virtual hosts\n"$hostsLine"\n" >> $hostsFile
- # Delete xamppVHosts
- rm $xamppVHosts
- # Set xamppVHosts
- addrarr=($siteNames)
- for address in "${addrarr[@]}"
- do
- echo -e "<VirtualHost 127.0.0.1:80>
- DocumentRoot $sitesDir/$address
- ServerName $address
- ServerAlias www.$address
- ErrorLog $sitesDir/$address/$address.error.log
- CustomLog $sitesDir/$address/$address.access.log common
- <Directory $sitesDir/$address>
- Require all granted
- </Directory>
- </VirtualHost>\n" >> $xamppVHosts
- done
- action="XAMPP started..."
- answer=`/opt/lampp/lampp start`
- fi
- notify-send -t 5500 "$action" "$answer"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement