A set of useful server scripts
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install server-scripts
The mailer should be configured to email alerts to the system administrator. Configuration for the mailer is done through environment variables. See .env for available configuration options.
See .env.gmail for configuration options
The bin directory contains the executable server scripts. If these scripts are being run on a production server, the cron exporter is useful for creating wrapper scripts which can be executed by different environments such as cron.
Disk usage checks your disk usage and sends an alert if it's over your defined limit. You can export this to a cron job by using the cron exporter
Virtual IP Mapper
This script is useful when configuring a VPN on Amazon EC2. Amazon EC2 uses DHCP to allocate your static local IP which can change anytime. You can use a Virtual IP and and iptables to route traffic sent to your virtual IP to your local ip. That way you can give out your virtual ip instead of your actual local IP. The following iptables command would add such a rule.
sudo iptables -t nat -A PREROUTING -d virtual_ip/32 -j NETMAP --to actual_local_ip/32
Virtual IP Mapper will automatically update your IP table rule when your static local IP address changes via DHCP.
To install the script use the cron exporter adding the environment variables
VIRTUAL_IP to your
.env.production in addition to your mailer config. Finally create a new file in
/etc/dhcp/dhclient-enter-hooks.d/virtual_ip_mapper with the following code:
su - <user> -c '/path/to/exported/file/generated/from/cron/exporter'
Test the code by running:
sudo dhclient -v eth0
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request