1
0
Fork 0
pomodoro/bash_scripts/repo-compose.sh
2023-12-17 07:53:27 +03:00

69 lines
3 KiB
Bash
Executable file
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
echo "Установка параметров для шаблонов и копирование готовых скриптов в каталоги проектов."
source info-domain.sh || remote="git.org.ru"
basedir=$(pwd)
cd ../..
find . -mindepth 1 -maxdepth 1 -type d | sort -r | while read -r dir; do
echo "Обработка: $dir"
if [ ! -f "$dir"/.gitignore ] || [ "$(grep -cx "\.repo_\*\.sh" "$dir"/.gitignore)" == 0 ]; then
echo ".repo_*.sh" >>"$dir"/.gitignore
echo "Обновлён файл .gitignore"
fi
owner="golovin.gg"
repo=${dir##*/}
description=""
type="usr"
wiki=""
if [[ "$dir" =~ "pomodoro" ]]; then
if [[ "$dir" =~ [[:digit:]] ]]; then
owner="pomodoro"
repo=${dir//[^[:digit:]]/}
type="org"
description="Вёб-сайт: https://${owner}${repo}.mircloud.ru"
else
if [ "$remote" == "hub.mos.ru" ]; then
wiki=$(uni2ascii -a U -qpsn "$dir"/WIKI.md)
else
wiki=$(basenc "$dir"/WIKI.md --base64)
fi
description="Серия статических вёб-сайтов / Содержание / Сборка / Оформление / Открытая лицензия РФ"
fi
elif [[ "$dir" =~ "color-tomato" ]]; then
description="Цветной помидор / Тема оформления Jekyll"
elif [[ "$dir" =~ "older-tomato" ]]; then
description="Старый помидор / Тема оформления Jekyll"
elif [[ "$dir" =~ "maintenance" ]]; then
description="Скрипты Bash / Обслуживание / Автоматизация процессов / Создание архивов / Сборка вёб-сайтов / "
description+="Копирование файлов / Построение дерева каталогов / Создание скриптов из шаблонов / "
description+="Шаблоны скриптов / Создание локальных и удалённых репозиториев"
elif [[ "$dir" =~ "draft" ]]; then
description="Черновик / Код с комментариями"
elif [[ "$dir" =~ "pictures" ]]; then
description="Картинки / Аватарки для репозиториев"
fi
{
echo "#!/bin/bash"
if [ "$remote" == "hub.mos.ru" ]; then
echo "user=\"golovin.gg\""
fi
echo "owner=\"$owner\""
echo "repo=\"$repo\""
echo "description=\"$description\""
echo "type=\"$type\""
echo "wiki=\"$wiki\""
if [ "$remote" == "hub.mos.ru" ]; then
echo "token=\"$(cat "$basedir/.token_hub_mos_ru")\""
cat "$basedir/repo-gitlab.tmpl.sh"
else
echo "token=\"$(cat "$basedir/.token_git_org_ru")\""
cat "$basedir/repo-gitea.tmpl.sh"
fi
} >"$dir"/.repo_remote.sh && chmod +x "$dir"/.repo_remote.sh
{
echo "#!/bin/bash"
echo "remote=\"$remote\""
echo "owner=\"$owner\""
echo "repo=\"$repo\""
cat "$basedir/repo-local.tmpl.sh"
} >"$dir"/.repo_local.sh && chmod +x "$dir"/.repo_local.sh
done