<commit_before>#!/bin/bash

mount=$1
function runCommandWithTimeout {
	command=$2
	timeout --signal=9 $1 sh -c "$command"
	if [ $? -eq 0 ]; then
		return 0
	else
		return 1
	fi
}
#TODO: Move this check to monit once on wheezy
#Fix for https://github.com/cargomedia/puppet-cargomedia/issues/229
function failAndRestart {
	echo $1
	if (test -x /etc/init.d/nfs-kernel-server && which monit >/dev/null); then monit restart nfs-server; fi
	exit 1
}

if !(grep -q "[[:space:]]${mount}[[:space:]]" /proc/mounts); then
	echo "Mountpoint not mounted: $mount - remounting..."
	runCommandWithTimeout 5 "mount $mount"
	if [ $? -gt 0 ]; then
		failAndRestart "Failed to remount!"
	fi
	echo "Done."
fi
runCommandWithTimeout 5 "testFile=\$(mktemp --tmpdir=${mount}) && rm -f \$testFile"
if [ $? -gt 0 ]; then
	echo "Cannot write to mountpoint: $mount - remounting..."
	umount -l $mount
	runCommandWithTimeout 5 "mount $mount"
	if [ $? -gt 0 ]; then
		failAndRestart "Failed to remount!"
	fi
	echo "Done."
fi<commit_msg>Restart nfs-server also if remount succeeded<commit_after>#!/bin/bash

mount=$1
function runCommandWithTimeout {
	command=$2
	timeout --signal=9 $1 sh -c "$command"
	if [ $? -eq 0 ]; then
		return 0
	else
		return 1
	fi
}

if !(grep -q "[[:space:]]${mount}[[:space:]]" /proc/mounts); then
	echo "Mountpoint not mounted: $mount - remounting..."
	runCommandWithTimeout 5 "mount $mount"
	if [ $? -gt 0 ]; then
		echo "Failed to remount!"
		exit 1
	fi
	echo "Done."
fi
runCommandWithTimeout 5 "testFile=\$(mktemp --tmpdir=${mount}) && rm -f \$testFile"
if [ $? -gt 0 ]; then
	echo "Cannot write to mountpoint: $mount - remounting..."
	umount -l $mount
	runCommandWithTimeout 5 "mount $mount"

	#TODO: Move this check to monit once on wheezy
	#Fix for https://github.com/cargomedia/puppet-cargomedia/issues/229
	if (test -x /etc/init.d/nfs-kernel-server && which monit >/dev/null); then
		echo "Restarting nfs-server..."
		monit restart nfs-server
	fi

	if [ $? -gt 0 ]; then
		echo "Failed to remount!"
		exit 1
	fi
	echo "Done."
fi
{'fraction_non_alphanumeric': 0.15403543307086615, 'fraction_numerical': 0.017716535433070866, 'mean_word_length': 3.6099773242630384, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2477691', 'n_tokens_mistral': 801, 'n_tokens_neox': 753, 'n_words': 239}