2023-04-24 10:11:09 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
driglibash_run_retry=true
|
|
|
|
|
. driglibash-base
|
2023-12-20 17:06:09 +00:00
|
|
|
|
set -u
|
2023-04-24 10:11:09 +00:00
|
|
|
|
|
2023-09-07 17:50:05 +00:00
|
|
|
|
# Already done at upload time ?
|
|
|
|
|
#run gen_env.sh
|
2023-08-28 18:25:32 +00:00
|
|
|
|
|
2023-04-24 10:11:09 +00:00
|
|
|
|
###############################################################################
|
|
|
|
|
# Variables
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
2023-09-13 08:46:02 +00:00
|
|
|
|
set -a
|
|
|
|
|
. /etc/jeancloud.env
|
|
|
|
|
set +a
|
2023-04-24 10:11:09 +00:00
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Helpers
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
# Path to this directory
|
|
|
|
|
here="$(where 'follow_links')"
|
|
|
|
|
|
|
|
|
|
|
2023-09-07 17:50:05 +00:00
|
|
|
|
###############################################################################
|
|
|
|
|
# Test system requirements
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
[ ! -f /data/mounted ] && die "/data is not mounted"
|
2023-04-24 10:11:09 +00:00
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Nginx preparation
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
driglibash_section_prefix="[Prepare nginx] "
|
2023-08-28 18:25:32 +00:00
|
|
|
|
section "Delete new conf directory (to start from scratch)"
|
2023-04-24 10:11:09 +00:00
|
|
|
|
run rm -rf "$new_nginx_conf_path"
|
|
|
|
|
|
|
|
|
|
section "Create new conf file (for tests purposes)"
|
2023-10-31 15:42:06 +00:00
|
|
|
|
sed "s#$nginx_conf_path#$new_nginx_conf_path/#" "/docker/_proxy/nginx.conf" > "$proxy_dir/new_nginx.conf"
|
2023-04-24 10:11:09 +00:00
|
|
|
|
|
|
|
|
|
section "Create proxy dir"
|
|
|
|
|
run mkdir -p "$proxy_dir" /docker /data
|
|
|
|
|
run chown root:root /docker
|
|
|
|
|
run chown root:root /data
|
|
|
|
|
run chmod 755 /docker
|
|
|
|
|
run chmod 755 /data
|
|
|
|
|
|
|
|
|
|
section "Create new conf directory"
|
|
|
|
|
run mkdir -p "$new_nginx_conf_path"
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Deploy services
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
2023-08-28 18:25:32 +00:00
|
|
|
|
section "Start docker"
|
|
|
|
|
run systemctl start docker docker.socket
|
|
|
|
|
|
2023-12-20 17:06:09 +00:00
|
|
|
|
# List of failed services
|
|
|
|
|
failed=""
|
|
|
|
|
|
2024-01-02 16:50:14 +00:00
|
|
|
|
while IFS=';' read -r id username service target
|
|
|
|
|
do
|
2023-09-07 17:50:05 +00:00
|
|
|
|
|
|
|
|
|
echo -n "$service -> "
|
|
|
|
|
[ ! -d "/docker/$service" ] && die "/docker/$service directory not found"
|
|
|
|
|
|
|
|
|
|
# Check if service target is localhost
|
|
|
|
|
[[ "$(getent hosts $target)" != "::1 "* ]] && echo 'Not here' && continue
|
|
|
|
|
|
|
|
|
|
echo "Deploying"
|
2023-08-28 18:25:32 +00:00
|
|
|
|
deploy_service.sh "$service" "noreload"
|
2024-01-02 16:50:14 +00:00
|
|
|
|
|
2023-12-20 17:06:09 +00:00
|
|
|
|
if [ "$?" -ne 0 ] ; then
|
|
|
|
|
failed="$failed $service"
|
|
|
|
|
fi
|
2023-04-24 10:11:09 +00:00
|
|
|
|
|
2024-01-02 16:50:14 +00:00
|
|
|
|
done < <(grep -v '^#' /docker/services.csv)
|
2023-04-24 10:11:09 +00:00
|
|
|
|
|
2023-08-28 18:25:32 +00:00
|
|
|
|
restart_nginx.sh
|
2023-04-24 10:11:09 +00:00
|
|
|
|
|
2023-12-20 17:06:09 +00:00
|
|
|
|
if [ -n "$failed" ] ; then
|
|
|
|
|
echo "FAILED SERVICES"
|
|
|
|
|
echo "$failed"
|
|
|
|
|
fi
|
|
|
|
|
|
2023-04-24 10:11:09 +00:00
|
|
|
|
clean
|