#!/usr/bin/env clisp ;;;;Create an alert every time one of your domains ;;;;is approaching its expiration date ;;;;Usage: ./domainalert.lisp 100 ;;;;100 can be replaced with the number of days you want to be ;;;;alerted before domain expiration ;;;;This script can be executed manually or f.ex. added to your .bashrc ;;;; so you get alerted whenever you start your shell ;;;;Add the next line (without the ;'s) at the end of your .bashrc ;;;; $HOME/prog/lisp/domainalert.lisp 100 ;;;; (adjust the script path as required) ;;A list of domains with expiration dates. Replace with your own domains. (defparameter *domains* (list (list :domain "xhbml.com" :year 2008 :month 08 :day 19) (list :domain "fishingbase.com" :year 2009 :month 01 :day 29) (list :domain "goodwebhosting.info" :year 2007 :month 10 :day 05) (list :domain "flaks.net" :year 2007 :month 10 :day 11))) ;;Extract timestamp for domain expiration and compare to current time (defun expires-in-days-old (domain) (setf expires (encode-universal-time 0 0 0 (getf domain :day) (getf domain :month) (getf domain :year))) (floor (/ (- expires (get-universal-time)) (* 24 60 60)))) ;; Expiration time - now in days (defun expires-in-days (domain) (let ((expires (encode-universal-time 0 0 0 (getf domain :day) (getf domain :month) (getf domain :year)))) (floor (/ (- expires (get-universal-time)) (* 24 60 60))))) ;; Expiration time - now in days ;;Print out an alert for every domain that expires withing warning-period days (defun alert (domains warning-period) (dolist (domain domains) (let ((expires-in-days (expires-in-days domain))) (if (<= expires-in-days warning-period) (format t "~A expires in ~d days~%" (getf domain :domain) expires-in-days))))) ;;Main function. Parameters are built inside the main function to enable more interactive development (function by function) (defun main () (let ((input (first ext:*args*))) (alert *domains* (parse-integer (if input input "999999999"))))) ;;Then just call the main function here when everything is done and the script is ready to go (main)