diff --git a/README.md b/README.md new file mode 100644 index 0000000..3b4f168 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# Запустить удалённый скрипт: +## wget +``` +wget -qO - https://g.torshes.ru/alex/galias-d/raw/branch/main/galias-d.sh | bash +``` + +## curl +``` +source <(curl -s https://g.torshes.ru/alex/galias-d/raw/branch/main/galias-d.sh) +``` \ No newline at end of file diff --git a/galias-d.sh b/galias-d.sh new file mode 100644 index 0000000..b0f5b04 --- /dev/null +++ b/galias-d.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# set -x + +echo "hey! this is talias-d!" + +check_apt() { + sudo apt install git -y +} + +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 https://g.torshes.ru/user/settings/keys" + + # если 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" +if [ $(git clone ssh://git@g.torshes.ru:57322/alex/talias.git $TALIAS_DIR) ]; then + echo ERROR + return 1 +fi + +cat $TALIAS_DIR/README.md diff --git a/hw.md b/hw.md deleted file mode 100644 index 95d09f2..0000000 --- a/hw.md +++ /dev/null @@ -1 +0,0 @@ -hello world \ No newline at end of file