Ajoute l'application de Brice et sa mise a jour automatique
This commit is contained in:
@@ -34,6 +34,8 @@ Options principales:
|
||||
--branch Branche Git a deployer (defaut: main)
|
||||
--ethan-repo-url Depot Git de l'application Ethan
|
||||
--ethan-branch Branche Git de l'application Ethan (defaut: main)
|
||||
--brice-repo-url Depot Git de l'application Brice
|
||||
--brice-branch Branche Git de l'application Brice (defaut: main)
|
||||
--lxc-password Mot de passe root du LXC. Genere si absent
|
||||
-h, --help Affiche cette aide
|
||||
|
||||
@@ -75,6 +77,8 @@ REPO_URL="https://git.jeannerot.fr/christophe/chesscubing.git"
|
||||
REPO_BRANCH="main"
|
||||
ETHAN_REPO_URL="https://git.jeannerot.fr/Mineloulou/Chesscubing.git"
|
||||
ETHAN_REPO_BRANCH="main"
|
||||
BRICE_REPO_URL="https://git.jeannerot.fr/Lescratcheur/ChessCubing.git"
|
||||
BRICE_REPO_BRANCH="main"
|
||||
LXC_PASSWORD=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
@@ -159,6 +163,14 @@ while [[ $# -gt 0 ]]; do
|
||||
ETHAN_REPO_BRANCH="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--brice-repo-url)
|
||||
BRICE_REPO_URL="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--brice-branch)
|
||||
BRICE_REPO_BRANCH="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--lxc-password)
|
||||
LXC_PASSWORD="${2:-}"
|
||||
shift 2
|
||||
@@ -206,7 +218,9 @@ repo_url="$3"
|
||||
repo_branch="$4"
|
||||
ethan_repo_url="$5"
|
||||
ethan_repo_branch="$6"
|
||||
lxc_password="$7"
|
||||
brice_repo_url="$7"
|
||||
brice_repo_branch="$8"
|
||||
lxc_password="$9"
|
||||
|
||||
die() {
|
||||
printf 'Erreur: %s\n' "$*" >&2
|
||||
@@ -342,7 +356,7 @@ pct exec "$ctid" -- true >/dev/null 2>&1 || die "Le LXC n'est pas joignable apre
|
||||
printf 'Installation de nginx, git, rsync et des prerequis de build dans le conteneur...\n'
|
||||
ct_exec "apt-get update && apt-get install -y ca-certificates curl gpg git nginx rsync"
|
||||
|
||||
ct_exec "install -d -m 0755 /opt/chesscubing/repo /opt/chesscubing/ethan-repo /opt/chesscubing/publish /var/www/chesscubing/current"
|
||||
ct_exec "install -d -m 0755 /opt/chesscubing/repo /opt/chesscubing/ethan-repo /opt/chesscubing/brice-repo /opt/chesscubing/publish /var/www/chesscubing/current"
|
||||
|
||||
printf 'Clonage du depot %s...\n' "$repo_url"
|
||||
ct_exec "if [ ! -d /opt/chesscubing/repo/.git ]; then \
|
||||
@@ -363,11 +377,14 @@ trap 'printf \"Erreur: echec de la commande [%s] a la ligne %s.\\n\" \"\$BASH_CO
|
||||
|
||||
main_repo_dir='/opt/chesscubing/repo'
|
||||
ethan_repo_dir='/opt/chesscubing/ethan-repo'
|
||||
brice_repo_dir='/opt/chesscubing/brice-repo'
|
||||
publish_root='/opt/chesscubing/publish'
|
||||
web_root='/var/www/chesscubing/current'
|
||||
main_branch=\"\${1:-${repo_branch}}\"
|
||||
ethan_repo_url='${ethan_repo_url}'
|
||||
ethan_branch='${ethan_repo_branch}'
|
||||
brice_repo_url='${brice_repo_url}'
|
||||
brice_branch='${brice_repo_branch}'
|
||||
|
||||
ensure_dotnet_sdk() {
|
||||
if command -v dotnet >/dev/null 2>&1; then
|
||||
@@ -448,19 +465,32 @@ publish_static_tree() {
|
||||
--include='*.webp' \
|
||||
--include='*.ico' \
|
||||
--include='*.pdf' \
|
||||
--include='*.json' \
|
||||
--include='*.webmanifest' \
|
||||
--exclude='*' \
|
||||
\"\$source_dir/\" \"\$destination_dir/\"
|
||||
}
|
||||
|
||||
ensure_browser_stub() {
|
||||
local destination_dir=\"\$1\"
|
||||
local stub_path=\"\$destination_dir/cordova.js\"
|
||||
|
||||
if [[ ! -f \"\$stub_path\" ]]; then
|
||||
printf '%s\n' '// Browser stub for Cordova builds.' > \"\$stub_path\"
|
||||
fi
|
||||
}
|
||||
|
||||
sync_git_repo \"\$main_repo_dir\" '${repo_url}' \"\$main_branch\" 'principal'
|
||||
sync_git_repo \"\$ethan_repo_dir\" \"\$ethan_repo_url\" \"\$ethan_branch\" 'Ethan'
|
||||
sync_git_repo \"\$brice_repo_dir\" \"\$brice_repo_url\" \"\$brice_branch\" 'Brice'
|
||||
|
||||
install -d -m 0755 \"\$web_root\" \"\$publish_root\"
|
||||
|
||||
publish_blazor_app \"\$main_repo_dir\" \"\$publish_root/main\"
|
||||
rsync -a --delete \"\$publish_root/main/wwwroot/\" \"\$web_root/\"
|
||||
publish_static_tree \"\$ethan_repo_dir\" \"\$web_root/ethan\"
|
||||
publish_static_tree \"\$brice_repo_dir/www\" \"\$web_root/brice\"
|
||||
ensure_browser_stub \"\$web_root/brice\"
|
||||
|
||||
chown -R www-data:www-data \"\$web_root\"
|
||||
|
||||
@@ -486,11 +516,19 @@ server {
|
||||
try_files \$uri \$uri/ /ethan/index.html;
|
||||
}
|
||||
|
||||
location = /brice {
|
||||
return 301 \$scheme://\$http_host/brice/;
|
||||
}
|
||||
|
||||
location /brice/ {
|
||||
try_files \$uri \$uri/ /brice/index.html;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files \$uri \$uri/ /index.html;
|
||||
}
|
||||
|
||||
location ~* \.(?:css|js|mjs|png|jpg|jpeg|svg|webp|ico|pdf|webmanifest)$ {
|
||||
location ~* \.(?:css|js|json|mjs|png|jpg|jpeg|svg|webp|ico|pdf|webmanifest)$ {
|
||||
expires -1;
|
||||
add_header Cache-Control 'no-cache, no-store, must-revalidate';
|
||||
}
|
||||
@@ -536,6 +574,8 @@ if [[ "$LOCAL_MODE" == "1" ]]; then
|
||||
"$REPO_BRANCH" \
|
||||
"$ETHAN_REPO_URL" \
|
||||
"$ETHAN_REPO_BRANCH" \
|
||||
"$BRICE_REPO_URL" \
|
||||
"$BRICE_REPO_BRANCH" \
|
||||
"$LXC_PASSWORD"
|
||||
exit 0
|
||||
fi
|
||||
@@ -576,4 +616,6 @@ sshpass -p "$PROXMOX_PASSWORD" \
|
||||
"$REPO_BRANCH" \
|
||||
"$ETHAN_REPO_URL" \
|
||||
"$ETHAN_REPO_BRANCH" \
|
||||
"$BRICE_REPO_URL" \
|
||||
"$BRICE_REPO_BRANCH" \
|
||||
"$LXC_PASSWORD" < "$payload_script"
|
||||
|
||||
@@ -25,6 +25,8 @@ Options principales:
|
||||
--branch Branche Git a deployer (defaut: main)
|
||||
--ethan-repo-url Depot Git de l'application Ethan
|
||||
--ethan-branch Branche Git de l'application Ethan (defaut: main)
|
||||
--brice-repo-url Depot Git de l'application Brice
|
||||
--brice-branch Branche Git de l'application Brice (defaut: main)
|
||||
-h, --help Affiche cette aide
|
||||
EOF
|
||||
}
|
||||
@@ -49,6 +51,8 @@ LXC_HOSTNAME="chesscubing-web"
|
||||
REPO_BRANCH="main"
|
||||
ETHAN_REPO_URL="https://git.jeannerot.fr/Mineloulou/Chesscubing.git"
|
||||
ETHAN_REPO_BRANCH="main"
|
||||
BRICE_REPO_URL="https://git.jeannerot.fr/Lescratcheur/ChessCubing.git"
|
||||
BRICE_REPO_BRANCH="main"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
@@ -92,6 +96,14 @@ while [[ $# -gt 0 ]]; do
|
||||
ETHAN_REPO_BRANCH="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--brice-repo-url)
|
||||
BRICE_REPO_URL="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--brice-branch)
|
||||
BRICE_REPO_BRANCH="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
@@ -124,6 +136,8 @@ lxc_hostname="$2"
|
||||
repo_branch="$3"
|
||||
ethan_repo_url="$4"
|
||||
ethan_repo_branch="$5"
|
||||
brice_repo_url="$6"
|
||||
brice_repo_branch="$7"
|
||||
|
||||
die() {
|
||||
printf 'Erreur: %s\n' "$*" >&2
|
||||
@@ -181,11 +195,14 @@ trap 'printf \"Erreur: echec de la commande [%s] a la ligne %s.\\n\" \"\$BASH_CO
|
||||
|
||||
main_repo_dir='/opt/chesscubing/repo'
|
||||
ethan_repo_dir='/opt/chesscubing/ethan-repo'
|
||||
brice_repo_dir='/opt/chesscubing/brice-repo'
|
||||
publish_root='/opt/chesscubing/publish'
|
||||
web_root='/var/www/chesscubing/current'
|
||||
main_branch=\"\${1:-${repo_branch}}\"
|
||||
ethan_repo_url='${ethan_repo_url}'
|
||||
ethan_branch='${ethan_repo_branch}'
|
||||
brice_repo_url='${brice_repo_url}'
|
||||
brice_branch='${brice_repo_branch}'
|
||||
|
||||
ensure_dotnet_sdk() {
|
||||
if command -v dotnet >/dev/null 2>&1; then
|
||||
@@ -266,19 +283,32 @@ publish_static_tree() {
|
||||
--include='*.webp' \
|
||||
--include='*.ico' \
|
||||
--include='*.pdf' \
|
||||
--include='*.json' \
|
||||
--include='*.webmanifest' \
|
||||
--exclude='*' \
|
||||
\"\$source_dir/\" \"\$destination_dir/\"
|
||||
}
|
||||
|
||||
ensure_browser_stub() {
|
||||
local destination_dir=\"\$1\"
|
||||
local stub_path=\"\$destination_dir/cordova.js\"
|
||||
|
||||
if [[ ! -f \"\$stub_path\" ]]; then
|
||||
printf '%s\n' '// Browser stub for Cordova builds.' > \"\$stub_path\"
|
||||
fi
|
||||
}
|
||||
|
||||
sync_git_repo \"\$main_repo_dir\" '' \"\$main_branch\" 'principal'
|
||||
sync_git_repo \"\$ethan_repo_dir\" \"\$ethan_repo_url\" \"\$ethan_branch\" 'Ethan'
|
||||
sync_git_repo \"\$brice_repo_dir\" \"\$brice_repo_url\" \"\$brice_branch\" 'Brice'
|
||||
|
||||
install -d -m 0755 \"\$web_root\" \"\$publish_root\"
|
||||
|
||||
publish_blazor_app \"\$main_repo_dir\" \"\$publish_root/main\"
|
||||
rsync -a --delete \"\$publish_root/main/wwwroot/\" \"\$web_root/\"
|
||||
publish_static_tree \"\$ethan_repo_dir\" \"\$web_root/ethan\"
|
||||
publish_static_tree \"\$brice_repo_dir/www\" \"\$web_root/brice\"
|
||||
ensure_browser_stub \"\$web_root/brice\"
|
||||
|
||||
chown -R www-data:www-data \"\$web_root\"
|
||||
|
||||
@@ -304,11 +334,19 @@ server {
|
||||
try_files \$uri \$uri/ /ethan/index.html;
|
||||
}
|
||||
|
||||
location = /brice {
|
||||
return 301 \$scheme://\$http_host/brice/;
|
||||
}
|
||||
|
||||
location /brice/ {
|
||||
try_files \$uri \$uri/ /brice/index.html;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files \$uri \$uri/ /index.html;
|
||||
}
|
||||
|
||||
location ~* \.(?:css|js|mjs|png|jpg|jpeg|svg|webp|ico|pdf|webmanifest)$ {
|
||||
location ~* \.(?:css|js|json|mjs|png|jpg|jpeg|svg|webp|ico|pdf|webmanifest)$ {
|
||||
expires -1;
|
||||
add_header Cache-Control 'no-cache, no-store, must-revalidate';
|
||||
}
|
||||
@@ -337,7 +375,9 @@ if [[ "$LOCAL_MODE" == "1" ]]; then
|
||||
"$LXC_HOSTNAME" \
|
||||
"$REPO_BRANCH" \
|
||||
"$ETHAN_REPO_URL" \
|
||||
"$ETHAN_REPO_BRANCH"
|
||||
"$ETHAN_REPO_BRANCH" \
|
||||
"$BRICE_REPO_URL" \
|
||||
"$BRICE_REPO_BRANCH"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -366,4 +406,6 @@ sshpass -p "$PROXMOX_PASSWORD" \
|
||||
"$LXC_HOSTNAME" \
|
||||
"$REPO_BRANCH" \
|
||||
"$ETHAN_REPO_URL" \
|
||||
"$ETHAN_REPO_BRANCH" < "$payload_script"
|
||||
"$ETHAN_REPO_BRANCH" \
|
||||
"$BRICE_REPO_URL" \
|
||||
"$BRICE_REPO_BRANCH" < "$payload_script"
|
||||
|
||||
Reference in New Issue
Block a user