You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
container-overlay/profiles/templates/taiga/taiga/sh.setup-taiga

198 lines
4.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Calculate path=/var/calculate/bin name=#-cut(1,.)-# chmod=755 comment=#
#!/bin/bash
export PATH="/lib/rc/bin:$PATH"
set -ueo pipefail
regular(){
replace=(
"taiga-back/settings/config.py" ""
"('PASSWORD':).*" "\1 '${taiga_pgsql_password}',"
"^.*(SECRET_KEY =).*" "\1 \"${taiga_secret_key}\""
"^.*(TAIGA_SITES_SCHEME =).*" "\1 \"${taiga_protocol}\""
"^.*(TAIGA_SITES_DOMAIN =).*" "\1 \"${taiga_taiga_sites_domain}\""
"^.*(MEDIA_ROOT =).*" "\1 '/var/calculate/www/taiga/taiga-back/media'"
"^.*(DEFAULT_FROM_EMAIL =).*" "\1 '${taiga_from_email}'"
"^.*(EMAIL_USE_TLS =).*" "\1 '${taiga_smtp_tls}'"
"^.*(EMAIL_USE_SSL =).*" "\1 '${taiga_smtp_ssl}'"
"^.*(EMAIL_HOST =).*" "\1 '${taiga_smtp_host}'"
"^.*(EMAIL_PORT =).*" "\1 ${taiga_smtp_port}"
"^.*(EMAIL_HOST_USER =).*" "\1 '${taiga_smtp_user}'"
"^.*(EMAIL_HOST_PASSWORD =).*" "\1 '${taiga_smtp_password}'"
"(\"url\": \"amqp://).*(:5672/taiga\")" "\1${taiga_rabbitmq_user}:${taiga_rabbitmq_password}@localhost\2"
"^.*(CELERY_BROKER_URL =).*" "\1 \"amqp://${taiga_rabbitmq_user}:${taiga_rabbitmq_password}@localhost:5672/taiga\""
"^.*(CELERY_TIMEZONE =).*" "\1 '${taiga_timezone}'"
"^.*(ENABLE_TELEMETRY =).*" "\1 False"
"^.*(PUBLIC_REGISTER_ENABLED =).*" "\1 ${taiga_public_register}"
"taiga-front-dist/dist/conf.json" ""
"(\"api\":).*" "\1 \"${taiga_protocol}://${taiga_taiga_sites_domain}/api/v1/\","
"(\"eventsUrl\":).*" "\1 \"wss://${taiga_taiga_sites_domain}/events\","
"(\"defaultLanguage\":).*" "\1 \"${taiga_language}\","
"(\"publicRegisterEnabled\":).*" "\1 true,"
"(\"supportUrl\":).*" "\1 \"${taiga_protocol}://${taiga_taiga_sites_domain}\","
"(\"gravatar\":).*" "\1 false,"
"taiga-events/.env" ""
"^.*(RABBITMQ_URL=).*" "\1\"amqp://${taiga_rabbitmq_user}:${taiga_rabbitmq_password}@localhost:5672/taiga\""
"^.*(SECRET=).*" "\1\"${taiga_secret_key}\""
"taiga-protected/.env" ""
"^.*(SECRET_KEY=).*" "\1\"${taiga_secret_key}\""
)
}
check_conf(){
conf=
for (( i=0; i < ${#replace[@]}; i += 2 ))
do
from=${replace[$i]}
to=${replace[$i+1]}
if [[ $to == '' ]]
then
conf=$from
continue
fi
if [[ ! -e $conf ]]
then
eerror "Не найден файл ~/taiga/$conf. Установите Taiga выполнив 'install-taiga'."
exit 2
fi
grep -qE "$from" $conf || exit 1
done
}
check_show(){
conf=
for (( i=0; i < ${#replace[@]}; i += 2 ))
do
from=${replace[$i]}
to=${replace[$i+1]}
if [[ $to == '' ]]
then
conf=$from
echo "$conf"
continue
fi
err=0
grep -qE "$from" $conf || err=1
if [[ $err == 0 ]]
then
einfo $from
else
eerror $from || true
fi
eend $err || true
done
}
configure_conf(){
conf=
for (( i=0; i < ${#replace[@]}; i += 2 ))
do
from=${replace[$i]}
to=${replace[$i+1]}
if [[ $to == '' ]]
then
if [[ $conf != '' ]]
then
eend
fi
conf=$from
ebegin $conf
continue
fi
sed -i -E "s|$from|$to|g" $conf
done
eend
}
show_conf(){
conf=
for (( i=0; i < ${#replace[@]}; i += 2 ))
do
from=${replace[$i]}
to=${replace[$i+1]}
if [[ $to == '' ]]
then
conf=$from
echo '#-------------------------------------------------------------------------'
echo " $conf"
echo '#-------------------------------------------------------------------------'
continue
fi
grep -E "$from" $conf
done
}
read_vars(){
all=
while IFS= read -r line
do
if [[ $line == *"["* ]]
then
line=${line#*[}
line=${line%%]*}
sec=$line
continue
fi
if [[ ${line:0:1} == '#' || $line == '' ]]
then
continue
fi
com=${sec}_${line// =/=};
com=${com//= /=};
all="$com; $all"
done < /var/calculate/ini.env
eval $all
}
check_homedir(){
homedir=/var/calculate/www/taiga
if [[ -d $homedir ]]
then
cd $homedir
else
eerror "Отсутствует директория $homedir!"
exit 1
fi
}
read_vars
regular
check_homedir
ebegin 'Проверка настраиваемых переменных'
`check_conf` || {
if [[ $? == 1 ]]
then
check_show # отобразим несоответствия
exit 1
fi
exit
}
eend
einfo 'Настройка конфигурационных файлов:'
configure_conf
if [[ $# == 0 ]]
then
einfo "Для отображения настроенных опций выполните '$0 show'."
else
einfo 'Настроенные параметры:'
show_conf
fi