Цветной вывод
This commit is contained in:
69
galias-d.sh
69
galias-d.sh
@@ -1,51 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
# set -x
|
||||
set -x
|
||||
|
||||
echo "hey! this is talias-d!"
|
||||
# Цвета для вывода
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Форматирование текста
|
||||
function msgerr()
|
||||
{
|
||||
echo -e "${RED}$1${NC}"
|
||||
}
|
||||
function msgok()
|
||||
{
|
||||
echo -e "${GREEN}$1${NC}"
|
||||
}
|
||||
function msgpr()
|
||||
{
|
||||
echo -e "\e[35m$1${NC}"
|
||||
}
|
||||
|
||||
msgpr "hey! this is talias-d!"
|
||||
|
||||
msgerr "hey! this is ERROR!"
|
||||
msgok "hey! this is OK!"
|
||||
|
||||
check_apt() {
|
||||
sudo apt install $1 -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 git
|
||||
# Попробовать склонировать репозиторий
|
||||
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