diff --git a/rootfs/root/docker/setup/01-system.sh b/rootfs/root/docker/setup/01-system.sh index bd92656..f4cf172 100755 --- a/rootfs/root/docker/setup/01-system.sh +++ b/rootfs/root/docker/setup/01-system.sh @@ -24,10 +24,37 @@ set -o pipefail # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set env variables exitCode=0 - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Predifined actions +cat <"/etc/rc.local" +#!/bin/bash +# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES +[ ! -f "/data/.installed" ] && [ -f "/usr/local/bin/coolify-setup" ] && export COOLIFY_INIT=yes;bash -c "/usr/local/bin/coolify-setup" + +touch /var/lock/subsys/local +exit 0 +EOF +cat <"/etc/systemd/system/rc-local.service" +[Unit] +Description=/etc/rc.local +ConditionPathExists=/etc/rc.local +After=network.target + +[Service] +Type=forking +ExecStart=/etc/rc.local start +TimeoutSec=0 +StandardOutput=tty +RemainAfterExit=yes +SysVStartPriority=99 + +[Install] +WantedBy=multi-user.target +HERE +sudo chmod +x /etc/rc.local +systemctl daemon-reload +systemctl enable rc-local # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Main script diff --git a/rootfs/root/docker/setup/02-packages.sh b/rootfs/root/docker/setup/02-packages.sh index 0205c7a..c62316e 100755 --- a/rootfs/root/docker/setup/02-packages.sh +++ b/rootfs/root/docker/setup/02-packages.sh @@ -27,13 +27,7 @@ exitCode=0 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Predifined actions -apt-get update -apt-get install -y ca-certificates curl -install -m 0755 -d /etc/apt/keyrings -curl -q -LSsf "https://download.docker.com/linux/debian/gpg" -o "/etc/apt/keyrings/docker.asc" -chmod a+r /etc/apt/keyrings/docker.asc -printf '%s %s\n' "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian" "$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list >/dev/null -apt-get update && apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Main script diff --git a/rootfs/usr/local/bin/coolify-setup b/rootfs/usr/local/bin/coolify-setup index 588952f..25fa870 100755 --- a/rootfs/usr/local/bin/coolify-setup +++ b/rootfs/usr/local/bin/coolify-setup @@ -24,12 +24,13 @@ set -o pipefail # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set env variables exitCode=0 - +[ -f "/data/.installed" ] || COOLIFY_INIT=yes # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Predifined actions -if [ ! -f "/data/coolify/source/.env" ]; then - [ -d "/data/coolify/source" ] || mkdir -p /data/coolify/source - cat <"/data/coolify/source/.env" +if [ "$COOLIFY_INIT" = "yes" ]; then + if [ ! -f "/data/coolify/source/.env" ]; then + [ -d "/data/coolify/source" ] || mkdir -p /data/coolify/source + cat <"/data/coolify/source/.env" APP_NAME=\${APP_NAME:-Coolify} APP_ID=\${APP_ID:-$(openssl rand -hex 16)} APP_KEY=base64:\${APP_KEY:-$(openssl rand -base64 32)} @@ -48,14 +49,30 @@ PUSHER_APP_KEY=\${PUSHER_APP_KEY:-$(openssl rand -hex 32)} PUSHER_APP_SECRET=\${PUSHER_APP_SECRET:-$(openssl rand -hex 32)} HERE + fi + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + mkdir -p /data/coolify/proxy/dynamic + mkdir -p /data/coolify/ssh/{keys,mux} + mkdir -p /data/coolify/{source,ssh,applications,databases,backups,services,proxy,webhooks-during-maintenance} + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + [ -d "$HOME/.ssh" ] || mkdir -p "$HOME/.ssh" + [ -f "$HOME/.ssh/authorized_keys" ] || touch "$HOME/.ssh/authorized_keys" + [ -f "/data/coolify/ssh/keys/id.root@host.docker.internal" ] || ssh-keygen -f /data/coolify/ssh/keys/id.root@host.docker.internal -t ed25519 -N '' -C root@coolify + SSH_PUB_KEY="$(<"cat /data/coolify/ssh/keys/id.root@host.docker.internal.pub")" + if ! grep -q "$SSH_PUB_KEY" "$HOME/.ssh/authorized_keys"; then + cat /data/coolify/ssh/keys/id.root@host.docker.internal.pub >>"$HOME/.ssh/authorized_keys" + fi + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + chmod 700 "$HOME/.ssh" + chmod 600 "$HOME/.ssh/authorized_keys" + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash + exitCode=$? + [ $exitCode -eq 0 ] && echo "$(date)" >"/data/.installed" fi # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -[ "$COOLIFY_INIT" != "yes" ] || curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Main script # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set the exit code -exitCode=$? -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - exit $exitCode