<commit_before>#Installer for patch bash 4.3.30 with syslog

#!/bin/bash

#detect bash version
MAJVER=${BASH_VERSINFO[0]}
MINVER=${BASH_VERSINFO[1]}
platform='unknown'
download='wget --no-check-certificate'
unamestr=`uname`

#CHANGE FOR THE YOURS
IPSYSLOG='127.0.0.1'
BASHPRINT='MIKA'
#####################

if [[ "$unamestr" == 'Linux' ]]; then
   platform='linux'
   download='wget --no-check-certificate'
   syslogconf='/etc/rsyslog.d'
   printrestart='/etc/init.d/rsyslog restart'
   logrotateconf="/etc/logrotate.d"
   bashpath="/bin"
   echo "PS1='\[\033[0;31m\]\u\[\033[0m\]@\[\033[0;32m\]\h\[\033[0m\] :\w\$ '" >> "/root/.bashrc"
elif [[ "$unamestr" == 'FreeBSD' ]]; then
   platform='freebsd'
   download='fetch'
   syslogconf='/usr/local/etc/rsyslog.d'
   printrestart='/usr/local/etc/rc.d/rsyslogd restart'
   logrotateconf="/usr/local/etc/logrotate.d"
   bashpath="/usr/local/bin"
fi

printf "System: $platform / Your bash version: ${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}\n"

if [[ "$unamestr" == 'Linux' ]]
then
  printf "Do you execute update and install 'patch make gcc' ? Y/N\n"
  read answer1

  if [[ "$answer1" == "Y" ]]
    then
		  apt-get update
		  apt-get install patch make gcc
  fi
fi

printf "Do you want upgrade and patch bash in your $platform ? Y/N\n"
read answer
if [[ "$answer" == "N" ]]
then
	printf "Bye\n"
	exit 1
else
	printf "Download bash version 4.3.30 from ftp.gnu.org\n"
	TARFILE=bash-4.3.30.tar.gz
	$download "https://ftp.gnu.org/gnu/bash/$TARFILE"
	tar -xzvf $TARFILE

	printf "Patch new bash version\n"
	patch bash-4.3.30/config-top.h config-top_syslog.patch
	patch bash-4.3.30/bashhist.c bashhist_syslog.patch

	printf "Compile new bash version\n"
	cd "bash-4.3.30"
	sed -i -e "s/GNU bash,/GNU bash ($BASHPRINT),/" version.c
	sed -i -e "s/GNU bash,/GNU bash ($BASHPRINT),/" shell.c
	./configure
	make
	make install

	NEWVERNAME="bash-4-3"
	OLDVERNAME="bash-$MAJVER-$MINVER"

	mv bash $NEWVERNAME-NEW
	mv $NEWVERNAME-NEW $bashpath/
	cd $bashpath
	cp bash $OLDVERNAME-OLD

  echo "user.*  -/var/log/tracecommands.log
	user.*   @$IPSYSLOG:514;GRAYLOGRFC5424" > "$syslogconf/tracecommands"

  echo "/var/log/tracecommands.log {
        daily
        rotate 7
        copytruncate
        compress
        delaycompress
        missingok
        notifempty
}
" > "$logrotateconf/tracecommands"

	printf "###################################\n"
	printf "Please execute this commands\n"
	printf "cd $bashpath\n"
	printf "$NEWVERNAME-NEW\n"
	printf "mv $NEWVERNAME-NEW bash\n"
	printf "bash\n"
  	printf "$printrestart\n"
	printf "###################################\n"
fi
<commit_msg>add dev to patched with lastest patch from ftp.gnu.org<commit_after>#Installer for patch bash 4.3.30 with syslog

#!/bin/bash

#detect bash version
MAJVER=${BASH_VERSINFO[0]}
MINVER=${BASH_VERSINFO[1]}
platform='unknown'
download='wget --no-check-certificate'
unamestr=`uname`
version="4.3"
nodotversion="43"


#CHANGE FOR THE YOURS
IPSYSLOG='127.0.0.1'
BASHPRINT='MIKA'
lastpatch="42"
#####################

if [[ "$unamestr" == 'Linux' ]]; then
   platform='linux'
   download='wget --no-check-certificate'
   syslogconf='/etc/rsyslog.d'
   printrestart='/etc/init.d/rsyslog restart'
   logrotateconf="/etc/logrotate.d"
   bashpath="/bin"
   echo "PS1='\[\033[0;31m\]\u\[\033[0m\]@\[\033[0;32m\]\h\[\033[0m\] :\w\$ '" >> "/root/.bashrc"
elif [[ "$unamestr" == 'FreeBSD' ]]; then
   platform='freebsd'
   download='fetch'
   syslogconf='/usr/local/etc/rsyslog.d'
   printrestart='/usr/local/etc/rc.d/rsyslogd restart'
   logrotateconf="/usr/local/etc/logrotate.d"
   bashpath="/usr/local/bin"
fi

printf "System: $platform / Your bash version: ${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}\n"

if [[ "$unamestr" == 'Linux' ]]
then
  printf "Do you execute update and install 'patch make gcc' ? Y/N\n"
  read answer1

  if [[ "$answer1" == "Y" ]]
    then
		  apt-get update
		  apt-get install patch make gcc
  fi
fi

printf "Do you want upgrade and patch bash in your $platform ? Y/N\n"
read answer
if [[ "$answer" == "N" ]]
then
	printf "Bye\n"
	exit 1
else
	printf "Download bash version 4.3.30 from ftp.gnu.org\n"
	TARFILE=bash-4.3.30.tar.gz
	$download "https://ftp.gnu.org/gnu/bash/$TARFILE"
	tar -xzvf $TARFILE

  printf "Download all patchs bash version 4.3 from ftp.gnu.org\n"
  for i in `seq 1 $lastpatch`;
  do
    number=$(printf %02d $i)
    file="https://ftp.gnu.org/pub/gnu/bash/bash-${version}-patches/bash${nodotversion}-0$number"
    echo $file
    curl -k $file | patch -N -p0
  done


	printf "Patch new bash version\n"
	patch bash-4.3.30/config-top.h config-top_syslog.patch
	patch bash-4.3.30/bashhist.c bashhist_syslog.patch

	printf "Compile new bash version\n"
	cd "bash-4.3.30"
	sed -i -e "s/GNU bash,/GNU bash ($BASHPRINT),/" version.c
	sed -i -e "s/GNU bash,/GNU bash ($BASHPRINT),/" shell.c
	./configure
	make
	make install

	NEWVERNAME="bash-4-3"
	OLDVERNAME="bash-$MAJVER-$MINVER"

	mv bash $NEWVERNAME-NEW
	mv $NEWVERNAME-NEW $bashpath/
	cd $bashpath
	cp bash $OLDVERNAME-OLD

  echo "user.*  -/var/log/tracecommands.log
	user.*   @$IPSYSLOG:514;GRAYLOGRFC5424" > "$syslogconf/tracecommands"

  echo "/var/log/tracecommands.log {
        daily
        rotate 7
        copytruncate
        compress
        delaycompress
        missingok
        notifempty
}
" > "$logrotateconf/tracecommands"

	printf "###################################\n"
	printf "Please execute this commands\n"
	printf "cd $bashpath\n"
	printf "$NEWVERNAME-NEW\n"
	printf "mv $NEWVERNAME-NEW bash\n"
	printf "bash\n"
  	printf "$printrestart\n"
	printf "###################################\n"
fi

{'fraction_non_alphanumeric': 0.1913833006943208, 'fraction_numerical': 0.026526615631119816, 'mean_word_length': 3.5861224489795918, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '78941', 'n_tokens_mistral': 2349, 'n_tokens_neox': 2151, 'n_words': 470}