mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-10 01:09:34 +00:00
172 lines
4.3 KiB
Bash
Executable file
172 lines
4.3 KiB
Bash
Executable file
#!/bin/bash
|
|
####################################
|
|
#
|
|
####################################
|
|
|
|
echo "Start Basic"
|
|
|
|
####################################
|
|
# Install some package for server (apache, mysql, screen)
|
|
####################################
|
|
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
|
|
|
|
####################################
|
|
# Initialize database
|
|
####################################
|
|
|
|
/usr/bin/mysql_install_db --user=mysql --skip-name-resolve || exit 2
|
|
|
|
# Start the MySQL daemon in the background.
|
|
/usr/sbin/mysqld &
|
|
mysql_pid=$!
|
|
|
|
# Wait mysql start
|
|
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
|
|
|
|
# Adding phpmyadmin
|
|
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
|
|
|
|
####################################
|
|
# Initialize bashrc (for root)
|
|
####################################
|
|
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
|
|
|
|
####################################
|
|
# Initialize bashrc (for compil)
|
|
####################################
|
|
cat << EOF > /home/compil/.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 compil:compil /home/compil/.bashrc
|
|
|
|
####################################
|
|
# 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)
|
|
cat << EOF > /etc/sudoers.d/compil
|
|
# User privilege specification
|
|
compil ALL=NOPASSWD: ALL
|
|
gameserver ALL=NOPASSWD: ALL
|
|
EOF
|
|
|
|
####################################
|
|
# LOGING HEADER
|
|
####################################
|
|
# Message see when connect on ssh
|
|
|
|
# Before login
|
|
cat << EOF > /etc/issue.net
|
|
*********************
|
|
* KHANAT SERVER DEV *
|
|
*********************
|
|
|
|
account compil
|
|
password khanat
|
|
|
|
account gameserver
|
|
password khanat
|
|
|
|
EOF
|
|
|
|
# After Login
|
|
cat << EOF > /etc/motd
|
|
***************************************************
|
|
connect to root use compil or gameserver and launch
|
|
sudo bash
|
|
---------------------------------------------------
|
|
mysql : account root (no password)
|
|
***************************************************
|
|
EOF
|
|
|
|
# Activate banner
|
|
sed -i 's/#Banner/Banner/g' /etc/ssh/sshd_config
|
|
|
|
####################################
|
|
# End
|
|
####################################
|
|
echo "End Basic"
|