Files
LEMPer/install.sh
2022-02-17 08:21:06 +07:00

279 lines
7.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# +-------------------------------------------------------------------------+
# | LEMPer is a simple LEMP stack installer for Debian/Ubuntu Linux |
# |-------------------------------------------------------------------------+
# | Min requirement : GNU/Linux Debian 8, Ubuntu 18.04 or Linux Mint 17 |
# | Last Update : 13/02/2022 |
# | Author : MasEDI.Net (me@masedi.net) |
# | Version : 2.x.x |
# +-------------------------------------------------------------------------+
# | Copyright (c) 2014-2022 MasEDI.Net (https://masedi.net/lemper) |
# +-------------------------------------------------------------------------+
# | This source file is subject to the GNU General Public License |
# | that is bundled with this package in the file LICENSE.md. |
# | |
# | If you did not receive a copy of the license and are unable to |
# | obtain it through the world-wide-web, please send an email |
# | to license@lemper.cloud so we can send you a copy immediately. |
# +-------------------------------------------------------------------------+
# | Authors: Edi Septriyanto <me@masedi.net> |
# +-------------------------------------------------------------------------+
# Work even if somebody does "bash install.sh".
#set -exv -o pipefail # For verbose output.
set -e -o pipefail
# Try to re-export global path.
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Get installer base directory.
export BASE_DIR && \
BASE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
# Include helper functions.
if [[ "$(type -t run)" != "function" ]]; then
. "${BASE_DIR}/scripts/helper.sh"
fi
# Make sure only root can run this installer script.
requires_root "$@"
# Make sure only supported distribution can run this installer script.
preflight_system_check
##
# Main LEMPer Installer
#
header_msg
echo "Starting LEMPer Stack installation..."
echo "Please ensure that you're on a fresh install!"
if [[ "${AUTO_INSTALL}" != true ]]; then
echo ""
read -t 60 -rp "Press [Enter] to continue..." </dev/tty
fi
# Init log.
run init_log
# Init config.
run init_config
### Install dependencies packages ###
if [ -f ./scripts/install_dependencies.sh ]; then
echo ""
. ./scripts/install_dependencies.sh
fi
### Clean-up server ###
if [ -f ./scripts/cleanup_server.sh ]; then
echo ""
. ./scripts/cleanup_server.sh
fi
### Create and enable swap ###
if [[ "${ENABLE_SWAP}" == true ]]; then
echo ""
enable_swap
fi
### Create default account ###
echo ""
USERNAME=${LEMPER_USERNAME:-"lemper"}
create_account "${USERNAME}"
### Nginx installation ###
if [ -f ./scripts/install_nginx.sh ]; then
echo ""
. ./scripts/install_nginx.sh
fi
### Certbot Let's Encrypt SSL installation ###
if [ -f ./scripts/install_certbotle.sh ]; then
echo ""
. ./scripts/install_certbotle.sh
fi
### PHP installation ###
if [ -f ./scripts/install_php.sh ]; then
echo ""
. ./scripts/install_php.sh
fi
### Phalcon PHP installation ###
if [ -f ./scripts/install_phalcon.sh ]; then
echo ""
. ./scripts/install_phalcon.sh
fi
### MySQL database installation ###
if [ -f ./scripts/install_mariadb.sh ]; then
echo ""
. ./scripts/install_mariadb.sh
fi
### Redis database installation ###
if [ -f ./scripts/install_redis.sh ]; then
echo ""
. ./scripts/install_redis.sh
fi
### MongoDB database installation ###
if [ -f ./scripts/install_mongodb.sh ]; then
echo ""
. ./scripts/install_mongodb.sh
fi
### Memcached installation ###
if [ -f ./scripts/install_memcached.sh ]; then
echo ""
. ./scripts/install_memcached.sh
fi
### Imagick installation ###
if [ -f ./scripts/install_imagemagick.sh ]; then
echo ""
. ./scripts/install_imagemagick.sh
fi
### Mail server installation ###
if [ -f ./scripts/install_mailer.sh ]; then
echo ""
. ./scripts/install_mailer.sh
fi
### VSFTPD installation ###
if [ -f ./scripts/install_vsftpd.sh ]; then
echo ""
. ./scripts/install_vsftpd.sh
fi
### Fail2ban, intrusion prevention software framework. ###
if [ -f ./scripts/install_fail2ban.sh ]; then
echo ""
. ./scripts/install_fail2ban.sh
fi
### LEMPer tools installation ###
if [ -f ./scripts/install_tools.sh ]; then
echo ""
. ./scripts/install_tools.sh
fi
### Basic server security setup ###
if [ -f ./scripts/secure_server.sh ]; then
echo ""
. ./scripts/secure_server.sh
fi
### FINAL SETUP ###
if [[ "${FORCE_REMOVE}" == true ]]; then
# Cleaning up all build dependencies hanging around on production server?
echo -e "\nClean up installation process..."
run apt-get autoremove -qq -y
# Cleanup build dir
echo "Clean up build directory..."
if [ -d "$BUILD_DIR" ]; then
run rm -fr "$BUILD_DIR"
fi
fi
if [[ "${DRYRUN}" != true ]]; then
status -e "\nCongrats, your LEMPer Stack installation has been completed."
### Recap ###
if [[ -n "${PASSWORD}" ]]; then
CREDENTIALS="~~~~~~~~~~~~~~~~~~~~~~~~~o0o~~~~~~~~~~~~~~~~~~~~~~~~~
Default system information:
Hostname : ${HOSTNAME}
Server IP: ${SERVER_IP}
SSH Port : ${SSH_PORT}
LEMPer Stack admin account:
Username : ${USERNAME}
Password : ${PASSWORD}
Database administration (Adminer):
http://${SERVER_IP}:8082/lcp/dbadmin/
Database root password: ${MYSQL_ROOT_PASSWORD}
Mariabackup user information:
DB Username: ${MARIABACKUP_USER}
DB Password: ${MARIABACKUP_PASS}
File manager (TinyFileManager):
http://${SERVER_IP}:8082/lcp/filemanager/
Use your default LEMPer stack admin account for Filemanager login."
if [[ "${INSTALL_MAILER}" == true ]]; then
CREDENTIALS="${CREDENTIALS}
Default Mail service:
Maildir : /home/${USERNAME}/Maildir
Sender Domain: ${SENDER_DOMAIN}
Sender IP : ${SERVER_IP}
IMAP Port : 143, 993 (SSL/TLS)
POP3 Port : 110, 995 (SSL/TLS)
Domain Key : lemper._domainkey.${SENDER_DOMAIN}
DKIM Key : ${DKIM_KEY}
SPF Record : v=spf1 ip4:${SERVER_IP} include:${SENDER_DOMAIN} mx ~all
Use your default LEMPer stack admin account for Mail login."
fi
if [[ "${INSTALL_MEMCACHED}" == true && "${MEMCACHED_SASL}" == true ]]; then
CREDENTIALS="${CREDENTIALS}
Memcached SASL login:
Username : ${MEMCACHED_USERNAME}
Password : ${MEMCACHED_PASSWORD}"
fi
if [[ "${INSTALL_MONGODB}" == true ]]; then
CREDENTIALS="${CREDENTIALS}
MongoDB test admin login:
Username : ${MONGODB_ADMIN_USER}
Password : ${MONGODB_ADMIN_PASSWORD}"
fi
if [[ "${INSTALL_REDIS}" == true && "${REDIS_REQUIRE_PASSWORD}" == true ]]; then
CREDENTIALS="${CREDENTIALS}
Redis required password enabled:
Password : ${REDIS_PASSWORD}"
fi
CREDENTIALS="${CREDENTIALS}
Please Save the above Credentials & Keep it Secure!
~~~~~~~~~~~~~~~~~~~~~~~~~o0o~~~~~~~~~~~~~~~~~~~~~~~~~"
status "${CREDENTIALS}"
# Save it to log file
#save_log "${CREDENTIALS}"
# Securing LEMPer stack credentials.
#secure_config
fi
else
warning -e "\nLEMPer installation has been completed in dry-run mode."
fi
echo "
See the log file (lemper.log) for more information.
Now, you can reboot your server and enjoy it!
"
info "SECURITY PRECAUTION! Due to the log file contains some credential data,
You SHOULD delete it after your stack completely installed."
footer_msg