<commit_before>#!/bin/bash
#########################################
#Function:    install lnmp
#Usage:       bash lnmp.sh
#website:     www.boxcore.org
#Version:     1.0
#########################################
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

# Check if user is root
if [ $(id -u) != "0" ]; then
    echo "Error: You must be root to run this script, please use root to install lnmp"
    exit 1
fi

clear
echo "========================================================================="
echo "Install LNMP v1.0 for CentOS"
echo "A tool to auto-compile & install Nginx+MySQL+PHP on Linux For more information please visit http://www.boxcore.org/"
echo "========================================================================="
# close var cur_dir now
cur_dir=$(pwd)

#set mysql root password
	echo "==========================="
	mysqlrootpwd="<PASSWORD>"
	echo "Please input the root password of mysql:"
	read -p "(Default password: root):" mysqlrootpwd
	if [ "$mysqlrootpwd" = "" ]; then
		mysqlrootpwd="<PASSWORD>"
	fi
	echo "==========================="
	echo "MySQL root password:$<PASSWORD>"
	echo "==========================="

# set install dependent method
function ChooseDependentType()
{
    echo "========================================================================="
    echo "You now have 2 options for your dependent setup."
    echo ""
    echo "1: Install Dependent By Yum"
    echo "2: Install Dependent By Compiled Resource"
    echo "========================================================================="
    echo -n "Enter your choice (1 or 2): ";
    read dependent_type

    if [ "$dependent_type" = "1" ]; then
        export LNMP_DTYPE="1"
    elif [ "$dependent_type" = "2" ]; then
        export LNMP_DTYPE="2"
    else
        echo "You input a wrong number, please choose again!"
        ChooseDependentType
    fi
}

# set run nginx and php user
function ChooseRunUser()
{
    echo "========================================================================="
    echo "Which User you want to run php and nginx?"
    echo ""
    echo "www: install for servers product"
    echo "root: only u!"
    echo "========================================================================="
    echo -n "Enter your choice (www or root): ";
    read runuser

    if [ "$runuser" = "1" ]; then
        export LNMP_USER="www"
        groupadd www
        useradd -s /sbin/nologin -g www www
    elif [ "$runuser" = "2" ]; then
        export LNMP_USER="root"
    else
        echo "You input a wrong user name, please choose again!"
        ChooseRunUser
    fi
}

function InitInstall()
{
    echo "================================================================="
    echo " Remove Basic LNMP and donwload install basic lib "
    echo "================================================================="
    cd $cur_dir
    cat /etc/issue
    uname -a
    MemTotal=`free -m | grep Mem | awk '{print  $2}'`  
    echo -e "\n Memory is: ${MemTotal} MB "
    #Set timezone
    rm -rf /etc/localtime
    ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

    yum install -y ntp
    ntpdate -u pool.ntp.org
    date

    rpm -qa|grep httpd
    rpm -e httpd
    rpm -qa|grep mysql
    rpm -e mysql
    rpm -qa|grep php<commit_msg>fix bug for choose lnmp user<commit_after>#!/bin/bash
#########################################
#Function:    install lnmp
#Usage:       bash lnmp.sh
#website:     www.boxcore.org
#Version:     1.0
#########################################
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

# Check if user is root
if [ $(id -u) != "0" ]; then
    echo "Error: You must be root to run this script, please use root to install lnmp"
    exit 1
fi

clear
echo "========================================================================="
echo "Install LNMP v1.0 for CentOS"
echo "A tool to auto-compile & install Nginx+MySQL+PHP on Linux For more information please visit http://www.boxcore.org/"
echo "========================================================================="
# close var cur_dir now
cur_dir=$(pwd)

#set mysql root password
	echo "==========================="
	mysqlrootpwd="<PASSWORD>"
	echo "Please input the root password of mysql:"
	read -p "(Default password: root):" mysqlrootpwd
	if [ "$mysqlrootpwd" = "" ]; then
		mysqlrootpwd="<PASSWORD>"
	fi
	echo "==========================="
	echo "MySQL root password:$<PASSWORD>rootpwd"
	echo "==========================="

# set install dependent method
function ChooseDependentType()
{
    echo "========================================================================="
    echo "You now have 2 options for your dependent setup."
    echo ""
    echo "1: Install Dependent By Yum"
    echo "2: Install Dependent By Compiled Resource"
    echo "========================================================================="
    echo -n "Enter your choice (1 or 2): ";
    read dependent_type

    if [ "$dependent_type" = "1" ]; then
        export LNMP_DTYPE="1"
    elif [ "$dependent_type" = "2" ]; then
        export LNMP_DTYPE="2"
    else
        echo "You input a wrong number, please choose again!"
        ChooseDependentType
    fi
}

# set run nginx and php user
function ChooseRunUser()
{
    echo "========================================================================="
    echo "Which User you want to run php and nginx?"
    echo ""
    echo "www: install for servers product"
    echo "root: only u!"
    echo "========================================================================="
    echo -n "Enter your choice (www or root): ";
    read runuser

    if [ "$runuser" = "www" ]; then
        export LNMP_USER="www"
        groupadd www
        useradd -s /sbin/nologin -g www www
    elif [ "$runuser" = "root" ]; then
        export LNMP_USER="root"
    else
        echo "You input a wrong user name, please choose again!"
        ChooseRunUser
    fi
}

function InitInstall()
{
    echo "================================================================="
    echo " Remove Basic LNMP and donwload install basic lib "
    echo "================================================================="
    cd $cur_dir
    cat /etc/issue
    uname -a
    MemTotal=`free -m | grep Mem | awk '{print  $2}'`  
    echo -e "\n Memory is: ${MemTotal} MB "
    #Set timezone
    rm -rf /etc/localtime
    ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

    yum install -y ntp
    ntpdate -u pool.ntp.org
    date

    rpm -qa|grep httpd
    rpm -e httpd
    rpm -qa|grep mysql
    rpm -e mysql
    rpm -qa|grep php
{'fraction_non_alphanumeric': 0.30866616428033156, 'fraction_numerical': 0.005124340617935192, 'mean_word_length': 3.5892116182572615, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 13, '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': '3758264', 'n_tokens_mistral': 1948, 'n_tokens_neox': 1792, 'n_words': 620}