Skip to content

Instantly share code, notes, and snippets.

View RPDiep's full-sized avatar

Rene Diepstraten RPDiep

  • YourHosting B.V.
  • Middelburg, The Netherlands
View GitHub Profile
@RPDiep
RPDiep / show_ipaddresses
Created February 11, 2014 12:46
A simple script to show the ip addresses for a host
#!/bin/bash
# Find the device with the default route
default_eth=$(ip r | awk '/default via/ {print $5}')
# Show the IP addresses for this device
ip a s ${default_eth} | awk '/global/ {print $2}' | cut -d'/' -f1
@RPDiep
RPDiep / removeoldkernels
Last active March 4, 2016 15:05
A script to remove old kernels in ubuntu
#!/bin/bash
kernelversion=$(uname -r)
kernelminversion=${kernelversion%-*}
latestkernelversion=$(dpkg -l | awk '/linux-image-[0-9]/ {print $2}' | sort | tail -1 | grep -o '[0-9][0-9\.-]*[0-9]')
packages_to_remove=$(dpkg -l | awk '/linux-(image|headers)-[0-9]/ {print $2}' | egrep -v "${kernelminversion}|${latestkernelversion}")
[[ -z "${packages_to_remove}" ]] || dpkg -P ${packages_to_remove}
@RPDiep
RPDiep / 98r1soft-installmodule
Last active August 29, 2015 13:56
Apt hook for installing r1soft modules on ubuntu
DPkg::Post-Invoke {"/usr/local/sbin/r1soft-installmodule"}
#!/bin/bash
#
# A simple remote side-by-side diff
#
# Author: Rene Diepstraten <[email protected]>
#
[[ $# -ne 2 ]] || [[ ! $1 =~ ":" ]] || [[ ! $2 =~ ":" ]] && { echo -e "\nUsage: $0 <host1>:<file> <host2>:<file>\n" >&2 ; exit 1; }
file1=${1##*:} ; host1=${1%%:*} ; file2=${2##*:} ; host2=${2%%:*}
@RPDiep
RPDiep / mysqlbackup.sh
Last active December 20, 2015 18:09
A script to create mysql backups and keep backups with a retention scheme.
#!/bin/bash
#
# Copyright 2013 Rene Diepstraten
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#!/bin/bash
#
# chkconfig: - 55 45
# description: The memcached daemon is a network memory cache service.
# processname: memcached
### END INIT INFO
# Usage:
# cp /etc/sysconfig/memcached /etc/sysconfig/memcached_server1
# cp /etc/sysconfig/memcached /etc/sysconfig/memcached_server2