diff --git a/bootstrap.sh b/bootstrap.sh index 0e5cc90..c4e365a 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -14,6 +14,7 @@ test -L $HOME/.gitignore || ln -f -s $BASEDIR/gitignore $HOME/.gitignore test -L $HOME/.hushlogin || ln -f -s $BASEDIR/hushlogin $HOME/.hushlogin test -d $HOME/.ncmpcpp || mkdir $HOME/.ncmpcpp test -L $HOME/.ncmpcpp/config || ln -f -s $BASEDIR/ncmpcpp $HOME/.ncmpcpp/config +test -L $HOME/.functions.zsh || ln -f -s $BASEDIR/functions.zsh $HOME/.functions.zsh test -L $HOME/.zshrc || ln -f -s $BASEDIR/zshrc $HOME/.zshrc # ln vim files diff --git a/functions.zsh b/functions.zsh new file mode 100644 index 0000000..4038253 --- /dev/null +++ b/functions.zsh @@ -0,0 +1,29 @@ +#!/usr/bin/env zsh + +# Functions + +# Generate TLS certs using a local CA +gencert () { + DOMAIN=$1 + + test -d /Users/jonny/Development/localCA && ROOT='/Users/jonny/Development/localCA' + test -d /home/jonny/git/ca && ROOT='/home/jonny/git/ca' + test -d /usr/local/opt/openssl@1.1/bin && PATH='/usr/local/opt/openssl@1.1/bin':$PATH + test -f /usr/local/etc/openssl@1.1/openssl.cnf && SSLCNF='/usr/local/etc/openssl@1.1/openssl.cnf' + test -f /etc/ssl/openssl.cnf && SSLCNF='/etc/ssl/openssl.cnf' + + cd $ROOT + [[ ! -d $DOMAIN ]] && mkdir $DOMAIN + cd $DOMAIN + [[ -f key ]] && mv key key.bak + [[ -f csr ]] && mv csr csr.bak + [[ -f crt ]] && mv crt crt.bak + + openssl ecparam -name secp384r1 -genkey -noout -out key + chmod 644 key + openssl req -new -sha256 -key key -subj "/C=UK/ST=England/L=Darwen/O=JMB Dev Ltd/CN=$DOMAIN" -reqexts SAN -config <(cat $SSLCNF <(printf "[SAN]\nsubjectAltName=DNS:$DOMAIN")) -out csr + openssl x509 -req -in csr -extfile <(cat $SSLCNF <(printf "[SAN]\nsubjectAltName=DNS:$DOMAIN")) -extensions SAN -CA ../jmb-ca-ecc.pem -CAkey ../jmb-ca-ecc.key -CAcreateserial -days 90 -sha256 -out crt + + cd $HOME + echo 'Certs generated for $DOMAIN' +} \ No newline at end of file diff --git a/zshrc b/zshrc index d9b8fbe..092ee5c 100644 --- a/zshrc +++ b/zshrc @@ -190,4 +190,7 @@ export LS_COLORS='di=33;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43 # They are packaged correctly for Arch Linux test "$platform" = 'osx' && fpath=(/usr/local/share/zsh-completions $fpath) +# Source my own functions +test -e $HOME/.functions.zsh && source $HOME/.functions.zsh + test -e ${HOME}/.iterm2_shell_integration.zsh && source ${HOME}/.iterm2_shell_integration.zsh