--wip-- [skip ci]
This commit is contained in:
10
README.md
Normal file
10
README.md
Normal file
@@ -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)
|
||||
```
|
||||
51
galias-d.sh
Normal file
51
galias-d.sh
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user