2017-08-08 19:13:59 +00:00
|
|
|
#!/bin/bash
|
2017-10-09 20:10:36 +00:00
|
|
|
#
|
|
|
|
# Configure environment
|
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
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat << EOF
|
|
|
|
usage:$0 [options]
|
|
|
|
prepare mysql (create directory, update configuration)
|
2017-08-08 19:13:59 +00:00
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
options:
|
|
|
|
-h, --help : Show this help
|
|
|
|
-d, --debug : Show debug message
|
|
|
|
EOF
|
|
|
|
}
|
2017-08-08 19:13:59 +00:00
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
#####################
|
|
|
|
# MAIN
|
|
|
|
#####################
|
|
|
|
source /opt/servercontainer_function.sh
|
|
|
|
msg_info "$(basename $0) => START"
|
2017-08-08 19:13:59 +00:00
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
while test $# -gt 0
|
2017-08-08 19:13:59 +00:00
|
|
|
do
|
2017-10-09 20:10:36 +00:00
|
|
|
case "$1" in
|
|
|
|
-h|--help)
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
-d|--debug)
|
|
|
|
set_debug 1
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
msg_error "options '$1' not recoginze"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2017-08-08 19:13:59 +00:00
|
|
|
done
|
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
msg_info "configure shard.sh"
|
2017-08-08 19:13:59 +00:00
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
####################################
|
|
|
|
# configure shard.sh
|
|
|
|
####################################
|
|
|
|
cat << EOF > /opt/shard.sh
|
|
|
|
# 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'
|
2017-08-08 19:13:59 +00:00
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
# Autocompletion
|
|
|
|
if [ -f /etc/bash_completion ]; then
|
|
|
|
. /etc/bash_completion
|
|
|
|
fi
|
2017-08-08 19:13:59 +00:00
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
export KHANAT_HOME=/home/gameserver
|
|
|
|
export KHANAT_PATH=/home/gameserver/khanat
|
|
|
|
export PATH=\$PATH:/usr/local/bin:/usr/local/sbin
|
|
|
|
export PATCH_CLIENT_SYSTEM=\$KHANAT_HOME/khanat/patch_service
|
2017-08-08 19:13:59 +00:00
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
export DIRCLIENT="Khanat_Linux64"
|
|
|
|
export PREPARE_CLIENT_DIR="khanat/prepare_client/\$DIRCLIENT"
|
|
|
|
export CLIENT_DIR="khanat/client_service"
|
|
|
|
export HOME_PREPARE_CLIENT="\$KHANAT_HOME/\$PREPARE_CLIENT_DIR"
|
|
|
|
export HOME_CLIENT="\$KHANAT_HOME/\$CLIENT_DIR"
|
|
|
|
EOF
|
2017-08-08 19:13:59 +00:00
|
|
|
|
|
|
|
|
2017-08-27 14:38:04 +00:00
|
|
|
####################################
|
2017-10-09 20:10:36 +00:00
|
|
|
# Initialize bashrc gameserver
|
2017-08-27 14:38:04 +00:00
|
|
|
####################################
|
2017-10-09 20:10:36 +00:00
|
|
|
msg_info "configure bashrc"
|
|
|
|
cat << EOF > /home/gameserver/.bashrc
|
2017-08-08 19:13:59 +00:00
|
|
|
# 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
|
2017-10-09 20:10:36 +00:00
|
|
|
. /etc/bash_completion
|
2017-08-08 19:13:59 +00:00
|
|
|
fi
|
2017-10-09 20:10:36 +00:00
|
|
|
|
|
|
|
export KHANAT_HOME=/home/gameserver
|
|
|
|
export KHANAT_PATH=/home/gameserver/khanat
|
|
|
|
export PATH=\$PATH:/usr/local/bin
|
|
|
|
export PATCH_CLIENT_SYSTEM=\$KHANAT_HOME/khanat/patch_service
|
|
|
|
|
|
|
|
export DIRCLIENT="Khanat_Linux64"
|
|
|
|
export PREPARE_CLIENT_DIR="khanat/prepare_client/\$DIRCLIENT"
|
|
|
|
export CLIENT_DIR="khanat/client_service"
|
|
|
|
export HOME_PREPARE_CLIENT="\$KHANAT_HOME/\$PREPARE_CLIENT_DIR"
|
|
|
|
export HOME_CLIENT="\$KHANAT_HOME/\$CLIENT_DIR"
|
|
|
|
|
2017-08-08 19:13:59 +00:00
|
|
|
EOF
|
2017-10-09 20:10:36 +00:00
|
|
|
chown gameserver:$(id -g -n gameserver) /home/gameserver/.bashrc
|
|
|
|
|
|
|
|
|
|
|
|
# load environment
|
|
|
|
source /home/gameserver/.bashrc
|
2017-08-08 19:13:59 +00:00
|
|
|
|
2017-08-27 14:38:04 +00:00
|
|
|
####################################
|
2017-10-09 20:10:36 +00:00
|
|
|
# Initialize bashrc (for root)
|
2017-08-27 14:38:04 +00:00
|
|
|
####################################
|
2017-10-09 20:10:36 +00:00
|
|
|
msg_debug "Configure bashrc (for root)"
|
|
|
|
cat << EOF > /root/.bashrc
|
2017-08-27 14:38:04 +00:00
|
|
|
# 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
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# Adding sudo command
|
|
|
|
####################################
|
|
|
|
|
|
|
|
# Update sudo rule (you can execute all command as root)
|
2017-10-09 20:10:36 +00:00
|
|
|
msg_debug "Configure sudo"
|
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
|
2017-10-09 20:10:36 +00:00
|
|
|
msg_debug "Configure message login"
|
2017-08-27 14:38:04 +00:00
|
|
|
cat << EOF > /etc/issue.net
|
|
|
|
*********************
|
|
|
|
* KHANAT SERVER DEV *
|
|
|
|
*********************
|
|
|
|
|
|
|
|
account gameserver
|
|
|
|
password khanat
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# After Login
|
2017-10-09 20:10:36 +00:00
|
|
|
msg_debug "Configure banner"
|
2017-08-27 14:38:04 +00:00
|
|
|
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
|
2017-10-09 20:10:36 +00:00
|
|
|
msg_debug "Activate banner"
|
2017-08-27 14:38:04 +00:00
|
|
|
sed -i 's/#Banner/Banner/g' /etc/ssh/sshd_config
|
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
|
|
|
|
# Initialize ssh
|
|
|
|
/etc/init.d/ssh restart
|
|
|
|
|
2017-08-27 14:38:04 +00:00
|
|
|
####################################
|
|
|
|
# End
|
|
|
|
####################################
|
2017-10-09 20:10:36 +00:00
|
|
|
msg_info "$(basename $0) => END"
|