<commit_before>#! /bin/bash

#Script for installing on Ubuntu the following programms
	#Tools: Wget, Curl, Tmux, Zsh, Git, Dropbox, Y PPA Manager, Ubuntu Make, Ubuntu restricted
	#Text Editors: Vim, Atom, Sublime
	#Multimedia Vlc, Gimp, Spotify
	#Browsers: Firefox for developers, Chromium, Chrome
	#Mail Clients / IM: Thunderbird
	#Security: Iptables, Wireshark, Hydra, Nmap, Aircrack-ng, Medusa
	#Compilers: Python, Oracle's jdk 8, Ruby, G++, GCC
	#IDEs: IntelliJ IDEA, Android Studio, Eclipse, Pycharm

export logDir="/var/log/installation_script" #Log directory
export logFile="$logDir/installation_script_ubuntu.log" # Log file
export architecture=$(uname -m) # Computers architecture
export tempDir=$(mktemp -d /tmp/tempdir.XXXXXXXX) # Create temp directory
export alreadyInstalledCode=999 # Already installed code
export showLog=false

# Programms to be installed from reposittories
declare -a tools=(wget curl git dropbox tmux zsh y-ppa-manager ubuntu-make ubuntu-restricted-extras) #Tools
declare -a textEditor=(vim atom) #Text Editors
declare -a multimedia=(vlc gimp gimp-data gimp-data-extras gimp-plugin-registry spotify-client) #Multimedia
declare -a browsers=(firefox chromium-browser google-chrome-stable) #Browsers
declare -a mailClient=(thunderbird) #Mail Client
declare -a security=(iptables wireshark hydra nmap aircrack-ng medusa) #Security
declare -a compilers=(ruby python3 g++ gcc oracle-java8-installer oracle-java8-set-default) #Compilers

# Check for root privilages
function check_root_privilages(){
 if [[ $EUID -ne 0 ]]; then
   echo "This script needs root privilages"
   exit 1
  fi
  }

# Check the internet connection
function check_conection(){
  if [[ ! "$(ping -c 1 google.com)" ]];then
    echo "Please check your internet connection and execute the script again"
    exit 2
  fi
}

# Create log directory
function create_log_directory(){
    	if [ ! -d $logDir ];then
    		mkdir $logDir
    		chown $USER:$USER $logDir
    	fi
    	if [ -e $logFile ];then
    		mv $logFile $logFile$(date +%Y%m%d).log
    		touch $logFile
    	fi
}

# Write log file
function write_log(){
  #TO DO
  if [ -z "$2" ];then
    echo "$1 : Parameter error" >> $logFile
  else
    case $2 in
      0)
        echo "$1 : successfully installed" >> $logFile
        ;;
      $alreadyInstalledCode)
        echo "$1 : already installed" >> $logFile
        ;;
      *)
        echo "$1 : installation failed (error code = $2)" >> $logFile
        showLog=true
        ;;
      esac
    fi
}

# Install applications from reposittories
function install_repo_apps(){
  name=$1[@]
  arrayName=("${!name}")
  for i in "${arrayName[@]}"; do
    if ! appLocation="$(type -p "$i")" || [ -z "$appLocation" ]; then # Check if the application isn't installed
      apt-get install -y $i
      exitLog=$?
      write_log $i $exitLog
    else<commit_msg>Deleted a forgotten #TO DO<commit_after>#! /bin/bash

#Script for installing on Ubuntu the following programms
	#Tools: Wget, Curl, Tmux, Zsh, Git, Dropbox, Y PPA Manager, Ubuntu Make, Ubuntu restricted
	#Text Editors: Vim, Atom, Sublime
	#Multimedia Vlc, Gimp, Spotify
	#Browsers: Firefox for developers, Chromium, Chrome
	#Mail Clients / IM: Thunderbird
	#Security: Iptables, Wireshark, Hydra, Nmap, Aircrack-ng, Medusa
	#Compilers: Python, Oracle's jdk 8, Ruby, G++, GCC
	#IDEs: IntelliJ IDEA, Android Studio, Eclipse, Pycharm

export logDir="/var/log/installation_script" #Log directory
export logFile="$logDir/installation_script_ubuntu.log" # Log file
export architecture=$(uname -m) # Computers architecture
export tempDir=$(mktemp -d /tmp/tempdir.XXXXXXXX) # Create temp directory
export alreadyInstalledCode=999 # Already installed code
export showLog=false

# Programms to be installed from reposittories
declare -a tools=(wget curl git dropbox tmux zsh y-ppa-manager ubuntu-make ubuntu-restricted-extras) #Tools
declare -a textEditor=(vim atom) #Text Editors
declare -a multimedia=(vlc gimp gimp-data gimp-data-extras gimp-plugin-registry spotify-client) #Multimedia
declare -a browsers=(firefox chromium-browser google-chrome-stable) #Browsers
declare -a mailClient=(thunderbird) #Mail Client
declare -a security=(iptables wireshark hydra nmap aircrack-ng medusa) #Security
declare -a compilers=(ruby python3 g++ gcc oracle-java8-installer oracle-java8-set-default) #Compilers

# Check for root privilages
function check_root_privilages(){
 if [[ $EUID -ne 0 ]]; then
   echo "This script needs root privilages"
   exit 1
  fi
  }

# Check the internet connection
function check_conection(){
  if [[ ! "$(ping -c 1 google.com)" ]];then
    echo "Please check your internet connection and execute the script again"
    exit 2
  fi
}

# Create log directory
function create_log_directory(){
    	if [ ! -d $logDir ];then
    		mkdir $logDir
    		chown $USER:$USER $logDir
    	fi
    	if [ -e $logFile ];then
    		mv $logFile $logFile$(date +%Y%m%d).log
    		touch $logFile
    	fi
}

# Write log file
function write_log(){
  if [ -z "$2" ];then
    echo "$1 : Parameter error" >> $logFile
  else
    case $2 in
      0)
        echo "$1 : successfully installed" >> $logFile
        ;;
      $alreadyInstalledCode)
        echo "$1 : already installed" >> $logFile
        ;;
      *)
        echo "$1 : installation failed (error code = $2)" >> $logFile
        showLog=true
        ;;
      esac
    fi
}

# Install applications from reposittories
function install_repo_apps(){
  name=$1[@]
  arrayName=("${!name}")
  for i in "${arrayName[@]}"; do
    if ! appLocation="$(type -p "$i")" || [ -z "$appLocation" ]; then # Check if the application isn't installed
      apt-get install -y $i
      exitLog=$?
      write_log $i $exitLog
    else
{'fraction_non_alphanumeric': 0.11375568778438921, 'fraction_numerical': 0.007000350017500875, 'mean_word_length': 3.6882690730106646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '320146', 'n_tokens_mistral': 1941, 'n_tokens_neox': 1813, 'n_words': 609}