Files
zShared/shared/mykeys
2022-07-18 10:09:08 +01:00

98 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
set -e
# Common environment variables
#
check_keystore () {
if [ ! -d ${KEYSTORE} ]
then
mkdir -p ${KEYSTORE}
fi
}
check_bastionkey () {
if [ ! -f ${BASTIONKEY} ]
then
ssh-keygen -o -a 100 -t ed25519 -f ${BASTIONKEY} -N "" -C bastion@${NAME}
cp -p ${BASTIONKEY}.pub ${KEYSTORE}/_b${NAME}${LAST}.pub
cp -p ${BASTIONKEY}.pub ${KEYSTORE}/_d${NAME}${LAST}.pub
fi
}
check_gitkey () {
if [ ! -f ${GITKEY} ]
then
ssh-keygen -o -a 100 -t ed25519 -f ${GITKEY} -N "" -C git@${NAME}
fi
}
check_rsynckey () {
if [ ! -f ${RSYNCKEY} ]
then
ssh-keygen -o -a 100 -t ed25519 -f ${RSYNCKEY} -N "" -C rsync@${NAME}
cp -p ${RSYNCKEY}.pub ${KEYSTORE}/_r${NAME}${LAST}.pub
fi
}
check_vibblerkey () {
if [ ! -f ${VIBBLERKEY} ]
then
ssh-keygen -o -a 100 -t ed25519 -f ${VIBBLERKEY} -N "" -C vibbler@${NAME}
cp -p ${VIBBLERKEY}.pub ${KEYSTORE}/_v${NAME}${LAST}.pub
fi
}
#####
# Main script below
#####
KEYSTORE=~/.mykeys
BASTIONKEY=${KEYSTORE}/bastionkey
GITKEY=${KEYSTORE}/gitkey
RSYNCKEY=${KEYSTORE}/rsynckey
VIBBLERKEY=${KEYSTORE}/vibblerkey
if [ -d /zTools/zShared/shared ] && [ ! -d /static ]
then
BASE=/zTools/zShared
fi
if [ ! -d /zTools/zShared/shared ] && [ -d /static ]
then
BASE=/static
fi
MYNAME=$(uname -n)
if [ -d /volume12/zTools/Sync${MYNAME}/zTools/zShared ]
then
BASE=/volume12/zTools/Sync${MYNAME}/zTools/zShared
fi
if [ -z ${BASE+x} ]
then
echo "Can not find BASE directory"
exit 1
fi
if [ -f ${BASE}/shared/myshared ]
then
. ${BASE}/shared/myshared
fi
SHARED=${BASE}/shared
. ${SHARED}/myshared
NAME=$(uname -n|cut -c2-4)
LAST=$(uname -n| sed -e 's/.*\(.$\)/\1/')
check_keystore
check_bastionkey
check_gitkey
check_rsynckey
check_vibblerkey