Add a functions file for custom actions

This commit is contained in:
Jonny Barnes 2017-09-11 14:23:28 +01:00
parent 62ad1077a4
commit 2cbef96dc0
3 changed files with 33 additions and 0 deletions

View file

@ -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 -L $HOME/.hushlogin || ln -f -s $BASEDIR/hushlogin $HOME/.hushlogin
test -d $HOME/.ncmpcpp || mkdir $HOME/.ncmpcpp test -d $HOME/.ncmpcpp || mkdir $HOME/.ncmpcpp
test -L $HOME/.ncmpcpp/config || ln -f -s $BASEDIR/ncmpcpp $HOME/.ncmpcpp/config 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 test -L $HOME/.zshrc || ln -f -s $BASEDIR/zshrc $HOME/.zshrc
# ln vim files # ln vim files

29
functions.zsh Normal file
View file

@ -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'
}

3
zshrc
View file

@ -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 # They are packaged correctly for Arch Linux
test "$platform" = 'osx' && fpath=(/usr/local/share/zsh-completions $fpath) 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 test -e ${HOME}/.iterm2_shell_integration.zsh && source ${HOME}/.iterm2_shell_integration.zsh