<commit_before>#!/bin/bash

# Log everything to file
exec &> >(tee -a "/var/log/first-boot.log")

timestamp() { date +"%F_%T_%Z"; }

echo "$(timestamp) [openHABian] Booting for the first time!"
rm -f /opt/openHABian-install-failed
touch /opt/openHABian-install-inprogress

echo "$(timestamp) [openHABian] Ensuring network connectivity... "
cnt=0
until ping -c1 8.8.8.8 &>/dev/null; do
  sleep 1
  cnt=$((cnt + 1))
  if [ $cnt -eq 100 ]; then
    echo "$(timestamp) [openHABian] Network unreachable, can't continue. Please reboot and let me try again."
    exit 0
  fi
done

echo -n "$(timestamp) [openHABian] Waiting for dpkg/apt to get ready... "
until apt update &>/dev/null; do sleep 1; done
echo "OK"

echo -n "$(timestamp) [openHABian] Updating repositories and upgrading installed packages... "
apt update &>/dev/null
apt --yes upgrade &>/dev/null
if [ $? -eq 0 ]; then echo "OK"; else echo "FAILED"; exit 1; fi

echo -n "$(timestamp) [openHABian] Installing git package... "
/usr/bin/apt -y install git &>/dev/null
if [ $? -eq 0 ]; then echo "OK"; else echo "FAILED"; exit 1; fi

echo -n "$(timestamp) [openHABian] Cloning myself... "
/usr/bin/git clone -b pine64-build https://github.com/openhab/openhabian.git /opt/openhabian &>/dev/null
if [ $? -eq 0 ]; then echo "OK"; else echo "FAILED"; exit 1; fi
ln -sfn /opt/openhabian/openhabian-setup.sh /usr/local/bin/openhabian-config

echo -n "$(timestamp) [openHABian] Copying configuration and first boot script... "
cp /opt/openhabian/build-pine64-image/openhabian.pine64.conf /etc/openhabian.conf
if [ $? -eq 0 ]; then echo "OK"; else echo "FAILED"; exit 1; fi

echo "$(timestamp) [openHABian] === Executing 'openhabian-setup.sh' ==="
if (/bin/bash /opt/openhabian/openhabian-setup.sh unattended); then
  systemctl start openhab2.service
  rm -f /opt/openHABian-install-inprogress
  touch /opt/openHABian-install-successful
else
  touch /opt/openHABian-install-failed
fi
echo "$(timestamp) [openHABian] === Finished executing 'openhabian-setup.sh' ==="<commit_msg>Switch pine64 image to master branch<commit_after>#!/bin/bash

# Log everything to file
exec &> >(tee -a "/var/log/first-boot.log")

timestamp() { date +"%F_%T_%Z"; }

echo "$(timestamp) [openHABian] Booting for the first time!"
rm -f /opt/openHABian-install-failed
touch /opt/openHABian-install-inprogress

echo "$(timestamp) [openHABian] Ensuring network connectivity... "
cnt=0
until ping -c1 8.8.8.8 &>/dev/null; do
  sleep 1
  cnt=$((cnt + 1))
  if [ $cnt -eq 100 ]; then
    echo "$(timestamp) [openHABian] Network unreachable, can't continue. Please reboot and let me try again."
    exit 0
  fi
done

echo -n "$(timestamp) [openHABian] Waiting for dpkg/apt to get ready... "
until apt update &>/dev/null; do sleep 1; done
echo "OK"

echo -n "$(timestamp) [openHABian] Updating repositories and upgrading installed packages... "
apt update &>/dev/null
apt --yes upgrade &>/dev/null
if [ $? -eq 0 ]; then echo "OK"; else echo "FAILED"; exit 1; fi

echo -n "$(timestamp) [openHABian] Installing git package... "
/usr/bin/apt -y install git &>/dev/null
if [ $? -eq 0 ]; then echo "OK"; else echo "FAILED"; exit 1; fi

echo -n "$(timestamp) [openHABian] Cloning myself... "
/usr/bin/git clone -b master https://github.com/openhab/openhabian.git /opt/openhabian &>/dev/null
if [ $? -eq 0 ]; then echo "OK"; else echo "FAILED"; exit 1; fi
ln -sfn /opt/openhabian/openhabian-setup.sh /usr/local/bin/openhabian-config

echo -n "$(timestamp) [openHABian] Copying configuration and first boot script... "
cp /opt/openhabian/build-pine64-image/openhabian.pine64.conf /etc/openhabian.conf
if [ $? -eq 0 ]; then echo "OK"; else echo "FAILED"; exit 1; fi

echo "$(timestamp) [openHABian] === Executing 'openhabian-setup.sh' ==="
if (/bin/bash /opt/openhabian/openhabian-setup.sh unattended); then
  systemctl start openhab2.service
  rm -f /opt/openHABian-install-inprogress
  touch /opt/openHABian-install-successful
else
  touch /opt/openHABian-install-failed
fi
echo "$(timestamp) [openHABian] === Finished executing 'openhabian-setup.sh' ==="
{'fraction_non_alphanumeric': 0.1593203644422556, 'fraction_numerical': 0.013789706968726915, 'mean_word_length': 3.899879372738239, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6623761', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1421, 'n_words': 445}