Since OpenVPN 2.3.x release there’s no more easy-rsa scripts in /usr/share. So you have to use different approach to setup OpenVPN. It’s easy when you know all the steps.
In this howto we’ll setup and configure MongoDB server on Ubuntu 14.04 x64 (it’s only available for x64 LTS distributions). To begin we have to setup custom repository:
Since Munin on Ubuntu 14.04 doesn’t work out of the box, here’s a short tutorial how to make it work.
Imagine you have couple of files: host1.cfg, host2.cfg, host3.cfg and you want to replace “hostname1”, “hostname2”, “hostname3” in each file at once to something like “hostname1-backup”. Here’s simple sed oneliner which will do that:
1 |
sed -ri "s/hostname([1-3])/hostname\1-backup/g" host*.cfg |
Sometimes you want to run one cronjob command at a time. Like rsync something or any other command which could interfere the next run. Imagine cronjob runs the rsync every 5 minutes. To avoid running multiple rsyncs at same time we can use helping script which creates the lock while rsync is running and removes it when rsync is done. So the script itself is below. Adapt it to your needs. Do you have idea how it can be improved or optimized? Leave a comment!
1 2 3 4 5 6 7 8 9 10 |
#!/bin/sh LOCKFILE=/tmp/script.lock if [ -e $LOCKFILE ]; then exit 1 else touch $LOCKFILE ionice -c3 rsync rm -f $LOCKFILE exit 0 fi |
UPD: you can add the trap to the script in case it gets killed accidentally, to remove the lockfile. Just before first if insert:
1 |
trap "{ rm -f $LOCKFILE ; exit 255; }" SIGTERM EXIT |