<commit_before>#!/usr/bin/env bash
set -eu
export LC_ALL=C

SWAP_PATH=/var/vm
SWAP_FILE=swapfile1

cat <<EOF
#cloud-config
---
# Before commit any change please validate this file @ https://coreos.com/validate/

# Set hostname
hostname: ${NODE_HOSTNAME}

# Set SSH Key
ssh_authorized_keys:
- ${NODE_PUBLIC_KEY}

coreos:
  update:
    reboot-strategy: ${COREOS_REBOOT_STRATEGY:-"etcd-lock"}
  units:
    - name: docker.service
      drop-ins:
      - name: 20-docker-opts.conf
        content: |
          [Service]
          Environment="DOCKER_OPTS=--log-opt max-size=50m --log-opt max-file=5"
    - name: systemd-networkd.service
      command: stop
    - name: 00-${NODE_NET_DEVICE}.network
      runtime: true
      content: |
        [Match]
        Name=${NODE_NET_DEVICE}

        [Network]
        DNS=${NODE_DNS}
        Address=${NODE_ADDRESS}/${NODE_NETWORK_RANGE}
        Gateway=${NODE_GATEWAY}
    - name: down-interfaces.service
      command: start
      content: |
        [Service]
        Type=oneshot
        ExecStart=/usr/bin/ip link set ${NODE_NET_DEVICE} down
        ExecStart=/usr/bin/ip addr flush dev ${NODE_NET_DEVICE}
    - name: systemd-networkd.service
      command: restart
    - name: swap.service
      enable: true
      contents: |
        [Unit]
        Description=Turn on swap

        [Service]
        Type=oneshot
        ExecStartPre=-/usr/bin/rm -rf ${SWAP_PATH}
        ExecStartPre=/usr/bin/mkdir -p ${SWAP_PATH}
        ExecStartPre=/usr/bin/touch ${SWAP_PATH}/${SWAP_FILE}
        ExecStartPre=/bin/bash -c "fallocate -l 4096m ${SWAP_PATH}/${SWAP_FILE}"
        ExecStartPre=/usr/bin/chmod 600 ${SWAP_PATH}/${SWAP_FILE}
        ExecStartPre=/usr/sbin/mkswap ${SWAP_PATH}/${SWAP_FILE}
        ExecStartPre=/usr/sbin/sysctl vm.swappiness=10
        ExecStart=/sbin/swapon ${SWAP_PATH}/${SWAP_FILE}
        ExecStop=/sbin/swapoff ${SWAP_PATH}/${SWAP_FILE}
        ExecStopPost=-/usr/bin/rm -rf ${SWAP_PATH}
        RemainAfterExit=true

        [Install]
        WantedBy=multi-user.target
EOF<commit_msg>Fix coreos cloud-config<commit_after>#!/usr/bin/env bash
set -eu
export LC_ALL=C

SWAPFILE=/2GiB.swap

cat <<EOF
#cloud-config
---
# Before commit any change please validate this file @ https://coreos.com/validate/

# Set hostname
hostname: ${NODE_HOSTNAME}

# Set SSH Key
ssh_authorized_keys:
- ${NODE_PUBLIC_KEY}

coreos:
  update:
    reboot-strategy: ${COREOS_REBOOT_STRATEGY:-"etcd-lock"}
  units:
    - name: docker.service
      drop-ins:
      - name: 20-docker-opts.conf
        content: |
          [Service]
          Environment="DOCKER_OPTS=--log-opt max-size=50m --log-opt max-file=5"
    - name: systemd-networkd.service
      command: stop
    - name: 00-${NODE_NET_DEVICE}.network
      runtime: true
      content: |
        [Match]
        Name=${NODE_NET_DEVICE}

        [Network]
        DNS=${NODE_DNS}
        Address=${NODE_ADDRESS}/${NODE_NETWORK_RANGE}
        Gateway=${NODE_GATEWAY}
    - name: down-interfaces.service
      command: start
      content: |
        [Service]
        Type=oneshot
        ExecStart=/usr/bin/ip link set ${NODE_NET_DEVICE} down
        ExecStart=/usr/bin/ip addr flush dev ${NODE_NET_DEVICE}
    - name: systemd-networkd.service
      command: restart
    - name: systemd-sysctl.service
      command: restart
    - name: create-swap.service
      command: start
      runtime: true
      content: |
        [Unit]
        Description=Create swap file
        Before=swap.service

        [Service]
        Type=oneshot
        ExecStart=/usr/bin/touch ${SWAPFILE}
        ExecStart=/usr/bin/chattr +C ${SWAPFILE}
        ExecStart=/usr/bin/fallocate -l 2048m ${SWAPFILE}
        ExecStart=/usr/bin/chmod 600 ${SWAPFILE}
        ExecStart=/usr/sbin/mkswap ${SWAPFILE}

        [Install]
        WantedBy=multi-user.target
    - name: swap.service
      command: start
      content: |
        [Unit]
        Description=Turn on swap

        [Service]
        Type=oneshot
        RemainAfterExit=true
        ExecStartPre=/usr/sbin/losetup -f ${SWAPFILE}
        ExecStart=/usr/bin/sh -c "/sbin/swapon $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)"
        ExecStop=/usr/bin/sh -c "/sbin/swapoff $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)"
        ExecStopPost=/usr/bin/sh -c "/usr/sbin/losetup -d $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)"

        [Install]
        WantedBy=multi-user.target
EOF
{'fraction_non_alphanumeric': 0.13085368586152812, 'fraction_numerical': 0.007842258570468295, 'mean_word_length': 2.3488372093023258, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3735214', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1538, 'n_words': 288}