Dépôt contenant certaines config du VPS, un wiki avec les bonnes pratiques, quelques scripts utiles, etc. Couvre tout ce qui touche à l'adminsys du VPS, à l'exception de la v5.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
VPS-config/ldap/install.sh

51 lines
1.3 KiB

#!/usr/bin/env bash
# stop service if running
echo "stop service if running"
systemctl stop slapd.service
# deleting old databases
echo "deleting old databases"
rm -f /var/lib/openldap/openldap-data/*.mdb
# copy default config
echo "copy default config"
cp -f ./slapd.conf /etc/openldap/slapd.conf
# remove root password
echo "remove root password"
sed -i "/rootpw/ d" /etc/openldap/slapd.conf
# add new root password
echo "add new root password"
echo "rootpw $(slappasswd)" >> /etc/openldap/slapd.conf
# copy default config
echo "copy default config"
cp /var/lib/openldap/openldap-data/DB_CONFIG.example /var/lib/openldap/openldap-data/DB_CONFIG
# remove old config files
echo "remove old config files"
rm -rf /etc/openldap/slapd.d/*
# create a db if there is none
echo "create a db if there is none"
systemctl start slapd.service && systemctl stop slapd.service
# generate new config files
echo "generate new config files"
slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d/
# change ownership of slapd.d
echo "change ownership of slapd.d"
chown -R ldap:ldap /etc/openldap/slapd.d
# start service
echo "start service"
systemctl start slapd.service
# add organization
echo "add organization"
ldapadd -x -D 'cn=ldap-root,o=planet-casio' -W -f ./organization
echo "Installation done. Service is running"