spcd/bootstrap.sh
Marc Beninca 2f397858c4
All checks were successful
/ job (push) Successful in 1m38s
openssh-client
2024-04-08 11:45:40 +02:00

45 lines
849 B
Bash
Executable file

FILE="$(realpath "${BASH_SOURCE[0]}")"
ROOT="$(dirname "${FILE}")"
COMMANDS='cmd'
KEY_ALGORITHM='ed25519'
KEY_DIRECTORY='.ssh'
KEY_PATH="${KEY_DIRECTORY}/id_${KEY_ALGORITHM}"
KEY_PUBLIC='AAAAC3NzaC1lZDI1NTE5AAAAIPHCNcgHlQoiNTXfnUZYvHz9OZwYsmBCrSSV7a7Zche5'
PACKAGES=(
'openssh-client'
'python3'
'rsync'
'tree'
)
SERVER="$(basename ${GITHUB_SERVER_URL})"
TARGET='/usr/local/sbin'
# commands
cd "${ROOT}/${COMMANDS}" \
|| exit
for file in *.sh ; do
cp "${file}" "${TARGET}/${file%.sh}" \
|| exit
done
# ssh
cd \
|| exit
mkdir "${KEY_DIRECTORY}" \
|| exit
echo "${CD}" > "${KEY_PATH}" \
|| exit
unset CD
chmod '400' "${KEY_PATH}" \
|| exit
echo "${SERVER} ssh-${KEY_ALGORITHM} ${KEY_PUBLIC}" \
> "${KEY_DIRECTORY}/known_hosts" \
|| exit
# packages
apt-get install --yes "${PACKAGES[@]}" \
|| exit
# remove
rm --force --recursive "${ROOT}"