# * local_setup: Should the Active Directory be installed locally ?
# * local_setup: Should the LDAP be installed locally ?
# 1 = yes
# 2 = no
# * password: the clear password for the admin user of the LDAP
# * domain: the domain extension to use for the LDAP structure in LDAP notation
###
echo"Setting up the active direcory ..."
echo"Setting up the LDAP ..."
local_setup=$1
password=$2
domain=$3
local_setup="$1"
password="$2"
domain="$3"
if[$local_setup==1];then
if["$local_setup"==1];then
echo"Installing slapd package ..."
apt-get -y install slapd
echo"Installing slapd package: Done"
echo"Hashing the LDAP password ..."
hashed_ldap_passwd=$(slappasswd -s $1)
hashed_ldap_passwd="$(slappasswd -s $1)"
echo"Hash of the password: $hashed_ldap_passwd"
echo"Building the LDAP config files ..."
sed 's|dc=example,dc=org|'"$2"'|g' install_utils/db.ldiff | sed 's|FILL_IT|'"$hashed_ldap_passwd"'|g' > /tmp/db
sed 's|dc=example,dc=org|'"$2"'|g' install_utils/schema.ldiff | sed 's|FILL_IT|'"$hashed_ldap_passwd"'|g' > /tmp/schema
sed 's|dc=example,dc=net|'"$2"'|g' install_utils/db.ldiff | sed 's|FILL_IT|'"$hashed_ldap_passwd"'|g' > /tmp/db
sed 's|dc=example,dc=net|'"$2"'|g' install_utils/schema.ldiff | sed 's|FILL_IT|'"$hashed_ldap_passwd"'|g' > /tmp/schema
echo"Building the LDAP config files: Done"
echo"Stopping slapd service ..."
@ -203,7 +250,7 @@ install_active_directory() {
fi
echo"Setting up the active directory: Done"
echo"Setting up the LDAP: Done"
}
@ -223,13 +270,13 @@ write_settings_file() {
# * sql_db_name: The name of the database itself
# * sql_username: The user to use to access the database
# * sql_password: The password to use to access the database
# * ldap_cn: The CN entry for the Active Directory admin in LDAP notation
# * ldap_tls: Should the TLS be activated to contact the Active Directory
# * ldap_cn: The CN entry for the LDAP admin in LDAP notation
# * ldap_tls: Should the TLS be activated to contact the LDAP
# 1 = yes
# 2 = no
# * ldap_password: The password to use to connect to the Active Directoryy
# * ldap_hostname: The hostname for contacting the Active Directory
# * ldap_domain: The local domain for the Active Directory in LDAP notation
# * ldap_password: The password to use to connect to the LDAP
# * ldap_hostname: The hostname for contacting the LDAP
# * ldap_domain: The local domain for the LDAP in LDAP notation
# * email_hostname: The hostname for contacting the mail server
# * email_port: The port for contacting the mail server
# * extension: The extension to use
@ -238,48 +285,48 @@ write_settings_file() {
echo"Writing of the settings_local.py file ..."
db_engine_type=$1
sql_hostname=$2
sql_db_name=$3
sql_username=$4
sql_password=$5
ldap_cn=$6
ldap_tls=$7
ldap_password=$8
ldap_hostname=$9
ldap_domain=${10}
email_hostname=${11}
email_port=${12}
extension=${13}
url=${14}
cp $SETTINGS_EXAMPLE_FILE$SETTINGS_LOCAL_FILE
django_secret_key=$(python -c "import random; print(''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789%=+') for i in range(50)]))")
aes_key=$(python -c "import random; print(''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789%=+') for i in range(32)]))")
db_engine_type="$1"
sql_hostname="$2"
sql_db_name="$3"
sql_username="$4"
sql_password="$5"
ldap_cn="$6"
ldap_tls="$7"
ldap_password="$8"
ldap_hostname="$9"
ldap_domain="${10}"
email_hostname="${11}"
email_port="${12}"
extension="${13}"
url="${14}"
cp "$SETTINGS_EXAMPLE_FILE""$SETTINGS_LOCAL_FILE"
django_secret_key="$(python -c "import random; print(''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789%=+') for i in range(50)]))")"
aes_key="$(python -c "import random; print(''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789%=+') for i in range(32)]))")"
if[$db_engine_type==1];then
sed -i 's/db_engine/django.db.backends.mysql/g'$SETTINGS_LOCAL_FILE
if["$db_engine_type"==1];then
sed -i 's/db_engine/django.db.backends.mysql/g'"$SETTINGS_LOCAL_FILE"
else
sed -i 's/db_engine/django.db.backends.postgresql_psycopg2/g'$SETTINGS_LOCAL_FILE
sed -i 's/db_engine/django.db.backends.postgresql_psycopg2/g'"$SETTINGS_LOCAL_FILE"
fi
sed -i 's/SUPER_SECRET_KEY/'"$django_secret_key"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/SUPER_SECRET_DB/'"$sql_password"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/A_SECRET_AES_KEY/'"$aes_key"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/db_name_value/'"$sql_db_name"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/db_user_value/'"$sql_username"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/db_host_value/'"$sql_hostname"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/ldap_dn/'"$ldap_cn"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/SUPER_SECRET_KEY/'"$django_secret_key"'/g'"$SETTINGS_LOCAL_FILE"
sed -i 's/SUPER_SECRET_DB/'"$sql_password"'/g'"$SETTINGS_LOCAL_FILE"
sed -i 's/A_SECRET_AES_KEY/'"$aes_key"'/g'"$SETTINGS_LOCAL_FILE"
sed -i 's/db_name_value/'"$sql_db_name"'/g'"$SETTINGS_LOCAL_FILE"
sed -i 's/db_user_value/'"$sql_username"'/g'"$SETTINGS_LOCAL_FILE"
sed -i 's/db_host_value/'"$sql_hostname"'/g'"$SETTINGS_LOCAL_FILE"
sed -i 's/ldap_dn/'"$ldap_cn"'/g'"$SETTINGS_LOCAL_FILE"
if[$ldap_tls==2];then
sed -i "s/'TLS': True,/# 'TLS': True,#/g"$SETTINGS_LOCAL_FILE
sed -i "s/'TLS': True,/# 'TLS': True,/g""$SETTINGS_LOCAL_FILE"
fi
sed -i 's/SUPER_SECRET_LDAP/'"$ldap_password"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/ldap_host_ip/'"$ldap_hostname"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/dc=example,dc=org/'"$ldap_domain"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/example.org/'"$extension"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/MY_EMAIL_HOST/'"$email_hostname"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/MY_EMAIL_PORT/'"$email_port"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/URL_SERVER/'"$url"'/g'$SETTINGS_LOCAL_FILE
sed -i 's/SUPER_SECRET_LDAP/'"$ldap_password"'/g'"$SETTINGS_LOCAL_FILE"
sed -i 's/ldap_host_ip/'"$ldap_hostname"'/g'"$SETTINGS_LOCAL_FILE"
sed -i 's/dc=example,dc=net/'"$ldap_domain"'/g'"$SETTINGS_LOCAL_FILE"
sed -i 's/example.net/'"$extension"'/g'"$SETTINGS_LOCAL_FILE"
sed -i 's/MY_EMAIL_HOST/'"$email_hostname"'/g'"$SETTINGS_LOCAL_FILE"
sed -i 's/MY_EMAIL_PORT/'"$email_port"'/g'"$SETTINGS_LOCAL_FILE"
sed -i 's/URL_SERVER/'"$url"'/g'"$SETTINGS_LOCAL_FILE"
echo"Writing of the settings_local.py file: Done"
}
@ -335,11 +382,11 @@ install_webserver() {
echo"Setting up web server ..."
engine_type=$1
tls=$2
url=$3
engine_type="$1"
tls="$2"
url="$3"
if[$engine_type==1];then
if["$engine_type"==1];then
echo"Setting up Apache2 web server ..."
@ -348,12 +395,12 @@ install_webserver() {
a2enmod wsgi
a2enconf javascript-common
if[$tls==1];then
if["$tls"==1];then
echo"Setting up TLS with LE for Apache2 web server ..."
# Prompt to enter the requested URL for the web frontend
TITLE="Web URL"
INPUTBOX="URL for accessing the web server (e.g. re2o.example.net). Be sure that this URL is accessible and correspond to a DNS entry (if applicable)."
# Prompt to inform the installation process is over
TITLE="End of the setup"
MSGBOX="You can now visit $url_server and connect with the credentials you just entered. This user hhas the superuser rights, meaning he can access and do everything."