Hi Everyone i am trying to create Mailcow server into my server through scripts while creating Hetzner server currently i create Hetzner server through API and pass to create mailcow server scripts through payload the same scripts when i try to create manually it works and UI also accessible but through the API it didn’t works can you guys helps me here is a scripts that i try to run through Hetzner Payload

Payload for Hetzner

payload = {
name: “#{domain_name}”,
server_type: “cx22”,
image: “ubuntu-24.04”,
location: “nbg1”,
ssh_keys: [ Figaro.env.SSH_KEYS_NAME ],
public_net: { enable_ipv4: true, enable_ipv6: false },
start_after_create: true,
user_data: user_data
}

Scripts that i passed on user_data
<<SCRIPT
#cloud-config
runcmd:
- apt-get update && apt upgrade -y
- apt install -y ca-certificates curl gnupg
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg

| sudo gpg –dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- echo “deb [arch=$(dpkg –print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] Index of linux/ubuntu/
download.docker.com
Index of linux/ubuntu/
$(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- apt update
- apt install -y docker-ce docker-ce-cli containerd.io
- sudo usermod -aG docker $USER
- sudo curl -L “docker/composereleases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest
api.github.com
https://api.github.com/repos/docker/compose/releases/latest
No preview could be generated for this link
| grep ‘tag_name’ | cut -d’”' -f4)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- sudo chmod +x /usr/local/bin/docker-compose
- sleep 30
- systemctl enable docker
- systemctl start docker
- sleep 10

      # open ports
      - ufw allow 80/tcp
      - ufw allow 443/tcp
      - ufw allow 25/tcp
      - ufw allow 587/tcp
      - ufw reload

      # Set up mail server
      - umask
      - cd /opt/
      - git clone https://github.com/mailcow/mailcow-dockerized
      - cd mailcow-dockerized
      - echo "MAILCOW_HOSTNAME=mail.#{domain_name}" >> mailcow.conf
      - ./generate_config.sh
      - docker-compose pull
      - docker-compose up -d
      - sleep 120
  SCRIPT
    • DocFraggle

      • Community Hero
      Moolevel 282

    Prajwal77777 ./generate_config.sh

    Running this script asks for your input to generate the mailcow.conf file, it’s interactive. I guess you have to skip this step and provide the mailcow.conf file yourself instead, containing all necessary data like hostname, database password etc

    Have something to say?

    Join the community by quickly registering to participate in this discussion. We'd like to see you joining our great moo-community!

    No one is typing