Skip to content

Instantly share code, notes, and snippets.

View bagf's full-sized avatar
💣
⭐️ ⭐️ ⭐️ ⭐️ ⭐️ ⭐️ ⭐️ ⭐️

Rory bagf

💣
⭐️ ⭐️ ⭐️ ⭐️ ⭐️ ⭐️ ⭐️ ⭐️
View GitHub Profile
@bagf
bagf / build.sh
Last active September 2, 2019 15:11
SBT (lagom framework) deployment
#!/usr/bin/env bash
images=$(echo $IMAGES | tr " " "\n")
for image in $images
do
IFS=':' read -ra imageSplit <<< "$image"
IMGNAME=${imageSplit[0]}
IMGTAG=${imageSplit[1]}
PROJECT="$(basename $IMGNAME)"
@bagf
bagf / vsftpd_test.sh
Last active May 2, 2018 14:24
Trigger after FTP upload
#!/bin/sh
# @see https://stackoverflow.com/questions/10956668/run-a-shell-command-when-a-file-is-added
tail -n 0 -F /var/log/vsftpd.log | while read line; do
if echo "$line" | grep -q 'OK UPLOAD:'; then
filename=$(echo "$line" | cut -d, -f2)
#if [ -s "/srv/$filename" ]; then
echo "Got: $filename"
#fi
fi
done
@bagf
bagf / uptime.php
Last active July 6, 2016 08:06
Script that should run regularly to check the status of the internet and writes the results to a date stamped CSV.
<?php
date_default_timezone_set('Africa/Johannesburg');
/**
* Get this library here https://github.com/geerlingguy/Ping
*/
require_once __DIR__ .'/Ping/JJG/Ping.php';
$lock = __DIR__ ."/.lock";
@bagf
bagf / vagrant_precise32_install_packages.sh
Last active August 29, 2015 13:57
Installs PHP dependancies, mysql-server, sass and compass
#!/bin/sh
# Update apt
echo "Update apt..."
apt-get -q=2 update
# Stop interaction
echo mysql-server mysql-server/root_password password unsafepassword | debconf-set-selections
echo mysql-server mysql-server/root_password_again password unsafepassword | debconf-set-selections
# Download and install
@bagf
bagf / vagrant_precise32_install_nginx.sh
Created March 17, 2014 16:49
Installs Nginx apt source and downloads it
# Update apt
echo "Update apt..."
apt-get -q=2 update
# Add official nginx source
apt-get install -q=2 python-software-properties
echo "Installing official Nginx source..."
nginx=stable
add-apt-repository -y ppa:nginx/$nginx
apt-get -q=2 update
@bagf
bagf / vagrant_precise32_install_php5.5.9.sh
Last active August 29, 2015 13:57
Downloads PHP 5.5.9 and builds it from source, then processed to use PECL to install memcache, libxl, openssl and gearman extensions
#!/bin/sh
echo "Installing php5 build dependencies..."
apt-get build-dep -q=2 php5
cd /tmp
# Get PHP
echo "Downloading and extracting php5.5.9 source..."
wget -q -O php5.5.9.tar.xz http://us2.php.net/get/php-5.5.9.tar.xz/from/this/mirror
tar xf php5.5.9.tar.xz
cd php-5.5.9/
@bagf
bagf / vagrant_precise32_install_gearmand1.1.12.sh
Last active August 29, 2015 13:57
Downloads and complies gearman
#!/bin/sh
# Get gearman client and server library
cd /tmp
# apt-get Dependancies
echo "Installing dependencies..."
apt-get build-dep -q=2 libgearman6
apt-get install -q=2 gperf
echo "Downloading gearmand source from Launchpad..."
wget -q -O gearmand-1.1.12.tar.gz https://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz
tar -xf gearmand-1.1.12.tar.gz
@bagf
bagf / vagrant_precise32_install_libxl3.5.4.sh
Created March 17, 2014 13:44
Downloads and install libxl 3.5.4 for linux
#!/bin/sh
# Get libxl library
echo "Downloading and extracting libxl 3.5.4 for linux..."
cd /tmp
wget -q -O libxl-lin-3.5.4.tar.gz ftp://xlware.com/libxl-lin-3.5.4.tar.gz
tar -xf libxl-lin-3.5.4.tar.gz
cd libxl-3.5.4.1/
cp lib/libxl.so /usr/lib/libxl.so
cp -r include_c/ /usr/include/libxl_c
@bagf
bagf / ovpn-update-bind.php
Created February 27, 2014 12:08
OpenVPN common name sync script for bind9 DNS servers
#!/usr/bin/php
<?php
/*
* This script can be passed to --learn-address of the openvpn server, it will
* update the local bind9 server whenever an ip address is passed
*/
// Bind9 server to update
define("NS_ADDR", "127.0.0.1");
// Domain to prepend common name to
define("DOMAIN", "vpn.");
@bagf
bagf / ubuntu32_configure.sh
Last active December 30, 2015 05:59
Configures LNMP packages for Vagrant's Ubuntu precise32 box (without sass including memcache)
#!/bin/sh
# MySQL listen on all interfaces
echo "Configuring MySQL..."
mysql -uroot -punsafepassword <<EOFMYSQL
CREATE USER 'remoteuser'@'localhost' IDENTIFIED BY 'passwd123';
GRANT ALL PRIVILEGES ON *.* TO 'remoteuser'@'localhost' WITH GRANT OPTION;
CREATE USER 'remoteuser'@'%' IDENTIFIED BY 'passwd123';
GRANT ALL PRIVILEGES ON *.* TO 'remoteuser'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;