1
0
Fork 0
pomodoro/bash_scripts/repo_compose.sh

65 lines
2.2 KiB
Bash
Raw Normal View History

2023-12-17 08:06:45 +03:00
#!/bin/bash
echo "Составление скриптов с параметрами и копирование их в каталоги проектов."
remote="git.org.ru" && source info_param.sh
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_\*" "$dir"/.gitignore)" == 0 ]; then
echo ".repo_*" >>"$dir"/.gitignore
echo "Обновлён файл .gitignore"
fi
owner="golovin.gg"
repo=${dir##*/}
description=""
type="usr"
wiki=""
if [ -f "$dir"/WIKI.md ]; then
if [ "$remote" == "hub.mos.ru" ]; then
wiki=$(uni2ascii -a U -qpsn "$dir"/WIKI.md)
else
wiki=$(basenc "$dir"/WIKI.md --base64)
fi
fi
if [[ "$dir" =~ "pomodoro" ]]; then
if [[ "$dir" =~ [[:digit:]] ]]; then
owner="pomodoro"
repo=${dir//[^[:digit:]]/}
type="org"
description="Вёб-сайт: https://${owner}${repo}.mircloud.ru"
else
description="Описание / Управление процессами / Незавершённые публикации / Аватарки для репозиториев"
fi
elif [[ "$dir" =~ "color-tomato" ]]; then
description="Цветной помидор / Тема оформления Jekyll"
elif [[ "$dir" =~ "older-tomato" ]]; then
description="Старый помидор / Тема оформления Jekyll"
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\""
echo "folder=\"${dir##*/}\""
cat "$basedir/repo_local.tmpl.sh"
} >"$dir"/.repo_local.sh && chmod +x "$dir"/.repo_local.sh
done