add README.MD

This commit is contained in:
rnsrk 2021-08-21 23:15:09 +02:00
parent 2c6251f0c6
commit 97c2415de4
2 changed files with 100 additions and 25 deletions

2
README.MD Normal file
View file

@ -0,0 +1,2 @@
# INSTALL WISSKI SCRIPT
This script installs a LAMP-Stack (Apache2, PHP7.4, latest Mariadb) on your Ubuntu 20.04 machine and everything you need to start an install of the latest Drupal version (composer and drush). WissKI and all necessary modules/ libraries are downloaded and you have to activate them after your Drupal installation.

View file

@ -6,11 +6,10 @@ RED='\033[0;31m'
NC='\033[0m'
if [ "$EUID" -ne 0 ]
then echo -e"${RED} Please run as root${NC}"
then echo -e"${RED} Please run as root: \"sudo ./install_drupal-wisski.bash\"${NC}"
exit
fi
echo -e "${GREEN}Hi, this script installs a LAMP-Stack with the latest Drupal-WissKI for you!${NC}"
sleep 5
@ -23,11 +22,12 @@ fi
# update packages
echo -e "${GREEN}Update package manager.${NC}"
sleep 1
apt update;
# install packages
echo -e "${GREEN}Install necessary packages.${NC}"
sleep 1
apt install apache2 \
composer \
@ -48,6 +48,7 @@ apt install apache2 \
# add php configuration via wisski.ini
echo -e "${YELLOW}Add PHP configuration in /etc/php/7.4/cli/conf.d/wisski.ini${NC}"
sleep 1
echo "file_uploads = On
allow_url_fopen = On
@ -59,18 +60,21 @@ max_input_nesting_level = 640" > /etc/php/7.4/apache2/conf.d/wisski.ini
# enable mod-rewrite
echo -e "${GREEN}enable mod_rewrite for apache2.${NC}"
sleep 1
a2enmod rewrite;
# restart apache
echo -e "${GREEN}Restart apache server${NC}"
sleep 1
systemctl restart apache2
# configure site
finished=false
while [ $finished == false ]
FINISHED=false
while [ $FINISHED == false ]
do
echo -e "${GREEN}What is the name of your Website (WITHOUT \"https://www.\" etc. like \"example.com\")?${NC}"
echo -e "${YELLOW}What is the name of your Website (WITHOUT \"https://www.\" etc. like \"example.com\")?${NC}"
echo -e "${YELLOW}It will be used as webroot dir at /var/www/html/ and as your servername.${NC}"
while [[ -z $WEBSITENAME ]]
do
@ -80,7 +84,7 @@ do
echo -e "${RED}Websitename can not be emtpy! Please enter a websitename!${NC}"
fi
done
echo -e "${GREEN}Enter your server admin email adress:${NC}"
echo -e "${YELLOW}Enter your server admin email adress:${NC}"
while [[ -z $SERVERADMINEMAIL ]]
do
read SERVERADMINEMAIL
@ -89,17 +93,17 @@ do
echo -e "${RED}Server admin mail adress can not be emtpy! Please enter an amdin mail adress!${NC}"
fi
done
echo -e "${YELLOW}Websitename: ${WEBSITENAME}${NC}"
echo -e "${YELLOW}Server admin mail: ${SERVERADMINEMAIL}${NC}"
echo -e "${GREEN}Websitename: ${WEBSITENAME}${NC}"
echo -e "${GREEN}Server admin mail: ${SERVERADMINEMAIL}${NC}"
echo -e "${YELLOW}Is that correct? (Y/n)"
read SURE
if [[ $SURE == 'y' ]] || [[ $SURE == 'Y' ]] || [[ -z $SURE ]]
then
export WEBSITENAME
export SERVERADMINEMAIL
finished=true
FINISHED=true
else
echo -e "${RED}Okay then...?${NC}"
echo -e "${GREEN}Okay then...${NC}"
fi
done
@ -121,6 +125,7 @@ fi
# add apache site
echo -e "${YELLOW}Write server configuration in /etc/apache2/sites-available/${WEBSITENAME}.conf.${NC}"
sleep 1
echo "<VirtualHost *:80>
ServerAdmin ${SERVERADMINEMAIL}
DocumentRoot \"/var/www/html/${WEBSITENAME}/web\"
@ -142,34 +147,100 @@ echo "<VirtualHost *:80>
# enable site
echo -e "${GREEN}Enable site ${WEBSITENAME}${NC}"
sleep 1
a2ensite ${WEBSITENAME}
# restart apache
echo -e "${GREEN}Restart apache server${NC}"
sleep 1
systemctl restart apache2
# run mariadb security script
echo -e "${YELLOW}Making Mariadb secure. Please note your root credentials!${NC}"
mysql_secure_installation;
# create database
echo -e "${YELLOW}Create Database for Drupal. Please note your inputs, they will be needed in a moment.${NC}"
# create database user and database
echo -e "${YELLOW}Create database and user for Drupal. Please note your inputs, they will be needed in a moment.${NC}"
CORRECTDATABASE=false
CORRECTUSER=false
FINISHED=false
while [[ $CORRECTDATABASE == false ]] && [[ $CORRECTUSER == false ]]
do
while [[ $FINISHED == false ]]
do
echo -e "${YELLOW}Enter name of the Database, you want to create:${NC}"
read DB
if [[ ! -z "`mysql -qfsBe "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='${DB}'" 2>&1`" ]];
then
echo -e "${RED}Database already exists!${NC}"
echo -e "${RED}Should I drop it and recreate? Attention: All data will be lost and can not be recovered! (y/N)${NC}"
read SURE
if [[ $SURE == 'y' ]] || [[ $SURE == 'Y' ]]
then
mysql -e "DROP DATABASE ${DB};"
mysql -e "CREATE DATABASE ${DB} ;"
echo -e "${GREEN}Recreated database ${DB}.${NC}"
FINISHED=true
else
echo -e "${GREEN}Okay then...${NC}"
fi
else
mysql -e "CREATE DATABASE ${DB} ;"
echo -e "${GREEN}Created database ${DB}.${NC}"
FINISHED=true
CORRECTDATABASE=true
fi
done
FINISHED=false
while [[ $FINISHED == false ]]
do
echo -e "${YELLOW}Enter name of the user you want to create:${NC}"
read USER
echo -e "${YELLOW}Enter passwort of that user:${NC}"
read USERPW
mysql -e "CREATE DATABASE ${DB} ;"
echo -e "${GREEN}Database username: ${USER}${NC}"
echo -e "${GREEN}Database user password: ${USERPW}${NC}"
echo -e "${YELLOW}Is that correct? (Y/n)"
read SURE
if [[ $SURE == 'y' ]] || [[ $SURE == 'Y' ]] || [[ -z $SURE ]]
then
if [[ ! -z "`mysql -qfsBe "SELECT User FROM mysql.user WHERE User = '${USER}'" 2>&1`" ]];
then
echo -e "${RED}User already exists!${NC}"
echo -e "${RED}Should I drop it and recreate? (y/N)${NC}"
read SURE
if [[ $SURE == 'y' ]] || [[ $SURE == 'Y' ]]
then
mysql -e "DROP USER ${DB}@'localhost';"
mysql -e "CREATE USER ${DB}@localhost IDENTIFIED BY '${USERPW}';"
mysql -e "GRANT ALL PRIVILEGES ON ${DB}.* TO '${USER}'@'localhost';"
mysql -e "FLUSH PRIVILEGES;"
echo -e "${GREEN}Recreated User ${USER}.${NC}"
FINISHED=true
CORRECTUSER=true
else
echo -e "${GREEN}Okay then...${NC}"
fi
else
mysql -e "CREATE USER ${DB}@localhost IDENTIFIED BY '${USERPW}';"
mysql -e "GRANT ALL PRIVILEGES ON ${DB}.* TO '${USER}'@'localhost';"
mysql -e "FLUSH PRIVILEGES;"
echo -e "${GREEN}Created User ${USER}.${NC}"
FINISHED=true
CORRECTUSER=true
fi
else
echo -e "${GREEN}Okay then...${NC}"
fi
done
done
echo -e "${GREEN}Created ${DB} database with ${USER} identified by ${USERPW} ${NC}"
sleep 1
# install drupal with drush
echo -e "${GREEN}We are ready to install Drupal! It will be installed under /var/www/html/$WEBSITENAME.${NC}"
sleep 1
cd /var/www/html/
echo -e "${YELLOW}Composer will scold you for being root, ignore it, it will be taken care of later.${NC}"
@ -177,10 +248,12 @@ composer create-project drupal/recommended-project $WEBSITENAME
echo -e "${GREEN}Installing WissKI with some modules (you have to activate them later).${NC}"
sleep 1
cd $WEBSITENAME
composer require drupal/colorbox drupal/devel drush/drush drupal/imagemagick drupal/wisski
echo -e "${GREEN}Get necessary libraries.${NC}"
sleep 1
mkdir -p web/libraries
wget https://github.com/jackmoore/colorbox/archive/refs/heads/master.zip -P web/libraries/
unzip web/libraries/master.zip -d web/libraries/