Giter VIP home page Giter VIP logo

a2's Introduction

a2

More reliable than grep -ir /etc/apache2

If you're running Apache you'll often find you need to find the config for a vhost given a serveralias, or the logfile of the site served out of a particular directory. This aims to be a faster and more reliable way of doing that than grepping:

avi@donkey:$ a2 avi.co
servername            avi.co
documentroot          /home/avi/wordpress
errorlog              /home/avi/logs/error_log
customlog             /home/avi/logs/access_log combined
serveralias           avi.co, www.avi.co, aviswebsite.co.uk, www.aviswebsite.co.uk
sockets               10.20.30.10:80
file                  /etc/apache2/sites-enabled/avi.co.conf

If the argument begins with a forward-slash, it is assumed to be a path, and so the log, docroot, ssl key/cert and config file paths are checked, rather than servernames and aliases:

avi@donkey:~$ a2 /home/avi/logs/pics_error_log 
servername            pics.avi.co
documentroot          /home/avi/pics_html
errorlog              /home/avi/logs/pics_error_log
serveralias           pics.avi.co
sockets               10.20.30.10:80
file                  /etc/apache2/sites-enabled/pics.avi.co

and, if you know what you want, you can have it just give the path either to the document root or apache's config file (for all matching vhosts):

vim `a2 avi.co -f`

cd `a2 avi.co -d`

Included Files

I had a look through the various Apache config-file parsing moduls on the CPAN and each was lacking one of an ability to deal with included config files, or an ability to deal with a series of virtualhosts with identical opening tags (all on the same socket); they are for using Apache-like configs, not actually parsing Apache's config.

parse_apache_config() is therefore small, inelegant and single-use. It has its limitations (not least that it can't deal with an Include inside a vhosts) but it's generally good enough at the moment. If this is useful but needs to be able to more properly parse the configs it may end up making use of one of those, but for now, as a single-script, I think it's fine :)

a2's People

Contributors

bigreds avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

a2's Issues

moar fuzzy searching

apart from just running it raw and grepping, how about a2 avi and it pulling out all the vhosts with 'avi' in?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.