<commit_before>#!/bin/bash

tmux_config()
{
    git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm > /dev/null 2>&1 &&
    ln -s $HOME/myautoconfig/dotfiles/tmux.conf $HOME/.tmux.conf > /dev/null 2>&1;
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

vim_config()
{
    ln -s $HOME/myautoconfig/dotfiles/vimrc $HOME/.vimrc > /dev/null 2>&1;
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

oh_my_zsh_config()
{
    sudo chsh $LOGNAME -s /bin/zsh > /dev/null 2>&1 &&
    git clone https://github.com/robbyrussell/oh-my-zsh.git $HOME/.oh-my-zsh/ > /dev/null 2>&1 &&
    ln -s $HOME/myautoconfig/dotfiles/zshrc $HOME/.zshrc > /dev/null 2>&1;
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

pip_config()
{
    sudo ln -s $HOME/myautoconfig/dotfiles/pip.conf /etc/pip.conf > /dev/null 2>&1;
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

mariadb_config()
{
    echo "mariadb_config...";
	mysql -V;
    # sudo systemctl start mariadb && sudo systemctl enable mariadb && sudo systemctl restart mariadb;
    echo "systemctl enable mariadb_config...";
    sudo systemctl enable mariadb && sudo systemctl restart mariadb || sudo systemctl start;
    echo "systemctl enable mariadb_config...";
	sudo $HOME/myautoconfig/mariadb.sh;
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

nginx_config()
{
    echo "nginx_config...";
	nginx -v;
	sudo rm -f /etc/nginx/sites-available/default;
	sudo systemctl stop nginx;
    echo "systemctl enable nginx_config...";
	sudo  ln $HOME/myautoconfig/dotfiles/env_config_file/default  /etc/nginx/sites-available/default;
    sudo systemctl enable nginx && sudo systemctl restart nginx || sudo systemctl start nginx;
    echo "systemctl enable nginx_config...";
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

php_config()
{
    echo "php_config...";
	php -v;
	# curl -sS https://getcomposer.org/installer | php;
	sudo systemctl stop php7.1-fpm;
	curl -sS https://install.phpcomposer.com/installer | php; # in domain
	sudo mv composer.phar /usr/local/bin/composer;
	composer config -g repo.packagist composer https://packagist.phpcomposer.com;
	# composer self-update;
	sudo rm -f /etc/php/7.1/fpm/php.ini;
	sudo rm -f /etc/php/7.1/cli/php.ini;
	sudo ln $HOME/myautoconfig/dotfiles/env_config_file/php.ini /etc/php/7.1/fpm/php.ini;
	sudo ln $HOME/myautoconfig/dotfiles/env_config_file/php.ini /etc/php/7.1/cli/php.ini;
    echo "systemctl enable php7.1-fpm_config...";
    sudo systemctl enable php7.1-fpm && sudo systemctl restart php7.1-fpm && sudo systemctl start php7.1-fpm;
    echo "systemctl enable php7.1-fpm_config...";
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

main()
{
    #sudo apt update && sudo apt -y full-upgrade;
    #sudo apt -y install htop vim tmux zsh curl synapse > /dev/null 2>&1;
    sudo apt -y install htop vim zsh curl synapse > /dev/null 2>&1;

    if [ $? = 0 ] ; then
        echo -e "Software has been installed [\033[;32mFinish\033[;m].";
    else
        echo -e "Software has been installed [\033[;31mFaile\033[;m].";
        exit 1;
    fi

    # tmux vim oh_my_zsh pip
    software=(vim oh_my_zsh pip);
    
    for sw in ${software[*]};
    do
        ${sw}'_config';
        if [ $? = 0 ] ; then
            echo -e "$0 deployed ${sw} [\033[;32mFinish\033[;m].";
            continue;
        else
            echo -e "$0 deployed ${sw} [\033[;31mFaile\033[;m].";
            return 1;
        fi
    done

    return 0;
}

env_install()
{

    cd $HOME/myautoconfig/;
    git pull;
    
	env_software=(mariadb php nginx);
    #sudo apt update && sudo apt -y full-upgrade;
	sw_db="mariadb-server-10.1 mariadb-client-10.1";
	sw_web="nginx";
	sw_php="curl php7.1-dev php7.1-fpm php7.1-mbstring php7.1-mysql";
	sw_phpmyadmin_must="php7.1-xml php7.1-curl phpunit phpunit-selenium";
	sw_phpmyadmin_improve="php-invoker php-bz2 php-zip php-opcache php-gd php-gmp php-libsodium php-xdebug php-soap";
    # sudo apt -y install mariadb-server-10.1 mariadb-client-10.1 nginx php7.1-dev php7.1-fpm php7.1-mbstring php7.1-mysql php7.1-xml php7.1-curl phpunit phpunit-selenium curl > /dev/null 2>&1;
	sudo apt -y install ${sw_db} ${sw_web} ${sw_php} ${sw_phpmyadmin_must} ${sw_phpmyadmin_improve};
    if [ $? = 0 ] ; then
        echo -e "Software has been installed [\033[;32mFinish\033[;m].";
    else
        echo -e "Software has been installed [\033[;31mFaile\033[;m].";
        exit 1;
    fi
    for env_sw in ${env_software[*]};
    do
        ${env_sw}'_config';
        if [ $? = 0 ] ; then
            echo -e "$0 deployed ${env_sw} [\033[;32mFinish\033[;m].";
        else
            echo -e "$0 deployed ${env_sw} [\033[;31mFaile\033[;m].";
            return 1;
        fi
    done
    echo -e "ThinkPHP5 install.";
    cd $HOME;

	sudo ln -s $HOME/myautoconfig/dotfiles/env_config_file/index.php /var/www/html/;

	composer create-project topthink/think=5.1 $HOME/tp5  --prefer-dist;
	sudo ln -s $HOME/tp5/ /var/www/;
    echo -e "ThinkPHP5 installed.";

    echo -e "phpmyadmin install.";
	composer create-project phpmyadmin/phpmyadmin $HOME/phpmyadmin;
	sudo ln -s $HOME/phpmyadmin/ /var/www/;
	cd $HOME/phpmyadmin;
	composer update && cd $HOME;
    echo -e "phpmyadmin installed.";
	 
	sudo $HOME/myautoconfig/host_wrtie.sh;
    exit 0;
}

env_update()
{
    cd $HOME/myautoconfig/;
    git pull;

    sudo systemctl restart ginx;
    sudo systemctl restart mariadb;
    sudo systemctl restart php7.1-fpm;
    if [ $? = 0 ] ; then<commit_msg>modify<commit_after>#!/bin/bash

tmux_config()
{
    git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm > /dev/null 2>&1 &&
    ln -s $HOME/myautoconfig/dotfiles/tmux.conf $HOME/.tmux.conf > /dev/null 2>&1;
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

vim_config()
{
    ln -s $HOME/myautoconfig/dotfiles/vimrc $HOME/.vimrc > /dev/null 2>&1;
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

oh_my_zsh_config()
{
    sudo chsh $LOGNAME -s /bin/zsh > /dev/null 2>&1 &&
    git clone https://github.com/robbyrussell/oh-my-zsh.git $HOME/.oh-my-zsh/ > /dev/null 2>&1 &&
    ln -s $HOME/myautoconfig/dotfiles/zshrc $HOME/.zshrc > /dev/null 2>&1;
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

pip_config()
{
    sudo ln -s $HOME/myautoconfig/dotfiles/pip.conf /etc/pip.conf > /dev/null 2>&1;
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

mariadb_config()
{
    echo "mariadb_config...";
	mysql -V;
    # sudo systemctl start mariadb && sudo systemctl enable mariadb && sudo systemctl restart mariadb;
    echo "systemctl enable mariadb_config...";
    sudo systemctl enable mariadb.service && sudo systemctl restart mariadb.service || sudo systemctl start mariadb.service;
    echo "systemctl enable mariadb_config...";
	sudo $HOME/myautoconfig/mariadb.sh;
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

nginx_config()
{
    echo "nginx_config...";
	nginx -v;
	sudo rm -f /etc/nginx/sites-available/default;
	sudo systemctl stop nginx.service;
    echo "systemctl enable nginx_config...";
	sudo  ln $HOME/myautoconfig/dotfiles/env_config_file/default  /etc/nginx/sites-available/default;
    sudo systemctl enable nginx.service && sudo systemctl restart nginx.service || sudo systemctl start nginx.service;
    echo "systemctl enable nginx_config...";
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

php_config()
{
    echo "php_config...";
	php -v;
	# curl -sS https://getcomposer.org/installer | php;
	sudo systemctl stop php7.1-fpm.service;
	curl -sS https://install.phpcomposer.com/installer | php; # in domain
	sudo mv composer.phar /usr/local/bin/composer;
	composer config -g repo.packagist composer https://packagist.phpcomposer.com;
	# composer self-update;
	sudo rm -f /etc/php/7.1/fpm/php.ini;
	sudo rm -f /etc/php/7.1/cli/php.ini;
	sudo ln $HOME/myautoconfig/dotfiles/env_config_file/php.ini /etc/php/7.1/fpm/php.ini;
	sudo ln $HOME/myautoconfig/dotfiles/env_config_file/php.ini /etc/php/7.1/cli/php.ini;
    echo "systemctl enable php7.1-fpm_config...";
    sudo systemctl enable php7.1-fpm.service && sudo systemctl restart php7.1-fpm.service&& sudo systemctl start php7.1-fpm.service;
    echo "systemctl enable php7.1-fpm_config...";
    if [ $? = 0 ] ; then
        return 0;
    else
        return 1;
    fi
}

main()
{
    #sudo apt update && sudo apt -y full-upgrade;
    #sudo apt -y install htop vim tmux zsh curl synapse > /dev/null 2>&1;
    sudo apt -y install htop vim zsh curl synapse > /dev/null 2>&1;

    if [ $? = 0 ] ; then
        echo -e "Software has been installed [\033[;32mFinish\033[;m].";
    else
        echo -e "Software has been installed [\033[;31mFaile\033[;m].";
        exit 1;
    fi

    # tmux vim oh_my_zsh pip
    software=(vim oh_my_zsh pip);
    
    for sw in ${software[*]};
    do
        ${sw}'_config';
        if [ $? = 0 ] ; then
            echo -e "$0 deployed ${sw} [\033[;32mFinish\033[;m].";
            continue;
        else
            echo -e "$0 deployed ${sw} [\033[;31mFaile\033[;m].";
            return 1;
        fi
    done

    return 0;
}

env_install()
{

    cd $HOME/myautoconfig/;
    git pull;
    
	env_software=(mariadb php nginx);
    #sudo apt update && sudo apt -y full-upgrade;
	sw_db="mariadb-server-10.1 mariadb-client-10.1";
	sw_web="nginx";
	sw_php="curl php7.1-dev php7.1-fpm php7.1-mbstring php7.1-mysql";
	sw_phpmyadmin_must="php7.1-xml php7.1-curl phpunit phpunit-selenium";
	sw_phpmyadmin_improve="php-invoker php-bz2 php-zip php-opcache php-gd php-gmp php-libsodium php-xdebug php-soap";
    # sudo apt -y install mariadb-server-10.1 mariadb-client-10.1 nginx php7.1-dev php7.1-fpm php7.1-mbstring php7.1-mysql php7.1-xml php7.1-curl phpunit phpunit-selenium curl > /dev/null 2>&1;
	sudo apt -y install ${sw_db} ${sw_web} ${sw_php} ${sw_phpmyadmin_must} ${sw_phpmyadmin_improve};
    if [ $? = 0 ] ; then
        echo -e "Software has been installed [\033[;32mFinish\033[;m].";
    else
        echo -e "Software has been installed [\033[;31mFaile\033[;m].";
        exit 1;
    fi
    for env_sw in ${env_software[*]};
    do
        ${env_sw}'_config';
        if [ $? = 0 ] ; then
            echo -e "$0 deployed ${env_sw} [\033[;32mFinish\033[;m].";
        else
            echo -e "$0 deployed ${env_sw} [\033[;31mFaile\033[;m].";
            return 1;
        fi
    done
    echo -e "ThinkPHP5 install.";
    cd $HOME;

	sudo ln -s $HOME/myautoconfig/dotfiles/env_config_file/index.php /var/www/html/;

	composer create-project topthink/think=5.1 $HOME/tp5  --prefer-dist;
	sudo ln -s $HOME/tp5/ /var/www/;
    echo -e "ThinkPHP5 installed.";

    echo -e "phpmyadmin install.";
	composer create-project phpmyadmin/phpmyadmin $HOME/phpmyadmin;
	sudo ln -s $HOME/phpmyadmin/ /var/www/;
	cd $HOME/phpmyadmin;
	composer update && cd $HOME;
    echo -e "phpmyadmin installed.";
	 
	sudo $HOME/myautoconfig/host_wrtie.sh;
    exit 0;
}

env_update()
{
    cd $HOME/myautoconfig/;
    git pull;

    sudo systemctl restart nginx.service || sudo systemctl restart nginx.service;
    sudo systemctl restart mariadb.service || sudo systemctl restart mariadb.service;
    sudo systemctl restart php7.1-fpm.service || sudo systemctl restart php7.1-fpm.service;
    if [ $? = 0 ] ; then
{'fraction_non_alphanumeric': 0.14353776853776853, 'fraction_numerical': 0.032224532224532226, 'mean_word_length': 2.4742702377369845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 43, 'https://': 10, 'lorem ipsum': 0, 'www.': 6, 'xml': 4}, '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': '1298344', 'n_tokens_mistral': 4840, 'n_tokens_neox': 4393, 'n_words': 1060}