<commit_before>#!/bin/bash

# Stop on error
set -e

#Load settings
if [ -e settings ]; then
  . ./settings
else
  . ./settings.template
fi

####################
# Derived settings #
####################

CWD=$(pwd)
DOCKER_VOLUME_INTERNAL_PATH="/mnt"

##########
# SCRIPT #
##########

# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
   echo "WARNING: This script should be run as root or with permissions for docker" 1>&2
fi

#Stop existing CCU docker
./undeploy.sh

#Udev rule for HmIP-RFUSB
if [ -d /etc/udev/rules.d ] && [ ! -e /etc/udev/rules.d/99-Homematic.rules ]; then
  cp -av host/99-Homematic.rules /etc/udev/rules.d/
  udevadm control --reload-rules
  udevadm trigger --attr-match=subsystem=usb
fi

if which dpkg>/dev/null && ! modinfo eq3_char_loop >/dev/null 2>&1 ; then
  echo "Installing pivcpu extensions"

  #Add repository
  apt install -y wget
  wget -q -O - https://www.pivccu.de/piVCCU/public.key | apt-key add -
  bash -c 'echo "deb https://www.pivccu.de/piVCCU stable main" > /etc/apt/sources.list.d/pivccu.list'
  apt update

  #Install kernel headers
  if which armbian-config>/dev/null; then
    echo "Detected Armbian - install kernel sources and device tree"
    apt install -y `dpkg --get-selections | grep 'linux-image-' | grep '\sinstall' | sed -e 's/linux-image-\([a-z0-9-]\+\).*/linux-headers-\1/'`
    apt install -y pivccu-devicetree-armbian
  else
    echo "Uknown platform - trying generic way to install kernel headers"
    apt install -y linux-headers
  fi

  #Install UART drivers
  apt install -y pivccu-modules-dkms

  #Load eq3_char_loop module
  modprobe eq3_char_loop
  echo eq3_char_loop>/etc/modules-load.d/eq3_char_loop.conf

  echo "If you are connecting your Homematic adapter to a GPIO in Armbian you might need to reboot to get /dev/raw-uart"
fi

#Calculate common options
DOCKER_START_OPTS="--detach=true --name $DOCKER_NAME -p ${CCU_REGA_PORT}:80 -p ${CCU_RFD_PORT}:2001 -p ${CCU_TCLREGASCRIPT_PORT}:8181 -e PERSISTENT_DIR=${DOCKER_VOLUME_INTERNAL_PATH} --hostname $DOCKER_NAME $DOCKER_OPTIONS ${DOCKER_REPO}:${DOCKER_TAG}"
DOCKER_START_OPTS="--mount type=bind,src=/sys,dst=/sys --mount type=bind,src=/dev,dst=/dev --mount type=volume,src=${DOCKER_CCU_DATA},dst=${DOCKER_VOLUME_INTERNAL_PATH} ${DOCKER_START_OPTS}"
echo
if [ $DOCKER_MODE = swarm ] ; then
  echo "Starting as swarm service"

  #Install service that corrects permissions
  echo
  echo "Start ccu service"
  cp -a host/enableCCUDevices.sh /usr/local/sbin
  cp host/enableCCUDevices.service /etc/systemd/system/enableCCUDevices.service
  sed -i -e "s/DOCKER_NAME/$DOCKER_NAME/g"   /etc/systemd/system/enableCCUDevices.service
  systemctl daemon-reload<commit_msg>Correct linux headers to install<commit_after>#!/bin/bash

# Stop on error
set -e

#Load settings
if [ -e settings ]; then
  . ./settings
else
  . ./settings.template
fi

####################
# Derived settings #
####################

CWD=$(pwd)
DOCKER_VOLUME_INTERNAL_PATH="/mnt"

##########
# SCRIPT #
##########

# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
   echo "WARNING: This script should be run as root or with permissions for docker" 1>&2
fi

#Stop existing CCU docker
./undeploy.sh

#Udev rule for HmIP-RFUSB
if [ -d /etc/udev/rules.d ] && [ ! -e /etc/udev/rules.d/99-Homematic.rules ]; then
  cp -av host/99-Homematic.rules /etc/udev/rules.d/
  udevadm control --reload-rules
  udevadm trigger --attr-match=subsystem=usb
fi

if which dpkg>/dev/null && ! modinfo eq3_char_loop >/dev/null 2>&1 ; then
  echo "Installing pivcpu extensions"

  #Add repository
  apt install -y wget
  wget -q -O - https://www.pivccu.de/piVCCU/public.key | apt-key add -
  bash -c 'echo "deb https://www.pivccu.de/piVCCU stable main" > /etc/apt/sources.list.d/pivccu.list'
  apt update

  #Install kernel headers
  if which armbian-config>/dev/null; then
    echo "Detected Armbian - install kernel sources and device tree"
    apt install -y `dpkg --get-selections | grep 'linux-image-' | grep '\sinstall' | sed -e 's/linux-image-\([a-z0-9-]\+\).*/linux-headers-\1/'`
    apt install -y pivccu-devicetree-armbian
  else
    echo "Uknown platform - trying generic way to install kernel headers"
    apt install -y linux-headers-$(uname -r)
  fi

  #Install UART drivers
  apt install -y pivccu-modules-dkms

  #Load eq3_char_loop module
  modprobe eq3_char_loop
  echo eq3_char_loop>/etc/modules-load.d/eq3_char_loop.conf

  echo "If you are connecting your Homematic adapter to a GPIO in Armbian you might need to reboot to get /dev/raw-uart"
fi

#Calculate common options
DOCKER_START_OPTS="--detach=true --name $DOCKER_NAME -p ${CCU_REGA_PORT}:80 -p ${CCU_RFD_PORT}:2001 -p ${CCU_TCLREGASCRIPT_PORT}:8181 -e PERSISTENT_DIR=${DOCKER_VOLUME_INTERNAL_PATH} --hostname $DOCKER_NAME $DOCKER_OPTIONS ${DOCKER_REPO}:${DOCKER_TAG}"
DOCKER_START_OPTS="--mount type=bind,src=/sys,dst=/sys --mount type=bind,src=/dev,dst=/dev --mount type=volume,src=${DOCKER_CCU_DATA},dst=${DOCKER_VOLUME_INTERNAL_PATH} ${DOCKER_START_OPTS}"
echo
if [ $DOCKER_MODE = swarm ] ; then
  echo "Starting as swarm service"

  #Install service that corrects permissions
  echo
  echo "Start ccu service"
  cp -a host/enableCCUDevices.sh /usr/local/sbin
  cp host/enableCCUDevices.service /etc/systemd/system/enableCCUDevices.service
  sed -i -e "s/DOCKER_NAME/$DOCKER_NAME/g"   /etc/systemd/system/enableCCUDevices.service
  systemctl daemon-reload
{'fraction_non_alphanumeric': 0.1438040876450009, 'fraction_numerical': 0.009942920272509667, 'mean_word_length': 3.8761220825852782, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '2420132', 'n_tokens_mistral': 2090, 'n_tokens_neox': 1985, 'n_words': 510}