<commit_before>#!/bin/bash


# main

[ $# -eq 0 ] && usage

if [ "${0:0:1}" != / ]; then
  error "please run this script with the full path, non-relative."
fi
script_dir=`dirname "$0"`

if [ $EUID -ne 0 ]; then
  echo "Error: This script needs to run with ROOT privileges." 1>&2
  exit 1
fi

unset confirmed
getopt_flags='yd'
while getopts $getopt_flags OPTN; do
  case "$OPTN" in
    y)
      confirmed=1
      ;;
    d)
      set -x
      ;;
  esac
done
shift $(( $OPTIND - 1 ))

if [ -z "$confirmed" ]; then
  echo "Error: please use option -y to confirm that you really want to uninstall the software and lose data" 1>&2
  exit 1
fi

install_dir="$1"
if [[ "$install_dir" =~ ^/*$ ]]; then
  echo "Error: install_dir can't be /" 1>&2
  exit 1
fi

dp_user="devpanel"
dp_group="$dp_user"

vagrant_dir=~devpanel/vagrant
if [ -d "$vagrant_dir" ]; then
  for D in "$vagrant_dir"/*; do
    if [ -d "$D" ]; then
      echo "Destroying VM `basename "$D"`..."
      su -l devpanel cd "$D" \&\& vagrant destroy -f \; cd "$D/.." \; rm -rf "$D"
    fi
  done
fi

user_path="/Users/$dp_user"
group_path="/Groups/$dp_group"
if dscl . -read "$group_path" &>/dev/null; then
  if dscl . delete "$group_path"; then
    echo "Successfully removed group $group_path."
  else
    echo "Failed to remove group $group_path."
  fi
fi

if dscl . -read "$user_path" &>/dev/null; then
  user_home_line=`dscl . -read "$user_path" NFSHomeDirectory`
  if [ $? -eq 0 -a -n "$user_home" ]; then
    user_home="${user_home_line##*: }"
    if [ "$user_home" != "/" -a -d "$user_home" ]; then
      rm -rf "$user_home"
    fi
  fi

  if dscl . delete "$user_path"; then
    echo "Successfully removed user $user_path."
  else
    echo "Failed to remove user $user_path."
  fi
fi

taskd_pids_str=`fuser /var/run/.taskd.lock`
if [ $? -eq 0 ]; then
  taskd_pids=${taskd_pids_str##*: }
  if [ -n "$taskd_pids" ]; then
    echo "Stopping taskd pids $taskd_pids"
    kill $taskd_pids
  fi
fi

"$install_dir/libexec/system-services" devpanel-taskd stop

rm -f /System/Library/LaunchDaemons/com.devpanel*

echo "Removing the install dir $install_dir"
rm -rf "$install_dir"

echo "Finished removal of devPanel software"<commit_msg>uninstall.macosx: remove entries from /etc/hosts<commit_after>#!/bin/bash


# main

[ $# -eq 0 ] && usage

if [ "${0:0:1}" != / ]; then
  error "please run this script with the full path, non-relative."
fi
script_dir=`dirname "$0"`

if [ $EUID -ne 0 ]; then
  echo "Error: This script needs to run with ROOT privileges." 1>&2
  exit 1
fi

unset confirmed
getopt_flags='yd'
while getopts $getopt_flags OPTN; do
  case "$OPTN" in
    y)
      confirmed=1
      ;;
    d)
      set -x
      ;;
  esac
done
shift $(( $OPTIND - 1 ))

if [ -z "$confirmed" ]; then
  echo "Error: please use option -y to confirm that you really want to uninstall the software and lose data" 1>&2
  exit 1
fi

install_dir="$1"
if [[ "$install_dir" =~ ^/*$ ]]; then
  echo "Error: install_dir can't be /" 1>&2
  exit 1
fi

dp_user="devpanel"
dp_group="$dp_user"

vagrant_dir=~devpanel/vagrant
if [ -d "$vagrant_dir" ]; then
  for D in "$vagrant_dir"/*; do
    if [ -d "$D" ]; then
      echo "Destroying VM `basename "$D"`..."
      su -l devpanel cd "$D" \&\& vagrant destroy -f \; cd "$D/.." \; rm -rf "$D"
    fi
  done
fi

user_path="/Users/$dp_user"
group_path="/Groups/$dp_group"
if dscl . -read "$group_path" &>/dev/null; then
  if dscl . delete "$group_path"; then
    echo "Successfully removed group $group_path."
  else
    echo "Failed to remove group $group_path."
  fi
fi

if dscl . -read "$user_path" &>/dev/null; then
  user_home_line=`dscl . -read "$user_path" NFSHomeDirectory`
  if [ $? -eq 0 -a -n "$user_home" ]; then
    user_home="${user_home_line##*: }"
    if [ "$user_home" != "/" -a -d "$user_home" ]; then
      rm -rf "$user_home"
    fi
  fi

  if dscl . delete "$user_path"; then
    echo "Successfully removed user $user_path."
  else
    echo "Failed to remove user $user_path."
  fi
fi

taskd_pids_str=`fuser /var/run/.taskd.lock`
if [ $? -eq 0 ]; then
  taskd_pids=${taskd_pids_str##*: }
  if [ -n "$taskd_pids" ]; then
    echo "Stopping taskd pids $taskd_pids"
    kill $taskd_pids
  fi
fi

"$install_dir/libexec/system-services" devpanel-taskd stop

rm -f /System/Library/LaunchDaemons/com.devpanel*

sed -E -i -e "/^128\..+devpanel\.net/d;" /etc/hosts

echo "Removing the install dir $install_dir"
rm -rf "$install_dir"

echo "Finished removal of devPanel software"
{'fraction_non_alphanumeric': 0.155550581915846, 'fraction_numerical': 0.009623992837958818, 'mean_word_length': 3.0664240218380345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, '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': '3191548', 'n_tokens_mistral': 1753, 'n_tokens_neox': 1695, 'n_words': 517}