Add reproducible LXC provisioning script
This commit is contained in:
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
# Подготавливает Ubuntu LXC и публикует статический Coral Mobile Lending через Nginx.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
APP_DIR=/var/www/coral-mobile-lending
|
||||
REPOSITORY=https://github.dfv24.com/fofanov.dmitry/coral-mobile-lending.git
|
||||
|
||||
# Локаль и часовой пояс задаются до запуска веб-сервера.
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends ca-certificates git locales nginx
|
||||
sed -i 's/^# *ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/' /etc/locale.gen
|
||||
locale-gen ru_RU.UTF-8
|
||||
update-locale LANG=ru_RU.UTF-8 LC_ALL=ru_RU.UTF-8
|
||||
ln -snf /usr/share/zoneinfo/Europe/Moscow /etc/localtime
|
||||
printf 'Europe/Moscow\n' > /etc/timezone
|
||||
|
||||
# Клонирование повторяемо: существующая рабочая копия только обновляется.
|
||||
if [[ -d "$APP_DIR/.git" ]]; then
|
||||
git -C "$APP_DIR" fetch --depth=1 origin main
|
||||
git -C "$APP_DIR" reset --hard origin/main
|
||||
else
|
||||
rm -rf "$APP_DIR"
|
||||
git clone --depth=1 "$REPOSITORY" "$APP_DIR"
|
||||
fi
|
||||
|
||||
install -m 0644 "$APP_DIR/deploy/nginx.conf" /etc/nginx/sites-available/coral-mobile-lending
|
||||
rm -f /etc/nginx/sites-enabled/default
|
||||
ln -sfn /etc/nginx/sites-available/coral-mobile-lending /etc/nginx/sites-enabled/coral-mobile-lending
|
||||
nginx -t
|
||||
systemctl enable --now nginx
|
||||
systemctl reload nginx
|
||||
Reference in New Issue
Block a user