49 lines
1.4 KiB
Bash
Executable File
49 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Runs INSIDE the LXC container as root (pushed + executed by build.sh).
|
|
# Installs Docker and clones NewsAtlas. Deliberately does NOT touch .env or
|
|
# start the stack — build.sh pushes the generated .env and starts the stack
|
|
# as separate steps afterward, so a plain `git clone` here never collides
|
|
# with an already-placed .env file.
|
|
set -euo pipefail
|
|
|
|
REPO_URL="${1:?usage: provision.sh <repo_url> <branch> <app_dir>}"
|
|
BRANCH="${2:?usage: provision.sh <repo_url> <branch> <app_dir>}"
|
|
APP_DIR="${3:?usage: provision.sh <repo_url> <branch> <app_dir>}"
|
|
|
|
. /etc/os-release
|
|
|
|
install_docker_apt() {
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
apt-get update
|
|
apt-get install -y ca-certificates curl gnupg git jq
|
|
curl -fsSL https://get.docker.com | sh
|
|
systemctl enable docker
|
|
systemctl start docker
|
|
}
|
|
|
|
install_docker_apk() {
|
|
apk update
|
|
apk add --no-cache docker docker-cli-compose git jq openrc
|
|
rc-update add docker default
|
|
service docker start
|
|
}
|
|
|
|
case "$ID" in
|
|
debian|ubuntu) install_docker_apt ;;
|
|
alpine) install_docker_apk ;;
|
|
*)
|
|
echo "provision.sh: unsupported distro '$ID' (expected debian, ubuntu, or alpine)" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
if [ -d "$APP_DIR/.git" ]; then
|
|
git -C "$APP_DIR" fetch origin "$BRANCH"
|
|
git -C "$APP_DIR" checkout "$BRANCH"
|
|
git -C "$APP_DIR" reset --hard "origin/$BRANCH"
|
|
else
|
|
git clone --branch "$BRANCH" --depth 1 "$REPO_URL" "$APP_DIR"
|
|
fi
|
|
|
|
echo "provision.sh: done. Docker installed, repo at $APP_DIR."
|