2024-04-22 15:41:01 +00:00
|
|
|
#! /usr/bin/env bash
|
2024-03-25 18:59:12 +00:00
|
|
|
FILE="$(realpath "${BASH_SOURCE[0]}")"
|
|
|
|
ROOT="$(dirname "${FILE}")"
|
|
|
|
|
2024-03-25 19:49:12 +00:00
|
|
|
COMMANDS='cmd'
|
2024-03-25 11:53:37 +00:00
|
|
|
KEY_ALGORITHM='ed25519'
|
2024-03-25 14:47:24 +00:00
|
|
|
KEY_DIRECTORY='.ssh'
|
|
|
|
KEY_PATH="${KEY_DIRECTORY}/id_${KEY_ALGORITHM}"
|
2024-03-25 11:53:37 +00:00
|
|
|
KEY_PUBLIC='AAAAC3NzaC1lZDI1NTE5AAAAIPHCNcgHlQoiNTXfnUZYvHz9OZwYsmBCrSSV7a7Zche5'
|
|
|
|
SERVER="$(basename ${GITHUB_SERVER_URL})"
|
2024-03-25 18:59:12 +00:00
|
|
|
TARGET='/usr/local/sbin'
|
|
|
|
|
|
|
|
# commands
|
2024-03-25 19:49:12 +00:00
|
|
|
cd "${ROOT}/${COMMANDS}" \
|
2024-03-25 18:59:12 +00:00
|
|
|
|| exit
|
|
|
|
for file in *.sh ; do
|
2024-03-25 19:52:27 +00:00
|
|
|
cp "${file}" "${TARGET}/${file%.sh}" \
|
2024-03-25 18:59:12 +00:00
|
|
|
|| exit
|
|
|
|
done
|
2024-03-25 11:53:37 +00:00
|
|
|
|
2024-03-23 08:39:00 +00:00
|
|
|
# ssh
|
2024-03-25 14:47:24 +00:00
|
|
|
cd \
|
|
|
|
|| exit
|
|
|
|
mkdir "${KEY_DIRECTORY}" \
|
2024-03-25 11:53:37 +00:00
|
|
|
|| exit
|
|
|
|
echo "${CD}" > "${KEY_PATH}" \
|
|
|
|
|| exit
|
2024-03-22 23:59:39 +00:00
|
|
|
unset CD
|
2024-03-25 11:53:37 +00:00
|
|
|
chmod '400' "${KEY_PATH}" \
|
|
|
|
|| exit
|
2024-03-25 14:42:26 +00:00
|
|
|
echo "${SERVER} ssh-${KEY_ALGORITHM} ${KEY_PUBLIC}" \
|
2024-03-25 14:47:24 +00:00
|
|
|
> "${KEY_DIRECTORY}/known_hosts" \
|
2024-03-25 11:53:37 +00:00
|
|
|
|| exit
|