<commit_before>#!/bin/bash

# This script should only handle upgrade, nothing else

cd /home/pi/firewalla
cd .git
sudo chown -R pi *
cd ..
branch=$(git rev-parse --abbrev-ref HEAD)

GITHUB_STATUS_API=https://status.github.com/api.json

GITHUB_LIVE=0

for i in `seq 1 5`; do
    HTTP_STATUS_CODE=`curl -s -o /dev/null -w "%{http_code}" $GITHUB_STATUS_API`
    if [[ $HTTP_STATUS_CODE == "200" ]]; then
      break;
    fi
    sleep 1
done


# continue to try upgrade even github api is not successfully.
# very likely to fail

if [[ $branch =~ release.* ]]; then
  sudo -u pi git fetch origin $branch
  sudo -u pi git reset --hard origin/$branch
  echo "on release"

  # in case there is some upgrade change on firewalla.service
  # all the rest services will be updated (in case) via firewalla.service
  sudo cp /home/pi/firewalla/etc/firewalla.service /etc/systemd/system/.
  sudo cp /home/pi/firewalla/etc/fireupgrade.service /etc/systemd/system/.
  sudo systemctl daemon-reload
  sudo systemctl reenable firewalla
  sudo systemctl reenable fireupgrade
else
    # even on dev/beta branch, it will also upgrade unless there is a no upgrade flag
    # this might be changed if there is an official beta release branch<commit_msg>test git 2<commit_after>#!/bin/bash

# This script should only handle upgrade, nothing else

cd /home/pi/firewalla
cd .git
sudo chown -R pi *
cd ..
branch=$(git rev-parse --abbrev-ref HEAD)

GITHUB_STATUS_API=https://status.github.com/api.json

GITHUB_LIVE=0

for i in `seq 1 5`; do
    HTTP_STATUS_CODE=`curl -s -o /dev/null -w "%{http_code}" $GITHUB_STATUS_API`
    if [[ $HTTP_STATUS_CODE == "200" ]]; then
      break;
    fi
    sleep 1
done

# continue to try upgrade even github api is not successfully.
# very likely to fail

if [[ $branch =~ release.* ]]; then
  sudo -u pi git fetch origin $branch
  sudo -u pi git reset --hard origin/$branch
  echo "on release"

  # in case there is some upgrade change on firewalla.service
  # all the rest services will be updated (in case) via firewalla.service
  sudo cp /home/pi/firewalla/etc/firewalla.service /etc/systemd/system/.
  sudo cp /home/pi/firewalla/etc/fireupgrade.service /etc/systemd/system/.
  sudo systemctl daemon-reload
  sudo systemctl reenable firewalla
  sudo systemctl reenable fireupgrade
else
    # even on dev/beta branch, it will also upgrade unless there is a no upgrade flag
    # this might be changed if there is an official beta release branch
{'fraction_non_alphanumeric': 0.09535452322738386, 'fraction_numerical': 0.006112469437652812, 'mean_word_length': 3.3839285714285716, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7283151', 'n_tokens_mistral': 837, 'n_tokens_neox': 782, 'n_words': 299}