Files
galias-d/galias-d.sh
2025-08-24 20:41:10 +05:00

51 lines
1.3 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# wget https://g.torshes.ru/alex/galias-d/src/branch/main/galias-d.sh
# sh -c "$(wget https://g.torshes.ru/alex/galias-d/src/branch/main/galias-d.sh -O -)"
# set -x
echo "hey! this is galias-d!"
check_apt() {
sudo apt install git
}
read_ssh_pub_key() {
local ssh_dir="$HOME/.ssh"
local pub_key
if [ ! -d "$ssh_dir" ]; then
echo "Директория не существует" >&2
return 1
fi
pub_key=$(find "$ssh_dir" -maxdepth 1 -name "*.pub" -type f | head -n 1)
echo " Ключ для копирования в gitea:"
# если pub_key не пустой и является файлом
if [ -n "$pub_key" ] && [ -f "$pub_key" ]; then
cat "$pub_key"
return 0
else
echo "Публичные SSH-ключи не найдены в $ssh_dir" >&2
return 1
fi
}
# Показать ключ или создать его
if read_ssh_pub_key; then
echo "Ключ успешно прочитан"
else
local ALGORITHM="ed25519"
ssh-keygen -t $ALGORITHM -f ~/.ssh/id_$ALGORITHM -N "" > /dev/null
read_ssh_pub_key
fi
check_apt
# Попробовать склонировать репозиторий
TALIAS_DIR="$HOME/.talias"
git clone ssh://git@g.torshes.ru:57322/alex/talias.git $TALIAS_DIR
cat $TALIAS_DIR/README.md