2023-04-27 09:29:02 +00:00
|
|
|
#!/bin/bash
|
2023-04-27 12:45:45 +00:00
|
|
|
## Do not modify this file. You will lost the ability to installation and autoupdate!
|
2023-04-28 12:39:14 +00:00
|
|
|
|
|
|
|
###########
|
2023-05-03 07:57:06 +00:00
|
|
|
## Always run "php artisan app:sync-to-bunny-cdn --env=secrets" or "scripts/run sync-bunny" if you update this file.
|
2023-04-28 12:39:14 +00:00
|
|
|
###########
|
|
|
|
|
|
|
|
VERSION="1.0.0"
|
2023-05-03 07:57:06 +00:00
|
|
|
DOCKER_VERSION="23.0"
|
|
|
|
|
2023-04-28 11:50:27 +00:00
|
|
|
CDN="https://coolify-cdn.b-cdn.net/files"
|
2023-04-28 13:30:42 +00:00
|
|
|
OS_TYPE=$(cat /etc/os-release | grep -w "ID" | cut -d "=" -f 2 | tr -d '"')
|
|
|
|
OS_VERSION=$(cat /etc/os-release | grep -w "VERSION_ID" | cut -d "=" -f 2 | tr -d '"')
|
2023-05-11 13:29:06 +00:00
|
|
|
LATEST_VERSION=$(curl --silent https://coolify-cdn.b-cdn.net/versions.json | grep -i version | sed -n '2p' | xargs | awk '{print $2}' | tr -d ',')
|
2023-04-27 12:45:45 +00:00
|
|
|
|
2023-05-03 07:01:58 +00:00
|
|
|
if [ $EUID != 0 ]; then
|
2023-04-27 09:29:02 +00:00
|
|
|
echo "Please run as root"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! [ -x "$(command -v docker)" ]; then
|
|
|
|
echo "Docker is not installed. Installing Docker..."
|
2023-05-03 07:57:06 +00:00
|
|
|
curl https://releases.rancher.com/install-docker/${DOCKER_VERSION}.sh | sh
|
2023-04-27 09:29:02 +00:00
|
|
|
echo "Docker installed successfully"
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p /data/coolify/deployments
|
2023-05-25 11:29:15 +00:00
|
|
|
mkdir -p /data/coolify/ssh/keys
|
|
|
|
mkdir -p /data/coolify/ssh/mux
|
2023-04-27 09:29:02 +00:00
|
|
|
mkdir -p /data/coolify/source
|
2023-05-26 07:53:30 +00:00
|
|
|
mkdir -p /data/coolify/proxy/dynamic
|
2023-04-27 09:29:02 +00:00
|
|
|
|
2023-04-27 10:25:32 +00:00
|
|
|
chown -R 9999:root /data
|
2023-04-27 09:29:02 +00:00
|
|
|
chmod -R 700 /data
|
|
|
|
|
2023-04-28 13:30:42 +00:00
|
|
|
echo "Downloading required files from CDN..."
|
2023-04-28 11:50:27 +00:00
|
|
|
curl -fsSL $CDN/docker-compose.yml -o /data/coolify/source/docker-compose.yml
|
|
|
|
curl -fsSL $CDN/docker-compose.prod.yml -o /data/coolify/source/docker-compose.prod.yml
|
|
|
|
curl -fsSL $CDN/.env.production -o /data/coolify/source/.env.production
|
|
|
|
curl -fsSL $CDN/upgrade.sh -o /data/coolify/source/upgrade.sh
|
2023-04-27 09:29:02 +00:00
|
|
|
|
|
|
|
# Copy .env.example if .env does not exist
|
|
|
|
if [ ! -f /data/coolify/source/.env ]; then
|
2023-04-27 12:50:42 +00:00
|
|
|
cp /data/coolify/source/.env.production /data/coolify/source/.env
|
2023-04-27 09:29:02 +00:00
|
|
|
sed -i "s|APP_KEY=.*|APP_KEY=base64:$(openssl rand -base64 32)|g" /data/coolify/source/.env
|
|
|
|
sed -i "s|DB_PASSWORD=.*|DB_PASSWORD=$(openssl rand -base64 32)|g" /data/coolify/source/.env
|
2023-05-10 07:26:25 +00:00
|
|
|
sed -i "s|REDIS_PASSWORD=.*|REDIS_PASSWORD=$(openssl rand -base64 32)|g" /data/coolify/source/.env
|
2023-04-27 09:29:02 +00:00
|
|
|
fi
|
|
|
|
|
2023-05-25 11:29:15 +00:00
|
|
|
# Generate an ssh key (ed25519) at /data/coolify/ssh/keys/id.root@host.docker.internal
|
|
|
|
if [ ! -f /data/coolify/ssh/keys/id.root@host.docker.internal ]; then
|
|
|
|
ssh-keygen -t ed25519 -f /data/coolify/ssh/keys/id.root@host.docker.internal -q -N "" -C root@coolify
|
|
|
|
chown 9999 /data/coolify/ssh/keys/id.root@host.docker.internal
|
2023-04-27 09:29:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
addSshKey() {
|
2023-05-25 11:29:15 +00:00
|
|
|
cat /data/coolify/ssh/keys/id.root@host.docker.internal.pub >> ~/.ssh/authorized_keys
|
2023-04-27 09:29:02 +00:00
|
|
|
chmod 600 ~/.ssh/authorized_keys
|
|
|
|
}
|
|
|
|
|
2023-04-27 12:45:45 +00:00
|
|
|
if [ ! -f ~/.ssh/authorized_keys ]; then
|
2023-04-27 09:29:02 +00:00
|
|
|
mkdir -p ~/.ssh
|
|
|
|
chmod 700 ~/.ssh
|
|
|
|
touch ~/.ssh/authorized_keys
|
|
|
|
addSshKey
|
|
|
|
fi
|
2023-04-27 12:45:45 +00:00
|
|
|
|
2023-04-27 09:29:02 +00:00
|
|
|
if [ -z "$(grep -w "root@coolify" ~/.ssh/authorized_keys)" ]; then
|
|
|
|
addSshKey
|
|
|
|
fi
|
|
|
|
|
2023-04-28 13:30:42 +00:00
|
|
|
bash /data/coolify/source/upgrade.sh ${LATEST_VERSION:-latest}
|