Useful Bash Shell Scripts
Bash is a type of shell; you will find it sitting on almost every nix based computer you can get your hands on. To check if your running bash type in this on your command prompt
echo $SHELL
If it returns something like
/bin/bash
Then you are. There are alternatives to bash; C Shell (csh) and Bourne Shell (sh) being popular ones.
Anyway, getting to the point …
Scripting
I wrote some bash scripts to help with setting up websites; I know the current trend is to use Capistrano but not everyone wants to install all of it’s dependancies.
Currently, there is one main script called sitecreate.sh, this takes in an bunch of arguments and then goes off and calls utility scripts in the same directory. As long as you get the command right, the following happens:
user.sh
- Shell in to remote server
- Create group for user
- Create user & home directory
- Add user to group
- Setup users password
vhost.sh
- Reads in and parses a vhost skeleton file
- Saves parsed vhost to apache directory
mysql.sh
- Create mysql user
- Create mysql database
- Give user permissions to the db
checkout.sh
- Checks out the projects GiT repository
Once all of those are done, it then restarts apache. The scripts aren’t fully tested yet, but feel free to grab them over at github
blog comments powered by Disqus


