<commit_before>#!/bin/bash
# Help menu
print_help() {
cat <<-HELP
This script is used to fix permissions of a Drupal installation
you need to provide the following arguments:
1) Path to your Drupal installation.
2) Username of the user that you want to give files/directories ownership.
3) HTTPD group name (defaults to _www for Apache).
Usage: (sudo) bash ${0##*/} --drupal_path=PATH --drupal_user=USER --httpd_group=GROUP
Example: (sudo) bash ${0##*/} --drupal_path=/usr/local/apache2/htdocs --drupal_user=john --httpd_group=_www
HELP
exit 0
}
if [ $(id -u) != 0 ]; then
	printf "**************************************\n"
	printf "* Error: You must run this with sudo. *\n"
	printf "**************************************\n"
	print_help
	exit 1
fi
# Set defaults
drupal_path_default=$(pwd)
drupal_user_default=$USER
httpd_group_default="_www"

# Set variables
drupal_path=${1:-$drupal_path_default}
drupal_user=${2:-$drupal_user_default}
httpd_group=${3:-$httpd_group_default}

# Remove trailing slash
drupal_path=${drupal_path%/}

# Parse Command Line Arguments
while [ $# -gt 0 ]; do
	case "$1" in
		--drupal_path=*)
			drupal_path="${1#*=}"
			;;
		--drupal_user=*)
			drupal_user="${1#*=}"
			;;
		--httpd_group=*)
			httpd_group="${1#*=}"
			;;
		--help) print_help;;
		*)
			printf "***********************************************************\n"
			printf "* Error: Invalid argument, run --help for valid arguments. *\n"
			printf "***********************************************************\n"
			exit 1<commit_msg>Get correct user when calling with sudo<commit_after>#!/bin/bash
# Help menu
print_help() {
cat <<-HELP
This script is used to fix permissions of a Drupal installation
you need to provide the following arguments:
1) Path to your Drupal installation.
2) Username of the user that you want to give files/directories ownership.
3) HTTPD group name (defaults to _www for Apache).
Usage: (sudo) bash ${0##*/} --drupal_path=PATH --drupal_user=USER --httpd_group=GROUP
Example: (sudo) bash ${0##*/} --drupal_path=/usr/local/apache2/htdocs --drupal_user=john --httpd_group=_www
HELP
exit 0
}
if [ $(id -u) != 0 ]; then
	printf "**************************************\n"
	printf "* Error: You must run this with sudo. *\n"
	printf "**************************************\n"
	print_help
	exit 1
fi
# Set defaults
drupal_path_default=$(pwd)
drupal_user_default=${SUDO_USER:-$USER}
httpd_group_default="_www"

# Set variables
drupal_path=${1:-$drupal_path_default}
drupal_user=${2:-$drupal_user_default}
httpd_group=${3:-$httpd_group_default}

# Remove trailing slash
drupal_path=${drupal_path%/}

# Parse Command Line Arguments
while [ $# -gt 0 ]; do
	case "$1" in
		--drupal_path=*)
			drupal_path="${1#*=}"
			;;
		--drupal_user=*)
			drupal_user="${1#*=}"
			;;
		--httpd_group=*)
			httpd_group="${1#*=}"
			;;
		--help) print_help;;
		*)
			printf "***********************************************************\n"
			printf "* Error: Invalid argument, run --help for valid arguments. *\n"
			printf "***********************************************************\n"
			exit 1
{'fraction_non_alphanumeric': 0.26262953367875647, 'fraction_numerical': 0.011658031088082901, 'mean_word_length': 4.963320463320463, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '1032164', 'n_tokens_mistral': 1091, 'n_tokens_neox': 999, 'n_words': 283}