Source

timekoin / bin / generate-timekoin-keys

Full commit
#!/bin/sh

set -e

cd /usr/share/timekoin/util/

resetkeys=0
quiet=0

usage() {
    echo
    echo "$0: Generate a private/public key pair for timekoin"
    echo "Usage: $0 [--reset]"
    echo
    echo "Options:"
    echo "--quiet  Be less verbose.  This is useful for scripts."
    echo "--reset  Regenerate the Timekoin private/public key pair."
    echo " 	     Before doing this, consider backing up your"
    echo " 	   existing key pair."
    echo
    exit 1
}

main() {
    echo "<?PHP
\$_GET['cmdline'] = 1;
\$_GET['quiet'] = $quiet;
\$_GET['resetkeys'] = $resetkeys;
include('keys.php');
?>"|su www-data -c php
}

processargs() {
    if [ -n "$1" ]; then
	case "$1" in
	    --help)   usage        ;;
	    --reset)  resetkeys=1  ;;
	    --quiet)  quiet=1      ;;
	    --)       : 	   ;;
	    --*)      die "Unrecognized option: $N.  For more info: $0 --help" ;;
	    *)        main "$@"; return ;;
	esac
	shift
	processargs "$@"
    else
	main "$@"
    fi
}

processargs "$@"