199 lines
5.0 KiB
Bash
199 lines
5.0 KiB
Bash
#!/bin/bash
|
|
# Bash Menu Script Example
|
|
#==============================================================================
|
|
# UBUNTU 18.04 BASH SCRIPT
|
|
#==============================================================================
|
|
##R1 V1.1##
|
|
#===Changes For V1===#
|
|
#Added Variables and executes for them#
|
|
#===Changes For V1.1===#
|
|
# Nginx, apache, certbot, phpmyadmin, php-fpm, postfix, netdata, Memcached, redis, wordpress & opcache#
|
|
#install scripts were added#
|
|
#==============================================================================
|
|
# UNDER DEVELOPMENT
|
|
#==============================================================================
|
|
# Mailserver -->> EXIM, DOVECOT, SPAMASSASSIN, CLAMAV
|
|
# FTP backups -->> VSFTPD
|
|
# Secure WP -->> NGINX RULES
|
|
# WP backup & restore -->> SHELL or PHP
|
|
# LAMP SETUP
|
|
# APACHE, NGINX REVERSE PROXY
|
|
#==============================================================================
|
|
# CHECKEN!
|
|
# > Postfix
|
|
#==============================================================================
|
|
|
|
#--------#
|
|
# Menu #
|
|
#--------#
|
|
|
|
echo "UBUNTU 18.04 INSTALLATIE SCRIPT"
|
|
echo Welk domein mag gekoppeld worden? Typ domein zonder www
|
|
read domain
|
|
echo Standaard wachtwoord
|
|
read passwd
|
|
echo administrator email
|
|
read email
|
|
echo "Webserver:"
|
|
PS3='Keuze:'
|
|
options=("Apache" "Apache, Nginx reverse proxy" "Nginx, PHP-FPM" "Quit")
|
|
select opt in "${options[@]}"
|
|
do
|
|
case $opt in
|
|
"Apache")
|
|
script=https://trans.bprieshof.nl/gitea/ICT-Maatwerk/Vps-UBUNTU-SetupScripts/raw/branch/master/Apache-Installer.sh
|
|
break;;
|
|
"Apache, Nginx reverse proxy")
|
|
script=https://trans.bprieshof.nl/gitea/ICT-Maatwerk/Vps-UBUNTU-SetupScripts/raw/branch/master/RevProxySimple.sh
|
|
break;;
|
|
"Nginx, PHP-FPM")
|
|
script=https://trans.bprieshof.nl/gitea/ICT-Maatwerk/Vps-UBUNTU-SetupScripts/raw/branch/master/NGINX-Installer.sh
|
|
break;;
|
|
"Quit")
|
|
exit;;
|
|
*) echo "Fout commando $REPLY";;
|
|
esac
|
|
done
|
|
|
|
while true; do
|
|
read -p "Installeer Netdata -> yes/no?" yn
|
|
case $yn in
|
|
[Yy]* ) netdata=1
|
|
break;;
|
|
[Nn]* ) netdata=0
|
|
break;;
|
|
* ) echo "Kies yes of no.";;
|
|
esac
|
|
done
|
|
|
|
while true; do
|
|
read -p "Installeer Memcached -> yes/no?" yn
|
|
case $yn in
|
|
[Yy]* ) memcached=1
|
|
break;;
|
|
[Nn]* ) memcached=0
|
|
break;;
|
|
* ) echo "Kies yes of no.";;
|
|
esac
|
|
done
|
|
|
|
while true; do
|
|
read -p "Installeer Redis Cache -> yes/no?" yn
|
|
case $yn in
|
|
[Yy]* ) redis=1
|
|
break;;
|
|
[Nn]* ) redis=0
|
|
break;;
|
|
* ) echo "Kies yes of no.";;
|
|
esac
|
|
done
|
|
|
|
while true; do
|
|
read -p "Installeer Wordpress -> yes/no?" yn
|
|
case $yn in
|
|
[Yy]* ) wordpress=1
|
|
break;;
|
|
[Nn]* ) wordpress=0
|
|
break;;
|
|
* ) echo "Kies yes of no.";;
|
|
esac
|
|
done
|
|
|
|
#-------------------#
|
|
# Preconfiguration #
|
|
#-------------------#
|
|
|
|
cd /tmp
|
|
apt update
|
|
apt upgrade -y
|
|
apt dist-upgrade -y
|
|
apt install -y rsync grsync sshpass
|
|
apt clean
|
|
apt autoremove -y
|
|
hostnamectl set-hostname $domain
|
|
sed -i 's/;preserve_hostname: false/preserve_hostname: true/g' /etc/cloud/cloud.cfg
|
|
timedatectl set-timezone Europe/Amsterdam
|
|
sed -i 's/#/vm.swappiness=10/g' /etc/sysctl.conf
|
|
sed -i 's/#/vm.vfs_cache_pressure=50/g' /etc/sysctl.conf
|
|
touch /etc/cron.d/updates
|
|
cat <<EOF > /etc/cron.d/updates
|
|
SHELL=/bin/sh
|
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
|
# m h dom mon dow command
|
|
0 0 * * * apt update -y && apt upgrade -y && apt dist-upgrade -y
|
|
EOF
|
|
ufw allow OpenSSH
|
|
ufw allow 443/tcp
|
|
ufw allow 80/tcp
|
|
ufw limit ssh
|
|
echo "y" | sudo ufw enable
|
|
|
|
#-------------------#
|
|
# Install Phase #
|
|
#-------------------#
|
|
|
|
echo "***************************"
|
|
sleep 0.5
|
|
echo "INSTALLATIE DUURT 5 Minuten"
|
|
sleep 0.5
|
|
echo "***************************"
|
|
|
|
wget $script -O script.sh
|
|
source script.sh
|
|
|
|
#-------------------#
|
|
# MYSQL SETTINGS #
|
|
#-------------------#
|
|
|
|
rm /etc/mysql/my.cnf
|
|
cat > /etc/mysql/my.cnf <<- "EOF"
|
|
# - "/etc/mysql/my.cnf" to set global options,
|
|
[mysqld_safe]
|
|
socket = /var/run/mysqld/mysqld.sock
|
|
nice = 0
|
|
|
|
[mysqld]
|
|
user = mysql
|
|
pid-file = /var/run/mysqld/mysqld.pid
|
|
socket = /var/run/mysqld/mysqld.sock
|
|
port = 3306
|
|
basedir = /usr
|
|
datadir = /var/lib/mysql
|
|
tmpdir = /tmp
|
|
lc-messages-dir = /usr/share/mysql
|
|
skip-external-locking
|
|
|
|
innodb_buffer_pool_size = 1G # (adjust value here, 50%-70% of total RAM)
|
|
innodb_log_file_size = 256M
|
|
innodb_flush_log_at_trx_commit = 1 # may change to 2 or 0
|
|
innodb_flush_method = O_DIRECT
|
|
bind-address = 127.0.0.1
|
|
key_buffer_size = 16M
|
|
max_allowed_packet = 16M
|
|
thread_stack = 192K
|
|
thread_cache_size = 8
|
|
myisam-recover-options = BACKUP
|
|
#max_connections = 100
|
|
#table_open_cache = 64
|
|
#thread_concurrency = 10
|
|
query_cache_limit = 1M
|
|
query_cache_size = 16M
|
|
log_error = /var/log/mysql/error.log
|
|
expire_logs_days = 10
|
|
max_binlog_size = 100M
|
|
EOF
|
|
|
|
#--------------#
|
|
# Reboot #
|
|
#--------------#
|
|
|
|
echo "Install Succes"
|
|
echo "Reboot system in:"
|
|
sleep 1
|
|
echo 3
|
|
sleep 1
|
|
echo 2
|
|
sleep 1
|
|
echo 1
|
|
reboot
|
|
exit |