<commit_before>#!/bin/bash
#
# Install a module into a chroot

CHROOT=$1
MODULE=$2
MODULEDIR=$3

if [ -z "$CHROOT" -o -z "$MODULE"]; then
	echo "USAGE: $0 /path/to/chroot module [moduledir]"
	echo "  - moduledir: defaults to /etc/mkchroot/modules"
	exit 1
fi

# Find MODULEDIR
if [ -z "$MODULEDIR" ]; then
	MODULEDIR=/etc/mkchroot/modules
fi

# See if MODULE exists
if [ ! -d $MODULEDIR/$MODULE ]; then
	echo "$MODULE does not exist in $MODULEDIR, exiting"
	exit 2
fi

# Copy repos from module to chroot
if [ -d $MODULEDIR/$MODULE/yum.repos.d ]; then
	cp -rap $MODULEDIR/$MODULE/yum.repos.d $CHROOT/etc/
	echo "Copied yum.repos.d from $MODULE"
fi

# Copy file tree from module to chroot
if [ -d $MODULEDIR/$MODULE/files ]; then
	cp -rap $MODULEDIR/$MODULE/files/* $CHROOT/
	echo "Copied file tree from $MODULE"
fi

# Install packages from yum list
if [ -f $MODULEDIR/$MODULE/yum.list ]; then
	echo "Installing packages in yum.list"
	yum --installroot $CHROOT -y `cat $MODULEDIR/$MODULE/yum.list`	
	
fi

# If any packages are present in an rpms directory, install those
if [ -d $MODULEDIR/$MODULE/rpms ]; then
	if [ -f $MODULEDIR/$MODULE/rpm.list ]; then
		echo "Installing packages from $MODULE/rpms in rpm.list"
		yum --installroot $CHROOT --nogpgcheck -y $MODULEDIR/$MODULE/rpms/*.rpm
	fi
fi

# If there is a $MODULE/install script, run it
if [ -x $MODULEDIR/$MODULE/install ]; then
	echo "Executing $MODULE/install..."
	/sbin/chroot $MODULEDIR/$MODULE/install
	echo "Done."
fi

echo "Module $MODULE has been installed to $CHROOT"<commit_msg>Various fixes to module-install.sh<commit_after>#!/bin/bash
#
# Install a module into a chroot

CHROOT=$1
MODULE=$2
MODULEDIR=$3

if [ -z "$CHROOT" -o -z "$MODULE"]; then
	echo "USAGE: $0 /path/to/chroot module [moduledir]"
	echo "  - moduledir: defaults to /etc/mkchroot/modules"
	exit 1
fi

# Find MODULEDIR
if [ -z "$MODULEDIR" ]; then
	MODULEDIR=/etc/mkchroot/modules
fi

# See if MODULE exists
if [ ! -d $MODULEDIR/$MODULE ]; then
	echo "$MODULE does not exist in $MODULEDIR, exiting"
	exit 2
fi

# Copy repos from module to chroot
if [ -d $MODULEDIR/$MODULE/yum.repos.d ]; then
	cp -rap $MODULEDIR/$MODULE/yum.repos.d $CHROOT/etc/
	echo "Copied yum.repos.d from $MODULE"
fi

# Copy file tree from module to chroot
if [ -d $MODULEDIR/$MODULE/files ]; then
	cp -rap $MODULEDIR/$MODULE/files/* $CHROOT/
	echo "Copied file tree from $MODULE"
fi

# Install packages from yum list
if [ -f $MODULEDIR/$MODULE/yum.list ]; then
	echo "Installing packages in yum.list"
	yum --installroot $CHROOT -y install `cat $MODULEDIR/$MODULE/yum.list`	
	
fi

# If any packages are present in an rpms directory, install those
if [ -d $MODULEDIR/$MODULE/rpms ]; then
	if [ -f $MODULEDIR/$MODULE/rpm.list ]; then
		echo "Installing packages from $MODULE/rpms"
		yum --installroot $CHROOT --nogpgcheck -y install $MODULEDIR/$MODULE/rpms/*.rpm
	fi
fi

# If there is a $MODULE/install script, run it
if [ -x $MODULEDIR/$MODULE/install ]; then
	echo "Executing $MODULE/install..."
	mkdir -p $CHROOT/tmp
	cp $MODULEDIR/$MODULE/install $CHROOT/tmp/install
	/usr/sbin/chroot $CHROOT /tmp/install
	echo "Done."
fi

echo "Module $MODULE has been installed to $CHROOT"
{'fraction_non_alphanumeric': 0.1347361809045226, 'fraction_numerical': 0.0037688442211055275, 'mean_word_length': 3.704579025110783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3051625', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1204, 'n_words': 375}