2017-08-08 19:13:59 +00:00
|
|
|
#!/bin/bash
|
2017-09-11 18:53:54 +00:00
|
|
|
# Install all package we need to prepare and install khanat server
|
2017-08-08 19:13:59 +00:00
|
|
|
#
|
2017-09-11 18:53:54 +00:00
|
|
|
# Copyright (C) 2017 AleaJactaEst
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-08-08 19:13:59 +00:00
|
|
|
|
|
|
|
echo "Start Basic"
|
|
|
|
|
2017-08-27 14:38:04 +00:00
|
|
|
####################################
|
|
|
|
# Install some package for server (apache, mysql, screen)
|
|
|
|
####################################
|
2017-08-08 19:13:59 +00:00
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server
|
|
|
|
apt-get install -y apache2 php5 libapache2-mod-php5 php5-mysql apache2-utils php5-gd php5-imagick rrdtool screen mcrypt php5-mcrypt
|
|
|
|
|
2017-08-27 14:38:04 +00:00
|
|
|
####################################
|
|
|
|
# Initialize database
|
|
|
|
####################################
|
|
|
|
|
2017-08-08 19:13:59 +00:00
|
|
|
/usr/bin/mysql_install_db --user=mysql --skip-name-resolve || exit 2
|
|
|
|
|
|
|
|
# Start the MySQL daemon in the background.
|
|
|
|
/usr/sbin/mysqld &
|
|
|
|
mysql_pid=$!
|
|
|
|
|
2017-08-27 14:38:04 +00:00
|
|
|
# Wait mysql start
|
2017-08-08 19:13:59 +00:00
|
|
|
until /usr/bin/mysqladmin ping >/dev/null 2>&1
|
|
|
|
do
|
|
|
|
echo -n "."
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
# Initialize password root (to empty)
|
|
|
|
/usr/bin/mysqladmin -u root password '' || exit 2
|
|
|
|
|
2017-08-27 14:38:04 +00:00
|
|
|
# Adding phpmyadmin
|
2017-08-08 19:13:59 +00:00
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin
|
|
|
|
|
|
|
|
ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf || exit 2
|
|
|
|
a2enconf phpmyadmin.conf || exit 2
|
|
|
|
cp /etc/phpmyadmin/config.inc.php /etc/phpmyadmin/config.inc.php.ref || exit 2
|
|
|
|
awk '{if($0 ~ /AllowNoPassword/){$1="";}; print $0;}' /etc/phpmyadmin/config.inc.php.ref > /etc/phpmyadmin/config.inc.php || exit 2
|
|
|
|
|
|
|
|
|
|
|
|
# Stop MySQL
|
|
|
|
/usr/bin/mysqladmin shutdown
|
|
|
|
|
|
|
|
# Wait MySQL stop
|
|
|
|
wait $mysql_pid
|
|
|
|
|
2017-08-27 14:38:04 +00:00
|
|
|
####################################
|
2017-08-08 19:13:59 +00:00
|
|
|
# Initialize bashrc (for root)
|
2017-08-27 14:38:04 +00:00
|
|
|
####################################
|
2017-08-08 19:13:59 +00:00
|
|
|
cat << EOF > /root/.bashrc
|
|
|
|
# bashrc: executed by bash(1) for non-login shells.
|
|
|
|
|
|
|
|
# You may uncomment the following lines if you want 'ls' to be colorized:
|
|
|
|
export SHELL=/bin/bash
|
|
|
|
export LS_OPTIONS='--color=auto'
|
|
|
|
eval "\`dircolors\`"
|
|
|
|
alias ls='ls \$LS_OPTIONS'
|
|
|
|
alias ll='ls \$LS_OPTIONS -l'
|
|
|
|
alias l='ls \$LS_OPTIONS -lA'
|
|
|
|
|
|
|
|
# Some more alias to avoid making mistakes:
|
|
|
|
# alias rm='rm -i'
|
|
|
|
# alias cp='cp -i'
|
|
|
|
# alias mv='mv -i'
|
|
|
|
|
|
|
|
# Autocompletion
|
|
|
|
if [ -f /etc/bash_completion ]; then
|
|
|
|
. /etc/bash_completion
|
|
|
|
fi
|
|
|
|
EOF
|
|
|
|
|
2017-08-27 14:38:04 +00:00
|
|
|
####################################
|
|
|
|
# Initialize bashrc (for gameserver)
|
|
|
|
####################################
|
|
|
|
cat << EOF > /home/gameserver/.bashrc
|
|
|
|
# bashrc: executed by bash(1) for non-login shells.
|
|
|
|
|
|
|
|
# You may uncomment the following lines if you want 'ls' to be colorized:
|
|
|
|
export SHELL=/bin/bash
|
|
|
|
export LS_OPTIONS='--color=auto'
|
|
|
|
eval "\`dircolors\`"
|
|
|
|
alias ls='ls \$LS_OPTIONS'
|
|
|
|
alias ll='ls \$LS_OPTIONS -l'
|
|
|
|
alias l='ls \$LS_OPTIONS -lA'
|
|
|
|
|
|
|
|
# Some more alias to avoid making mistakes:
|
|
|
|
# alias rm='rm -i'
|
|
|
|
# alias cp='cp -i'
|
|
|
|
# alias mv='mv -i'
|
|
|
|
|
|
|
|
# Autocompletion
|
|
|
|
if [ -f /etc/bash_completion ]; then
|
|
|
|
. /etc/bash_completion
|
|
|
|
fi
|
|
|
|
EOF
|
|
|
|
chown gameserver:gameserver /home/gameserver/.bashrc
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# Adding sudo command
|
|
|
|
####################################
|
|
|
|
|
|
|
|
# Update sudo rule (you can execute all command as root)
|
2017-09-05 08:10:12 +00:00
|
|
|
cat << EOF > /etc/sudoers.d/gameserver
|
2017-08-08 19:13:59 +00:00
|
|
|
# User privilege specification
|
2017-08-27 14:38:04 +00:00
|
|
|
gameserver ALL=NOPASSWD: ALL
|
2017-08-08 19:13:59 +00:00
|
|
|
EOF
|
|
|
|
|
2017-08-27 14:38:04 +00:00
|
|
|
####################################
|
|
|
|
# LOGING HEADER
|
|
|
|
####################################
|
|
|
|
# Message see when connect on ssh
|
|
|
|
|
|
|
|
# Before login
|
|
|
|
cat << EOF > /etc/issue.net
|
|
|
|
*********************
|
|
|
|
* KHANAT SERVER DEV *
|
|
|
|
*********************
|
|
|
|
|
|
|
|
account gameserver
|
|
|
|
password khanat
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# After Login
|
|
|
|
cat << EOF > /etc/motd
|
|
|
|
***************************************************
|
2017-09-05 08:10:12 +00:00
|
|
|
connect to root use gameserver account and launch sudo command
|
|
|
|
like :
|
|
|
|
|
|
|
|
sudo bash
|
|
|
|
|
2017-08-27 14:38:04 +00:00
|
|
|
---------------------------------------------------
|
|
|
|
mysql : account root (no password)
|
2017-09-06 20:22:44 +00:00
|
|
|
---------------------------------------------------
|
|
|
|
log khanat server : /home/gameserver/khanat/server/log/log.log
|
2017-08-27 14:38:04 +00:00
|
|
|
***************************************************
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Activate banner
|
|
|
|
sed -i 's/#Banner/Banner/g' /etc/ssh/sshd_config
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# End
|
|
|
|
####################################
|
2017-08-08 19:13:59 +00:00
|
|
|
echo "End Basic"
|