From 7deda155859706dd19eb0a32a996dd1b21638086 Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 15 Jun 2015 02:06:23 +0200 Subject: [PATCH] DynDNS and kernel stripping for Ubuntu --- remove_old_kernels.sh | 9 +++++++++ update_ip.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 remove_old_kernels.sh create mode 100755 update_ip.sh diff --git a/remove_old_kernels.sh b/remove_old_kernels.sh new file mode 100644 index 0000000..52a01ea --- /dev/null +++ b/remove_old_kernels.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Remove all but the latest $keep kernels (and headers) +# +keep=2 +sudo aptitude purge $( + for i in linux-headers-[0-9]*[0-9] linux-headers-[0-9]*generic linux-image-[0-9]* linux-image-extra-[0-9]*; do + dpkg -l $i 2>/dev/null | grep ^ii | awk {'print $2'} | grep [0-9] | sort | head -n -${keep}; + done +) diff --git a/update_ip.sh b/update_ip.sh new file mode 100755 index 0000000..bcdc558 --- /dev/null +++ b/update_ip.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +cache=.update_ip.cache +server=ns1.example.com +zone=dyn.example.com +host=desktop +secret="" + +ip=$(wget -q -O - http://alma.ch/myip.cgi) + +if [ -z ${ip} ] || [ -z ${cache} ]; then + exit; +fi + +if [ -f "${HOME}/${cache}" ]; then + old_ip=$(cat "${HOME}/${cache}") +fi + +if [ "${ip}" = "${old_ip}" ]; then + exit; +else + rm -f "${HOME}/${cache}" + echo "${ip}" > "${HOME}/${cache}" +fi + +cat <