diff --git a/README.md b/README.md new file mode 100644 index 0000000..8bdd16f --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# provisioning + +Bash scripts for provisioning a working Alfresco 5.2g with Share 5.2f on CentOs7.x from zero. + +The scripts are re-runnable, they could continue there where they failed for any reason. diff --git a/jboss_for_alfresco/add_datasource.sh b/jboss_for_alfresco/add_datasource.sh new file mode 100644 index 0000000..1e1d29a --- /dev/null +++ b/jboss_for_alfresco/add_datasource.sh @@ -0,0 +1,62 @@ +usage() +{ + echo 'Usage:' + echo 'You must specify:' + echo ' 1, standalone.xml full path e.g.: /usr/share/jboss-as/standalone/configuration/standalone.xml' + echo ' 2, datasource template xml, e.g.: datasource_template.xml' + echo ' 3, datasource name, e.g.: AlfrescoDS' + echo ' 4, database host' + echo ' 5, database port, in case of PostgreSQL, the default is 5432' + echo ' 6, database name' + echo ' 7, database user' + echo ' 8, database password' + exit 1 +} + +# args: +# - target file +# - descriptor template +# - datasource name +# - db host +# - db port +# - db name +# - db user +# - db port +replace_datasource_descriptor() +{ + cp $2 /tmp/$1 + sed -i -e 's/$DATASOURCENAME/'"$3"'/g' /tmp/$1 + sed -i -e 's/$DBHOST/'"$4"'/g' /tmp/$1 + sed -i -e 's/$DBPORT/'"$5"'/g' /tmp/$1 + sed -i -e 's/$DBNAME/'"$6"'/g' /tmp/$1 + sed -i -e 's/$DBUSER/'"$7"'/g' /tmp/$1 + sed -i -e 's/$DBPASSWORD/'"$8"'/g' /tmp/$1 +} + +runinstallation() +{ +if [[ $(grep $3 $1 | wc -l) == 0 ]] ; then + echo "Appending $3 datasource to $1" + replace_datasource_descriptor datasource.xml "${@:2}" + fulllength=$(cat $1 | wc -l) + position=$(awk '/<\/datasource>/{print NR;exit}' $1) + head -n $position $1 > /tmp/standalone.xml + cat /tmp/datasource.xml >> /tmp/standalone.xml + lastpart=$(($fulllength - $position)) + tail -n $lastpart $1 >> /tmp/standalone.xml + cp $1 $1.before.$3 + mv /tmp/standalone.xml $1 +else + echo "DataSource $3 has already been added to $1" +fi +} + +# +# MAIN +# + +if [[ $# != 8 ]] ; then + usage +else + runinstallation "$@" +fi diff --git a/jboss_for_alfresco/alfresco_war_logging.xml b/jboss_for_alfresco/alfresco_war_logging.xml new file mode 100644 index 0000000..0c281fc --- /dev/null +++ b/jboss_for_alfresco/alfresco_war_logging.xml @@ -0,0 +1,672 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jboss_for_alfresco/datasource_template.xml b/jboss_for_alfresco/datasource_template.xml new file mode 100644 index 0000000..d6ff40a --- /dev/null +++ b/jboss_for_alfresco/datasource_template.xml @@ -0,0 +1,29 @@ + + jdbc:postgresql://$DBHOST:$DBPORT/$DBNAME + org.postgresql.Driver + postgresql + + 0 + 20 + + + $DBUSER + $DBPASSWORD + + + + + + + false + 0 + 5 + 0 + 0 + 0 + 0 + + + false + + diff --git a/jboss_for_alfresco/install_alfresco_war.sh b/jboss_for_alfresco/install_alfresco_war.sh new file mode 100644 index 0000000..070bab3 --- /dev/null +++ b/jboss_for_alfresco/install_alfresco_war.sh @@ -0,0 +1,309 @@ +usage() +{ + echo 'Usage:' + echo 'You must specify:' + echo ' 1, Install material folder' + echo ' 2, jboss target folder, e.q.: /usr/share/jboss-as' + echo ' 3, jboss user name' + echo ' 4, alfresco data folder e.g.: /data/alfresco' + echo ' 5, alfresco admin password' + echo ' 6 alfresco data source e.g.: AlfrescoDS' + echo ' 7, database name' + echo ' 8, database hostname' + echo ' 9, database port' + echo ' 10, database user' + echo " 11, database user's password" + echo ' 12, ldap host' + echo ' 13, ldap bind user (with double escaped (!) DN, e.g.: uid\\=ldapbind,ou\\=Technical,dc\\=myproject,dc\\=local)' + echo " 14, ldap bind user's password" + echo ' 15, ldap group search base (with double escaped DN, e.g.: ou\\=Groups,ou\\=Normal,dc\\=myproject,dc\\=local)' + echo ' 16, ldap user search base (with double escaped DN, e.g.: ou\\=Users,ou\\=Normal,dc\\=myproject,dc\\=local)' + exit 1 +} + +# args: package name +function isinstalled +{ + echo "Testing whether $1 is installed or not" + if yum list installed $1 >/dev/null 2>&1; then + true + else + false + fi +} + +# installs all required packages +function install_packages +{ + if ! ( isinstalled zip ) ; then + echo "installing zip" + yum -y install zip + else + echo "zip already installed" + fi +} + +# args: directory path, owner +createdirectory() +{ + if [ -d "$1" ] ; then + echo "$1 already exists, doing nothing with it" + else + echo "Creating $1" + mkdir $1 + chown -R $2:$2 $1 + fi +} + +# args: target jboss folder, jboss user +create_alf_jboss_module_conf() +{ +if [ -f $1/modules/org/alfresco/configuration/main/module.xml ] ; then +echo "$1/modules/org/alfresco/configuration/main/module.xml already exists" +else +echo "writing $1/modules/org/alfresco/configuration/main/module.xml" +cat > $1/modules/org/alfresco/configuration/main/module.xml < + + + + + +EOF +chown $2:$2 $1/modules/org/alfresco/configuration/main/module.xml +fi +} + +create_alf_global_properties() +{ +if [ -f $2/modules/org/alfresco/configuration/main/alfresco-global.properties ] ; then +echo "$2/modules/org/alfresco/configuration/main/alfresco-global.properties already exists" +else +echo "writing $2/modules/org/alfresco/configuration/main/alfresco-global.properties" + +cat > $2/modules/org/alfresco/configuration/main/alfresco-global.properties < $confdir/ldap-authentication.properties </{print NR;exit}' $1) + head -n $position $1 > /tmp/standalone.xml + cat alfresco_war_logging.xml >> /tmp/standalone.xml + lastpart=$(($fulllength - $position)) + tail -n $lastpart $1 >> /tmp/standalone.xml + cp $1 $1.before.alf.logging + mv /tmp/standalone.xml $1 +else + echo "alfresco logging profile already added" +fi +} + +configure_alfresco_war() +{ + echo "configuring alfresco.war..." + if [ ! -f $1/alfresco-platform-5.2.g.war ] ; then + echo "Missing $1/alfresco-platform-5.2.g.war: installation failed!" + exit 1 + else + if [ ! -f /tmp/alfresco.war ] ; then + echo "Missing manipulated /tmp/alfresco.war war file, creating..." + mkdir /tmp/alf + cp $1/alfresco-platform-5.2.g.war /tmp/alf + cd /tmp/alf + echo "unzipping alfresco.war..." + unzip -q alfresco-platform-5.2.g.war + rm -f alfresco-platform-5.2.g.war + echo "replacing datasource references" + sed -i -e 's/datasources\/MySqlDS/'"$2"'/g' /tmp/alf/WEB-INF/jboss-web.xml + echo "placing jboss-deployment-structure.xml" + create_jboss_deployment_structure /tmp/alf/WEB-INF + fix_manifest_error /tmp/alf/META-INF + add_logging_profile_to_manifest /tmp/alf/META-INF + echo "zipping /tmp/alfesco.war..." + zip -q -r /tmp/alfresco.war * + cd ~ + rm -Rf /tmp/alf + else + echo "Found manipulated /tmp/alfresco.war, do nothing" + fi + fi +} + +fix_manifest_error() +{ +sed -i -e 's/\r$//g' $1/MANIFEST.MF +perl -i -p0e 's/a\s+?lfresco/alfresco/s' $1/MANIFEST.MF +} + +add_logging_profile_to_manifest() +{ +echo "adding logging profile" +cp $1/MANIFEST.MF /tmp/MANIFEST_ORIG.MF +all=$(cat $1/MANIFEST.MF | wc -l) +head -n 18 $1/MANIFEST.MF > /tmp/MANIFEST.MF +echo -e "Logging-Profile: alfresco" >> /tmp/MANIFEST.MF +rest=$((all - 18)) +tail -n $rest $1/MANIFEST.MF /tmp/MANIFEST.MF +cp /tmp/MANIFEST.MF $1/MANIFEST.MF -f + +cp $1/MANIFEST.MF /tmp/MANIFEST_MODDED.MF +} + +create_jboss_deployment_structure() +{ +cat > $1/jboss-deployment-structure.xml < + + + + + + + + + + + +EOF +} + +apply_repo_amp_and_share_services_amp() +{ + if [ ! -f $1/alfresco-mmt-5.2.g.jar ] ; then + echo "Missing $1/alfresco-mmt-5.2.g.jar : installation failed" + exit 1 + fi + + if [ ! -f $1/alfresco-share-services-5.2.f.amp ] ; then + echo "Missing $1/alfresco-share-services-5.2.f.amp : installation failed" + exit 1 + fi + + cd $1 + echo "Applying share-services amp" + java -jar alfresco-mmt-5.2.g.jar install alfresco-share-services-5.2.f.amp /tmp/alfresco.war +} + +deploy_alfresco_war() +{ +if [ -f $1/standalone/deployments/alfresco.war ] ; then + echo "$1/standalone/deployments/alfresco.war already exists: do nothing" +else + echo "Copying /tmp/alfresco.war to $1/standalone/deployments" + cp /tmp/alfresco.war $1/standalone/deployments + chown $2:$2 $1/standalone/deployments/alfresco.war +fi +} + +runinstallation() +{ + install_packages + createdirectory $4 $3 + createdirectory $2/modules/org $3 + createdirectory $2/modules/org/alfresco $3 + createdirectory $2/modules/org/alfresco/configuration $3 + createdirectory $2/modules/org/alfresco/configuration/main $3 + create_alf_jboss_module_conf $2 $3 + create_alf_global_properties "$@" + create_alf_ldap_conf "$@" + add_alf_logging_profile $2/standalone/configuration/standalone.xml + configure_alfresco_war $1 $6 + apply_repo_amp_and_share_services_amp $1 + deploy_alfresco_war $2 $3 +} + +# +# MAIN +# + +if [[ $# != 16 ]]; then + usage +else + runinstallation "$@" +fi diff --git a/jboss_for_alfresco/install_jboss.sh b/jboss_for_alfresco/install_jboss.sh new file mode 100644 index 0000000..6c39f45 --- /dev/null +++ b/jboss_for_alfresco/install_jboss.sh @@ -0,0 +1,360 @@ +usage() +{ + echo 'Jboss 7.0 EAP install script for CentOS 7.x - for alfresco 5.2g' + echo '' + echo 'Run it as root. You must specify:' + echo ' 1, Install material folder' + echo ' 2, jboss target folder, e.q.: /usr/share/jboss-as' + echo ' 3, jboss service name' + echo ' 4, jboss user name' + echo ' 5, the server hostname' + echo ' 6, the server ip address' + echo ' 7, debug port, jboss will be started in debug mode, specify 0 if jboss should be started in normal mode' + exit 1 +} + +# checks one port in firewalld +# args: port +checkport() +{ +echo "Testing whether $1 port is open" +if [[ $(firewall-cmd --list-ports | grep -w $1 | wc -l) == 1 ]] ; then + echo "Port $1 is already opened" + true +else + false +fi +} + +# checks whether service is running +# args: service name +isservicerunning() +{ +if [[ $(systemctl is-active $1) == 'active' ]] ; then + echo "$1 is running" + true +else + echo "$1 is not running" + false +fi +} + +# open the default port if needed +openport() +{ + if ! ( isserviceenabled firewalld ) ; then + echo "Enabling firewall" + systemctl enable firewalld + else + echo "Firewall already enabled" + fi + + if ! ( isservicerunning firewalld ) ; then + echo "Starting firewall" + systemctl start firewalld + else + echo "Firewall is running" + fi + + if ! ( checkport 8080 ) ; then + echo "Opening default jboss port (8080)" + firewall-cmd --zone=public --add-port=8080/tcp --permanent + firewall-cmd --reload + else + echo "Port 5432 is already open" + fi +} + +# adds the given hostname and ip to the hostfile if needed +# args: the hostname and the ip +checkhostfile() +{ +if [[ $(grep $2 /etc/hosts | wc -l) == 1 ]] ; then + echo "Hostfile OK: already contains $2" +else + echo "Writing hostfile" + echo "$2 $1" >> /etc/hosts +fi +} + +# checks if the specific package is installed or not +# args: package name +function isinstalled +{ + echo "Testing whether $1 is installed or not" + if yum list installed $1 >/dev/null 2>&1; then + true + else + false + fi +} + +# installs all required packages +function install_packages +{ + if ! ( isinstalled unzip ) ; then + echo "installing unzip" + yum -y install unzip + else + echo "unzip already installed" + fi +} + +# args: install material folder +jbosszipexists() +{ + if [ -f $1/jboss-eap-7.0.0.zip ] ; then + echo "$1/jboss-eap-7.0.0.zip is exists in install material directory" + else + echo "File $1/jboss-eap-7.0.0.zip does not exists: installation failed" + exit 1 + fi +} + +# args: user name +isuserexists() +{ + if id "$1" >/dev/null 2>&1 ; then + echo "$1 user exists" + true + else + echo "$1 user does not exist" + false + fi +} + +# args: group name +isgroupexists() +{ + if [ $(grep -c "$1" /etc/group) == 1 ] ; then + echo "$1 group exists" + true + else + echo "$1 group does not exist" + false + fi +} + +# args: jboss user (and the default group) name +createjbossuserandgroup() +{ + if isgroupexists $1 ; then + echo "$1 group already created" + else + echo "creating $1 group" + groupadd -r $1 -g 1000 + fi + if isuserexists $1 ; then + echo "$1 user already created" + else + echo "creating $1 user" + useradd -u 1000 -r -g $1 -m -d /home/$1 -s /sbin/nologin -c "$1 user" $1 + chown -R $1:$1 /home/$1 + fi +} + +# args: directory path, owner +createdirectory() +{ + if [ -d "$1" ] ; then + echo "$1 already exists, doing nothing with it" + else + echo "Creating $1" + mkdir -p $1 + chown -R $2:$2 $1 + fi +} + +#args: installmaterial folder, jboss target folder, jboss service name, jboss user +unzipjboss() +{ +echo "$@" + if [ -d $2 ] ; then + echo "$2 already exists: it seems jboss is already installed: do nothing" + else + echo "$2 does not exist: unzipping $1/jboss-eap-7.0.0.zip to /usr/share" + unzip -q $1/jboss-eap-7.0.0.zip -d /usr/share + cd /usr/share + echo "moving /usr/share/jboss-eap-7.0 to $2" + mv /usr/share/jboss-eap-7.0 $2 + chown -R $4:$4 $2 + fi +} + +#args: jboss target folder, jboss service name, jboss user +create_jboss_as_conf() +{ +if [ -f /etc/jboss-as/$2.conf ] ; then + echo "File /etc/jboss-as/$2.conf already exists" +else + echo "writing /etc/jboss-as/$2.conf" + cat > /etc/jboss-as/$2.conf < /etc/systemd/system/$2.service <+$/, /<\/subsystem>+$/{next}1' /tmp/standalone.xml > $1/standalone/configuration/standalone.xml + rm -f /tmp/standalone.xml +fi +} + +# args: jboss target folder +disable_jsf_subsystem_in_jboss() +{ +if [[ $(grep "urn\:jboss\:domain\:jsf\:1.0" $1/standalone/configuration/standalone.xml | wc -l) == 0 ]] ; then + echo "urn:jboss:domain:jsf:1.0 already removed from $1/standalone/configuration/standalone.xml" +else + echo "Removing urn:jboss:domain:jsf:1.0 from $1/standalone/configuration/standalone.xml" + sed -i '/org.jboss.as.jsf/c\' $1/standalone/configuration/standalone.xml + sed -i '/urn:jboss:domain:jsf:1.0/c\' $1/standalone/configuration/standalone.xml +fi +} + +# args: jboss target folder +open_ajp_port() +{ +if [[ $(grep "" $1/standalone/configuration/standalone.xml | wc -l) == 1 ]] ; then + echo "ajp listener already added" +else + echo "adding ajp listener" + sed -i '//c\' $1/standalone/configuration/standalone.xml +fi +} + +# args: install material folder, jboss target folder, jboss user +add_postgresql_driver() +{ +if [[ $(grep "" $2/standalone/configuration/standalone.xml | wc -l) == 1 ]] ; then + echo "postgres driver already added to jboss" +else + echo "adding postgres driver to jboss" + sed -i '/<\/drivers>/c\\t\t\t\n\t\t' $2/standalone/configuration/standalone.xml +fi +if [ -f $1/postgresql-42.0.0.jar ] ; then + if [ ! -f $2/modules/org/postgresql/driver/main/postgresql-42.0.0.jar ] ; then + echo "copying postgres driver $1/postgresql-42.0.0.jar to $2/modules/org/postgresql/driver/main/postgresql-42.0.0.jar" + cp $1/postgresql-42.0.0.jar $2/modules/org/postgresql/driver/main/postgresql-42.0.0.jar + create_driver_xml $2 $3 + chown $3:$3 $2/modules/org/postgresql/driver/main/postgresql-42.0.0.jar + else + echo "Postres driver is already installed" + fi +else + echo "Postgres driver $1/postgresql-42.0.0.jar does not exists: installation failed" +fi +} + +# jboss target folder, jboss user +create_driver_xml() +{ +cat > $1/modules/org/postgresql/driver/main/module.xml < + + + + + + + + + +EOF +chown $2:$2 $1/modules/org/postgresql/driver/main/module.xml +} + + +runinstallation() +{ +install_packages +openport +checkhostfile $6 $5 +jbosszipexists $1 +createjbossuserandgroup $4 +createdirectory /etc/$3 $4 +unzipjboss $1 $2 $3 $4 +create_jboss_as_conf $2 $3 $4 +createdirectory /var/log/$3 $4 +createdirectory /var/run/$3 $4 +create_jboss_service $2 $3 $4 $7 +set_java_opts $2 +change_bind_address $2 +disable_webservices_subsystem_in_jboss $2 +disable_jsf_subsystem_in_jboss $2 +open_ajp_port $2 +createdirectory $2/modules/org $4 +createdirectory $2/modules/org/postgresql $4 +createdirectory $2/modules/org/postgresql/driver $4 +createdirectory $2/modules/org/postgresql/driver/main $4 +add_postgresql_driver $1 $2 $4 +} + +# +# MAIN +# + +if [[ $# != 7 ]] ; then + usage +else + runinstallation "$@" +fi diff --git a/jboss_for_alfresco/install_share_war.sh b/jboss_for_alfresco/install_share_war.sh new file mode 100644 index 0000000..4ee8318 --- /dev/null +++ b/jboss_for_alfresco/install_share_war.sh @@ -0,0 +1,108 @@ +usage() +{ + echo 'Usage:' + echo 'You must specify:' + echo ' 1, Install material folder' + echo ' 2, jboss target folder, e.q.: /usr/share/jboss-as' + echo ' 3, jboss user name' + exit 1 +} + +checkfiles() +{ +if [ ! -f $1/share-5.2.f.war ] ; then + echo "Missing $1/share-5.2.f.war: installation failed!" + exit 1 +fi +if [ ! -f $1/alfresco-mmt-5.2.g.jar ] ; then + echo "Missing $1/alfresco-mmt-5.2.g.jar: installation failed!" + exit 1 +fi + +echo "share.war and share amp and alfresco-mmt.jar are present" +} + +create_jboss_deployment_descriptor() +{ +if [ -f /tmp/share/WEB-INF/jboss-deployment-structure.xml ] ; then + echo "/tmp/share/WEB-INF/jboss-deployment-structure.xml already exists: doing nothing" +else + echo "Creating jboss-deployment-descriptor.xml" +cat > /tmp/share/WEB-INF/jboss-deployment-structure.xml < + + + + + + + +EOF +fi +} + +add_logging_profile() +{ +if [[ $(grep "Logging-Profile" /tmp/share/META-INF/MANIFEST.MF | wc -l) == 0 ]] ; then +echo "addig logging profile" +cp /tmp/share/META-INF/MANIFEST.MF /tmp/MANIFEST_ORIG.MF +sed -i -e 's/\r$//g' /tmp/share/META-INF/MANIFEST.MF +perl -i -p0e 's/shar\s+?e/share/s' /tmp/share/META-INF/MANIFEST.MF +all=$(cat /tmp/share/META-INF/MANIFEST.MF | wc -l) +head -n 18 /tmp/share/META-INF/MANIFEST.MF > /tmp/MANIFEST.MF +echo -e "Logging-Profile: share" >> /tmp/MANIFEST.MF +rest=$((all - 20)) +tail -n $rest /tmp/share/META-INF/MANIFEST.MF >> /tmp/MANIFEST.MF +cp /tmp/MANIFEST.MF /tmp/share/META-INF/MANIFEST.MF -f +cp /tmp/share/META-INF/MANIFEST.MF /tmp/MANIFEST_MODDED.MF +else +echo "logging profile already added" +fi +} + +unzipsharewar() +{ +if [ -d /tmp/share ] ; then + echo "/tmp/share already exists: doing nothing" +else + echo "Unzipping share.war" + mkdir /tmp/share + cp $1/share-5.2.f.war /tmp/share + cd /tmp/share + unzip -q share-5.2.f.war + rm -f share-5.2.f.war +fi +} + +zipsharewar() +{ +if [ -f /tmp/share.war ] ; then + echo "/tmp/share.war already created: doing nothing" +else + echo "creating share.war in /tmp" + cd /tmp/share + zip -q -r /tmp/share.war * +fi +} + +runinstallation() +{ + checkfiles $1 + unzipsharewar $1 + create_jboss_deployment_descriptor + add_logging_profile + zipsharewar + cp -f /tmp/share.war $2/standalone/deployments + chown $3:$3 $2/standalone/deployments/share.war +} + +# +# MAIN +# + +if [[ $# != 3 ]]; then + usage +else + runinstallation "$@" +fi + diff --git a/jboss_for_alfresco/share_war_logging.xml b/jboss_for_alfresco/share_war_logging.xml new file mode 100644 index 0000000..aef0fa2 --- /dev/null +++ b/jboss_for_alfresco/share_war_logging.xml @@ -0,0 +1,652 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/openldap/baseStructureTemplate.ldif b/openldap/baseStructureTemplate.ldif new file mode 100644 index 0000000..467f07e --- /dev/null +++ b/openldap/baseStructureTemplate.ldif @@ -0,0 +1,55 @@ +dn: $BASEDN +objectClass: dcObject +objectClass: organization +dc: myproject +o: myproject + + +dn: ou=Technical,$BASEDN +objectClass: top +objectClass: organizationalUnit +ou: Technical + +dn: uid=ldapbind,ou=Technical,$BASEDN +objectClass: posixAccount +objectClass: top +objectClass: inetOrgPerson +gidNumber: 0s +givenName: bind +sn: ldap +displayName: ldap bind +uid: ldapbind +homeDirectory: - +cn: ldap bind +uidNumber: 26088 +userPassword: $ENCPASSWD + +dn: ou=Normal,$BASEDN +objectClass: top +objectClass: organizationalUnit +ou: Normal + +dn: ou=Groups, ou=Normal,$BASEDN +objectClass: top +objectClass: organizationalUnit +ou: Groups + +dn: ou=Users,ou=Normal,$BASEDN +objectClass: top +objectClass: organizationalUnit +ou: Users + +dn: uid=admin,ou=Users,ou=Normal,$BASEDN +objectClass: posixAccount +objectClass: top +objectClass: inetOrgPerson +gidNumber: 0 +givenName: admin +sn: admin +displayName: admin +uid: admin +homeDirectory: - +cn: admin +uidNumber: 1 +userPassword: $ENCPASSWD + diff --git a/openldap/cn={0}core.ldif b/openldap/cn={0}core.ldif new file mode 100644 index 0000000..e6277db --- /dev/null +++ b/openldap/cn={0}core.ldif @@ -0,0 +1,249 @@ +# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify. +# CRC32 6f28213d +dn: cn={0}core +objectClass: olcSchemaConfig +cn: {0}core +olcAttributeTypes: {0}( 2.5.4.2 NAME 'knowledgeInformation' DESC 'RFC2256: k + nowledge information' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115. + 121.1.15{32768} ) +olcAttributeTypes: {1}( 2.5.4.4 NAME ( 'sn' 'surname' ) DESC 'RFC2256: last + (family) name(s) for which the entity is known by' SUP name ) +olcAttributeTypes: {2}( 2.5.4.5 NAME 'serialNumber' DESC 'RFC2256: serial nu + mber of the entity' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMat + ch SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{64} ) +olcAttributeTypes: {3}( 2.5.4.6 NAME ( 'c' 'countryName' ) DESC 'RFC4519: tw + o-letter ISO-3166 country code' SUP name SYNTAX 1.3.6.1.4.1.1466.115.121.1. + 11 SINGLE-VALUE ) +olcAttributeTypes: {4}( 2.5.4.7 NAME ( 'l' 'localityName' ) DESC 'RFC2256: l + ocality which this object resides in' SUP name ) +olcAttributeTypes: {5}( 2.5.4.8 NAME ( 'st' 'stateOrProvinceName' ) DESC 'RF + C2256: state or province which this object resides in' SUP name ) +olcAttributeTypes: {6}( 2.5.4.9 NAME ( 'street' 'streetAddress' ) DESC 'RFC2 + 256: street address of this object' EQUALITY caseIgnoreMatch SUBSTR caseIgn + oreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} ) +olcAttributeTypes: {7}( 2.5.4.10 NAME ( 'o' 'organizationName' ) DESC 'RFC22 + 56: organization this object belongs to' SUP name ) +olcAttributeTypes: {8}( 2.5.4.11 NAME ( 'ou' 'organizationalUnitName' ) DESC + 'RFC2256: organizational unit this object belongs to' SUP name ) +olcAttributeTypes: {9}( 2.5.4.12 NAME 'title' DESC 'RFC2256: title associate + d with the entity' SUP name ) +olcAttributeTypes: {10}( 2.5.4.14 NAME 'searchGuide' DESC 'RFC2256: search g + uide, deprecated by enhancedSearchGuide' SYNTAX 1.3.6.1.4.1.1466.115.121.1. + 25 ) +olcAttributeTypes: {11}( 2.5.4.15 NAME 'businessCategory' DESC 'RFC2256: bus + iness category' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch S + YNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} ) +olcAttributeTypes: {12}( 2.5.4.16 NAME 'postalAddress' DESC 'RFC2256: postal + address' EQUALITY caseIgnoreListMatch SUBSTR caseIgnoreListSubstringsMatch + SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 ) +olcAttributeTypes: {13}( 2.5.4.17 NAME 'postalCode' DESC 'RFC2256: postal co + de' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6. + 1.4.1.1466.115.121.1.15{40} ) +olcAttributeTypes: {14}( 2.5.4.18 NAME 'postOfficeBox' DESC 'RFC2256: Post O + ffice Box' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX + 1.3.6.1.4.1.1466.115.121.1.15{40} ) +olcAttributeTypes: {15}( 2.5.4.19 NAME 'physicalDeliveryOfficeName' DESC 'RF + C2256: Physical Delivery Office Name' EQUALITY caseIgnoreMatch SUBSTR caseI + gnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} ) +olcAttributeTypes: {16}( 2.5.4.20 NAME 'telephoneNumber' DESC 'RFC2256: Tele + phone Number' EQUALITY telephoneNumberMatch SUBSTR telephoneNumberSubstring + sMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.50{32} ) +olcAttributeTypes: {17}( 2.5.4.21 NAME 'telexNumber' DESC 'RFC2256: Telex Nu + mber' SYNTAX 1.3.6.1.4.1.1466.115.121.1.52 ) +olcAttributeTypes: {18}( 2.5.4.22 NAME 'teletexTerminalIdentifier' DESC 'RFC + 2256: Teletex Terminal Identifier' SYNTAX 1.3.6.1.4.1.1466.115.121.1.51 ) +olcAttributeTypes: {19}( 2.5.4.23 NAME ( 'facsimileTelephoneNumber' 'fax' ) + DESC 'RFC2256: Facsimile (Fax) Telephone Number' SYNTAX 1.3.6.1.4.1.1466.11 + 5.121.1.22 ) +olcAttributeTypes: {20}( 2.5.4.24 NAME 'x121Address' DESC 'RFC2256: X.121 Ad + dress' EQUALITY numericStringMatch SUBSTR numericStringSubstringsMatch SYNT + AX 1.3.6.1.4.1.1466.115.121.1.36{15} ) +olcAttributeTypes: {21}( 2.5.4.25 NAME 'internationaliSDNNumber' DESC 'RFC22 + 56: international ISDN number' EQUALITY numericStringMatch SUBSTR numericSt + ringSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.36{16} ) +olcAttributeTypes: {22}( 2.5.4.26 NAME 'registeredAddress' DESC 'RFC2256: re + gistered postal address' SUP postalAddress SYNTAX 1.3.6.1.4.1.1466.115.121. + 1.41 ) +olcAttributeTypes: {23}( 2.5.4.27 NAME 'destinationIndicator' DESC 'RFC2256: + destination indicator' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstring + sMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{128} ) +olcAttributeTypes: {24}( 2.5.4.28 NAME 'preferredDeliveryMethod' DESC 'RFC22 + 56: preferred delivery method' SYNTAX 1.3.6.1.4.1.1466.115.121.1.14 SINGLE- + VALUE ) +olcAttributeTypes: {25}( 2.5.4.29 NAME 'presentationAddress' DESC 'RFC2256: + presentation address' EQUALITY presentationAddressMatch SYNTAX 1.3.6.1.4.1. + 1466.115.121.1.43 SINGLE-VALUE ) +olcAttributeTypes: {26}( 2.5.4.30 NAME 'supportedApplicationContext' DESC 'R + FC2256: supported application context' EQUALITY objectIdentifierMatch SYNTA + X 1.3.6.1.4.1.1466.115.121.1.38 ) +olcAttributeTypes: {27}( 2.5.4.31 NAME 'member' DESC 'RFC2256: member of a g + roup' SUP distinguishedName ) +olcAttributeTypes: {28}( 2.5.4.32 NAME 'owner' DESC 'RFC2256: owner (of the + object)' SUP distinguishedName ) +olcAttributeTypes: {29}( 2.5.4.33 NAME 'roleOccupant' DESC 'RFC2256: occupan + t of role' SUP distinguishedName ) +olcAttributeTypes: {30}( 2.5.4.36 NAME 'userCertificate' DESC 'RFC2256: X.50 + 9 user certificate, use ;binary' EQUALITY certificateExactMatch SYNTAX 1.3. + 6.1.4.1.1466.115.121.1.8 ) +olcAttributeTypes: {31}( 2.5.4.37 NAME 'cACertificate' DESC 'RFC2256: X.509 + CA certificate, use ;binary' EQUALITY certificateExactMatch SYNTAX 1.3.6.1. + 4.1.1466.115.121.1.8 ) +olcAttributeTypes: {32}( 2.5.4.38 NAME 'authorityRevocationList' DESC 'RFC22 + 56: X.509 authority revocation list, use ;binary' SYNTAX 1.3.6.1.4.1.1466.1 + 15.121.1.9 ) +olcAttributeTypes: {33}( 2.5.4.39 NAME 'certificateRevocationList' DESC 'RFC + 2256: X.509 certificate revocation list, use ;binary' SYNTAX 1.3.6.1.4.1.14 + 66.115.121.1.9 ) +olcAttributeTypes: {34}( 2.5.4.40 NAME 'crossCertificatePair' DESC 'RFC2256: + X.509 cross certificate pair, use ;binary' SYNTAX 1.3.6.1.4.1.1466.115.121 + .1.10 ) +olcAttributeTypes: {35}( 2.5.4.42 NAME ( 'givenName' 'gn' ) DESC 'RFC2256: f + irst name(s) for which the entity is known by' SUP name ) +olcAttributeTypes: {36}( 2.5.4.43 NAME 'initials' DESC 'RFC2256: initials of + some or all of names, but not the surname(s).' SUP name ) +olcAttributeTypes: {37}( 2.5.4.44 NAME 'generationQualifier' DESC 'RFC2256: + name qualifier indicating a generation' SUP name ) +olcAttributeTypes: {38}( 2.5.4.45 NAME 'x500UniqueIdentifier' DESC 'RFC2256: + X.500 unique identifier' EQUALITY bitStringMatch SYNTAX 1.3.6.1.4.1.1466.1 + 15.121.1.6 ) +olcAttributeTypes: {39}( 2.5.4.46 NAME 'dnQualifier' DESC 'RFC2256: DN quali + fier' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR case + IgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.44 ) +olcAttributeTypes: {40}( 2.5.4.47 NAME 'enhancedSearchGuide' DESC 'RFC2256: + enhanced search guide' SYNTAX 1.3.6.1.4.1.1466.115.121.1.21 ) +olcAttributeTypes: {41}( 2.5.4.48 NAME 'protocolInformation' DESC 'RFC2256: + protocol information' EQUALITY protocolInformationMatch SYNTAX 1.3.6.1.4.1. + 1466.115.121.1.42 ) +olcAttributeTypes: {42}( 2.5.4.50 NAME 'uniqueMember' DESC 'RFC2256: unique + member of a group' EQUALITY uniqueMemberMatch SYNTAX 1.3.6.1.4.1.1466.115.1 + 21.1.34 ) +olcAttributeTypes: {43}( 2.5.4.51 NAME 'houseIdentifier' DESC 'RFC2256: hous + e identifier' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYN + TAX 1.3.6.1.4.1.1466.115.121.1.15{32768} ) +olcAttributeTypes: {44}( 2.5.4.52 NAME 'supportedAlgorithms' DESC 'RFC2256: + supported algorithms' SYNTAX 1.3.6.1.4.1.1466.115.121.1.49 ) +olcAttributeTypes: {45}( 2.5.4.53 NAME 'deltaRevocationList' DESC 'RFC2256: + delta revocation list; use ;binary' SYNTAX 1.3.6.1.4.1.1466.115.121.1.9 ) +olcAttributeTypes: {46}( 2.5.4.54 NAME 'dmdName' DESC 'RFC2256: name of DMD' + SUP name ) +olcAttributeTypes: {47}( 2.5.4.65 NAME 'pseudonym' DESC 'X.520(4th): pseudon + ym for the object' SUP name ) +olcAttributeTypes: {48}( 0.9.2342.19200300.100.1.3 NAME ( 'mail' 'rfc822Mail + box' ) DESC 'RFC1274: RFC822 Mailbox' EQUALITY caseIgnoreIA5Match SUBST + R caseIgnoreIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} + ) +olcAttributeTypes: {49}( 0.9.2342.19200300.100.1.25 NAME ( 'dc' 'domainCompo + nent' ) DESC 'RFC1274/2247: domain component' EQUALITY caseIgnoreIA5Match S + UBSTR caseIgnoreIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SIN + GLE-VALUE ) +olcAttributeTypes: {50}( 0.9.2342.19200300.100.1.37 NAME 'associatedDomain' + DESC 'RFC1274: domain associated with object' EQUALITY caseIgnoreIA5Match S + UBSTR caseIgnoreIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) +olcAttributeTypes: {51}( 1.2.840.113549.1.9.1 NAME ( 'email' 'emailAddress' + 'pkcs9email' ) DESC 'RFC3280: legacy attribute for email addresses in DNs' + EQUALITY caseIgnoreIA5Match SUBSTR caseIgnoreIA5SubstringsMatch SYNTAX 1.3. + 6.1.4.1.1466.115.121.1.26{128} ) +olcObjectClasses: {0}( 2.5.6.2 NAME 'country' DESC 'RFC2256: a country' SUP + top STRUCTURAL MUST c MAY ( searchGuide $ description ) ) +olcObjectClasses: {1}( 2.5.6.3 NAME 'locality' DESC 'RFC2256: a locality' SU + P top STRUCTURAL MAY ( street $ seeAlso $ searchGuide $ st $ l $ descriptio + n ) ) +olcObjectClasses: {2}( 2.5.6.4 NAME 'organization' DESC 'RFC2256: an organiz + ation' SUP top STRUCTURAL MUST o MAY ( userPassword $ searchGuide $ seeAlso + $ businessCategory $ x121Address $ registeredAddress $ destinationIndicato + r $ preferredDeliveryMethod $ telexNumber $ teletexTerminalIdentifier $ tel + ephoneNumber $ internationaliSDNNumber $ facsimileTelephoneNumber $ street + $ postOfficeBox $ postalCode $ postalAddress $ physicalDeliveryOfficeName + $ st $ l $ description ) ) +olcObjectClasses: {3}( 2.5.6.5 NAME 'organizationalUnit' DESC 'RFC2256: an o + rganizational unit' SUP top STRUCTURAL MUST ou MAY ( userPassword $ searchG + uide $ seeAlso $ businessCategory $ x121Address $ registeredAddress $ desti + nationIndicator $ preferredDeliveryMethod $ telexNumber $ teletexTerminalId + entifier $ telephoneNumber $ internationaliSDNNumber $ facsimileTelephoneNu + mber $ street $ postOfficeBox $ postalCode $ postalAddress $ physicalDelive + ryOfficeName $ st $ l $ description ) ) +olcObjectClasses: {4}( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' SUP to + p STRUCTURAL MUST ( sn $ cn ) MAY ( userPassword $ telephoneNumber $ seeAls + o $ description ) ) +olcObjectClasses: {5}( 2.5.6.7 NAME 'organizationalPerson' DESC 'RFC2256: an + organizational person' SUP person STRUCTURAL MAY ( title $ x121Address $ r + egisteredAddress $ destinationIndicator $ preferredDeliveryMethod $ telexNu + mber $ teletexTerminalIdentifier $ telephoneNumber $ internationaliSDNNumbe + r $ facsimileTelephoneNumber $ street $ postOfficeBox $ postalCode $ posta + lAddress $ physicalDeliveryOfficeName $ ou $ st $ l ) ) +olcObjectClasses: {6}( 2.5.6.8 NAME 'organizationalRole' DESC 'RFC2256: an o + rganizational role' SUP top STRUCTURAL MUST cn MAY ( x121Address $ register + edAddress $ destinationIndicator $ preferredDeliveryMethod $ telexNumber $ + teletexTerminalIdentifier $ telephoneNumber $ internationaliSDNNumber $ fac + simileTelephoneNumber $ seeAlso $ roleOccupant $ preferredDeliveryMethod $ + street $ postOfficeBox $ postalCode $ postalAddress $ physicalDeliveryOffic + eName $ ou $ st $ l $ description ) ) +olcObjectClasses: {7}( 2.5.6.9 NAME 'groupOfNames' DESC 'RFC2256: a group of + names (DNs)' SUP top STRUCTURAL MUST ( member $ cn ) MAY ( businessCategor + y $ seeAlso $ owner $ ou $ o $ description ) ) +olcObjectClasses: {8}( 2.5.6.10 NAME 'residentialPerson' DESC 'RFC2256: an r + esidential person' SUP person STRUCTURAL MUST l MAY ( businessCategory $ x1 + 21Address $ registeredAddress $ destinationIndicator $ preferredDeliveryMet + hod $ telexNumber $ teletexTerminalIdentifier $ telephoneNumber $ internati + onaliSDNNumber $ facsimileTelephoneNumber $ preferredDeliveryMethod $ stree + t $ postOfficeBox $ postalCode $ postalAddress $ physicalDeliveryOfficeName + $ st $ l ) ) +olcObjectClasses: {9}( 2.5.6.11 NAME 'applicationProcess' DESC 'RFC2256: an + application process' SUP top STRUCTURAL MUST cn MAY ( seeAlso $ ou $ l $ de + scription ) ) +olcObjectClasses: {10}( 2.5.6.12 NAME 'applicationEntity' DESC 'RFC2256: an + application entity' SUP top STRUCTURAL MUST ( presentationAddress $ cn ) MA + Y ( supportedApplicationContext $ seeAlso $ ou $ o $ l $ description ) ) +olcObjectClasses: {11}( 2.5.6.13 NAME 'dSA' DESC 'RFC2256: a directory syste + m agent (a server)' SUP applicationEntity STRUCTURAL MAY knowledgeInformati + on ) +olcObjectClasses: {12}( 2.5.6.14 NAME 'device' DESC 'RFC2256: a device' SUP + top STRUCTURAL MUST cn MAY ( serialNumber $ seeAlso $ owner $ ou $ o $ l $ + description ) ) +olcObjectClasses: {13}( 2.5.6.15 NAME 'strongAuthenticationUser' DESC 'RFC22 + 56: a strong authentication user' SUP top AUXILIARY MUST userCertificate ) +olcObjectClasses: {14}( 2.5.6.16 NAME 'certificationAuthority' DESC 'RFC2256 + : a certificate authority' SUP top AUXILIARY MUST ( authorityRevocationList + $ certificateRevocationList $ cACertificate ) MAY crossCertificatePair ) +olcObjectClasses: {15}( 2.5.6.17 NAME 'groupOfUniqueNames' DESC 'RFC2256: a + group of unique names (DN and Unique Identifier)' SUP top STRUCTURAL MUST ( + cn ) MAY ( uniqueMember $ businessCategory $ seeAlso $ owner $ ou $ o $ de + scription ) ) +olcObjectClasses: {16}( 2.5.6.18 NAME 'userSecurityInformation' DESC 'RFC225 + 6: a user security information' SUP top AUXILIARY MAY ( supportedAlgorithms + ) ) +olcObjectClasses: {17}( 2.5.6.16.2 NAME 'certificationAuthority-V2' SUP cert + ificationAuthority AUXILIARY MAY ( deltaRevocationList ) ) +olcObjectClasses: {18}( 2.5.6.19 NAME 'cRLDistributionPoint' SUP top STRUCTU + RAL MUST ( cn ) MAY ( certificateRevocationList $ authorityRevocationList $ + deltaRevocationList ) ) +olcObjectClasses: {19}( 2.5.6.20 NAME 'dmd' SUP top STRUCTURAL MUST ( dmdNam + e ) MAY ( userPassword $ searchGuide $ seeAlso $ businessCategory $ x121Add + ress $ registeredAddress $ destinationIndicator $ preferredDeliveryMethod $ + telexNumber $ teletexTerminalIdentifier $ telephoneNumber $ internationali + SDNNumber $ facsimileTelephoneNumber $ street $ postOfficeBox $ postalCode + $ postalAddress $ physicalDeliveryOfficeName $ st $ l $ description ) ) +olcObjectClasses: {20}( 2.5.6.21 NAME 'pkiUser' DESC 'RFC2587: a PKI user' S + UP top AUXILIARY MAY userCertificate ) +olcObjectClasses: {21}( 2.5.6.22 NAME 'pkiCA' DESC 'RFC2587: PKI certificate + authority' SUP top AUXILIARY MAY ( authorityRevocationList $ certificateRe + vocationList $ cACertificate $ crossCertificatePair ) ) +olcObjectClasses: {22}( 2.5.6.23 NAME 'deltaCRL' DESC 'RFC2587: PKI user' SU + P top AUXILIARY MAY deltaRevocationList ) +olcObjectClasses: {23}( 1.3.6.1.4.1.250.3.15 NAME 'labeledURIObject' DESC 'R + FC2079: object that contains the URI attribute type' MAY ( labeledURI ) SUP + top AUXILIARY ) +olcObjectClasses: {24}( 0.9.2342.19200300.100.4.19 NAME 'simpleSecurityObjec + t' DESC 'RFC1274: simple security object' SUP top AUXILIARY MUST userPasswo + rd ) +olcObjectClasses: {25}( 1.3.6.1.4.1.1466.344 NAME 'dcObject' DESC 'RFC2247: + domain component object' SUP top AUXILIARY MUST dc ) +olcObjectClasses: {26}( 1.3.6.1.1.3.1 NAME 'uidObject' DESC 'RFC2377: uid ob + ject' SUP top AUXILIARY MUST uid ) +structuralObjectClass: olcSchemaConfig +entryUUID: 70d0fb0a-68e1-1037-83b9-0f58524ea5fa +creatorsName: cn=config +createTimestamp: 20171128234146Z +entryCSN: 20171128234146.376029Z#000000#000#000000 +modifiersName: cn=config +modifyTimestamp: 20171128234146Z diff --git a/openldap/fixcrc.sh b/openldap/fixcrc.sh new file mode 100644 index 0000000..817be1a --- /dev/null +++ b/openldap/fixcrc.sh @@ -0,0 +1,14 @@ +if [[ $# != 1 ]] ; then + echo 'Usage: ' + echo 'You must specify: ' + echo ' 2, the ldif file to fix' + exit 1 +fi + +grep -v '^#' $1 > /tmp/cleaned.ldif +NEWCRC=$(sed 's/[&/\]/\\&/g' <<< $(crc32 /tmp/cleaned.ldif)) +echo "# AUO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify." > $1 +echo "# CRC32 $NEWCRC" >> $1 +cat /tmp/cleaned.ldif >> $1 +rm -f /tmp/cleaned.ldif + diff --git a/openldap/install_openldap.sh b/openldap/install_openldap.sh new file mode 100644 index 0000000..9fee94f --- /dev/null +++ b/openldap/install_openldap.sh @@ -0,0 +1,219 @@ +usage() +{ + echo 'OpenLDAP install script for CentOS 7.x' + echo '' + echo 'Run it as root. You must specify:' + echo 'Usage: ' + echo 'You must specify: ' + echo ' 1, the ldap password of ldap administrator and bind user!' + echo ' 2, the base dn' + echo ' 3, the ldap server hostname' + echo ' 4, the ldap server ip address' +} + +# expects two arguments: the hostname and the ip +checkhostfile() +{ +if [[ $(grep $2 /etc/hosts | wc -l) == 1 ]] ; then + echo "Hostfile OK: already contains $2" +else + echo "Writing hostfile" + echo "$2 $1" >> /etc/hosts +fi +} + +# checks if the specific package is installed or not +function isinstalled +{ + echo "Testing whether $1 is installed or not" + if yum list installed $1 >/dev/null 2>&1; then + true + else + false + fi +} + +# expects one arg: the database version +installpackages() +{ +if isinstalled openldap-servers ; then + echo 'OpenLDAP is already installed: do nothing' +else + echo 'Installing OpenLDAP' + yum -y install openldap compat-openldap openldap-clients openldap-servers openldap-servers-sql openldap-devel perl-Archive-Zip +fi +} + +# checks one port in firewalld +checkport() +{ +echo "Testing whether $1 port is open" +if [[ $(firewall-cmd --list-ports | grep -w $1 | wc -l) == 1 ]] ; then + echo "Port $1 is already opened" + true +else + false +fi +} + +# checks whether service is running +isservicerunning() +{ +if [[ $(systemctl is-active $1) == 'active' ]] ; then + echo "$1 is running" + true +else + echo "$1 is not running" + false +fi +} + +# checks a service is enabled or not +function isserviceenabled +{ + echo "Testing whether $1 service is enabled or not" + if systemctl is-active $1 >/dev/null 2>&1; then + echo "Service $1 is already enabled" + true + else + false + fi +} + +# open the default port if needed +openport() +{ + if ! ( isserviceenabled firewalld ) ; then + echo "Enabling firewall" + systemctl enable firewalld + else + echo "Firewall already enabled" + fi + + if ! ( isservicerunning firewalld ) ; then + echo "Starting firewall" + systemctl start firewalld + else + echo "Firewall is running" + fi + + if ! ( checkport 389 ) ; then + echo "Opening default postgres port (389)" + firewall-cmd --zone=public --add-port=389/tcp --permanent + firewall-cmd --reload + else + echo "Port 389 is already open" + fi +} + +# args: root/bind password, basedn +createschema() +{ + echo "modifying schema before the first start" + + cp /etc/openldap/slapd.d/cn\=config/cn\=schema/cn={0}core.ldif /etc/openldap/slapd.d/cn\=config/cn\=schema/cn={0}core.ldif.backup + cp cn={0}core.ldif /etc/openldap/slapd.d/cn\=config/cn\=schema + + # we have to correct the CRC in the file + + ./fixcrc.sh /etc/openldap/slapd.d/cn=config/cn=schema/cn={0}core.ldif + + cp /etc/openldap/slapd.d/cn\=config.ldif /etc/openldap/slapd.d/cn\=config.ldif.backup + echo "olcSizeLimit: -1" >> /etc/openldap/slapd.d/cn\=config.ldif + + # we have to correct the CRC in the file + + ./fixcrc.sh /etc/openldap/slapd.d/cn\=config.ldif + + cp /etc/openldap/slapd.d/cn\=config/olcDatabase={2}hdb.ldif /etc/openldap/slapd.d/cn\=config/olcDatabase={2}hdb.ldif.backup + sed -i -e 's/dc=my-domain,dc=com/'"$2"'/g' /etc/openldap/slapd.d/cn\=config/olcDatabase={2}hdb.ldif + + ENCPASSWD=$(sed 's/[&/\]/\\&/g' <<< $(slappasswd -s $1 -n)) + + echo "olcRootPW: $ENCPASSWD" >> /etc/openldap/slapd.d/cn\=config/olcDatabase={2}hdb.ldif + + # we have to correct the CRC in the file + + ./fixcrc.sh /etc/openldap/slapd.d/cn\=config/olcDatabase={2}hdb.ldif + + cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG + chown ldap:ldap /var/lib/ldap/DB_CONFIG +} + +enableandstart() +{ + if ! ( isserviceenabled slapd ) ; then + echo "Enabling firewall" + systemctl enable slapd + else + echo "Slapd already enabled" + fi + + if ! ( isservicerunning slapd ) ; then + echo "Starting slapd" + systemctl start slapd + else + echo "Slapd is running" + fi + +} + +addbuiltinschemas() +{ +echo "adding built-in used schemas" + +ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif +ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif +ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif +} + +#args: ldap admin password, basedn + +addbasestructure() +{ +echo "adding base structure" +cp baseStructureTemplate.ldif /tmp +sed -i -e 's/$BASEDN/'"$2"'/g' /tmp/baseStructureTemplate.ldif +sed -i -e 's/$ENCPASSWD/'"$ENCPASSWD"'/g' /tmp/baseStructureTemplate.ldif +ldapadd -H ldap://localhost -x -D "cn=Manager,$2" -f /tmp/baseStructureTemplate.ldif -w $1 +} + + +runinstallation() +{ + +# write hostfile if needed + +checkhostfile $3 $4 + +# installing packages + +installpackages + +# checking firewall and opening port + +openport + +createschema $1 $2 + +enableandstart + +addbuiltinschemas + +addbasestructure $1 $2 +} + +# +# MAIN +# + +if [[ $# != 4 ]] ; then + usage + exit 1 +else + if [ -x fixcrc.sh ] ; then + runinstallation "$@" + else + echo "fixcrc.sh not found or not executeable!" + fi +fi diff --git a/postgresql/install_postgres.sh b/postgresql/install_postgres.sh new file mode 100644 index 0000000..45317f0 --- /dev/null +++ b/postgresql/install_postgres.sh @@ -0,0 +1,329 @@ +usage() +{ + echo 'PostgreSQL install script for CentOS 7.x' + echo '' + echo 'Usage:' + echo 'Run it as root. You must specify:' + echo ' 1, Database version: latest|image (latest means the script will try to download the latest 9.6 from pg update site, image means the 9.2 will be installed from the image)' + echo ' 2, Database name' + echo ' 3, Database data root directory, for example /data/postgres - but the parent folder, in this case the /data must exist before run this command!' + echo ' 4, Postgres user password' + echo ' 5, All the other users password' + echo ' 6, the server hostname' + echo ' 7, the server ip address' + exit 1 +} + +checkselinux() +{ +if [[ $(grep "SELINUX=enforcing" /etc/sysconfig/selinux | wc -l) == 1 ]] ; then + echo "SELINUX is active! Tablespace creation requires a non-enforcing configuration, please check it! If you have to modify it, the host must be rebooted!" + false +else + true +fi +} + +# expects two arguments: the hostname and the ip +checkhostfile() +{ +if [[ $(grep $2 /etc/hosts | wc -l) == 1 ]] ; then + echo "Hostfile OK: already contains $2" +else + echo "Writing hostfile" + echo "$2 $1" >> /etc/hosts +fi +} + +# checks if the specific package is installed or not +function isinstalled +{ + echo "Testing whether $1 is installed or not" + if yum list installed $1 >/dev/null 2>&1; then + true + else + false + fi +} + +# expects one arg: the database version +installpackages() +{ +if isinstalled postgresql96-server ; then + echo 'PostgreSQL 9.6 is already installed: do nothing' +elif isinstalled postgresql-server ; then + echo 'PostgreSQL 9.2 is already installed: do nothing' +else + if [[ $1 == "latest" ]] ; then + yum -y install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm + yum install postgresql96-server -y + elif [[ $1 == "image" ]] ; then + echo 'PostgreSQL 9.2 will be installed' + yum install postgresql-server -y + else + echo 'Error: Only latest or image is supported as first argument for this script' + usage + fi +fi +} + +# checks one port in firewalld +checkport() +{ +echo "Testing whether $1 port is open" +if [[ $(firewall-cmd --list-ports | grep -w $1 | wc -l) == 1 ]] ; then + echo "Port $1 is already opened" + true +else + false +fi +} + +# checks whether service is running +isservicerunning() +{ +if [[ $(systemctl is-active $1) == 'active' ]] ; then + echo "$1 is running" + true +else + echo "$1 is not running" + false +fi +} + +# checks a service is enabled or not +# args: service name +function isserviceenabled +{ + echo "Testing whether $1 service is enabled or not" + if systemctl is-active $1 >/dev/null 2>&1; then + echo "Service $1 is already enabled" + true + else + false + fi +} + +# open the default port if needed +openport() +{ + if ! ( isserviceenabled firewalld ) ; then + echo "Enabling firewall" + systemctl enable firewalld + else + echo "Firewall already enabled" + fi + + if ! ( isservicerunning firewalld ) ; then + echo "Starting firewall" + systemctl start firewalld + else + echo "Firewall is running" + fi + + if ! ( checkport 5432 ) ; then + echo "Opening default postgres port (5432)" + firewall-cmd --zone=public --add-port=5432/tcp --permanent + firewall-cmd --reload + else + echo "Port 5432 is already open" + fi +} + +# directory existence check +createdirectory() +{ + if [ -d "$1" ] ; then + echo "$1 already exists, doing nothing with it" + else + echo "Creating $1" + mkdir $1 + chown -R postgres:postgres $1 + fi +} + +# args: version to install: latest|image + +initdatabase() +{ + if [[ $1 == "latest" ]] ; then + if [ ! -f /var/lib/pgsql/9.6/initdb.log ] ; then + echo "Initing database" + /usr/pgsql-9.6/bin/postgresql96-setup initdb + else + echo "Database already inited" + fi + fi + if [[ $1 == "image" ]] ; then + if [ ! -f /var/lib/pgsql/initdb.log ] ; then + echo "Initing database" + /usr/bin/postgresql-setup initdb + else + echo "Database already inited" + fi + fi +} + +# args: version to install: latest|image + +editpostgresqlconf() +{ +postgresqlfile=/var/lib/pgsql/data/postgresql.conf +if [[ "latest" == "$1" ]] ; then + postgresqlfile=/var/lib/pgsql/9.6/data/postgresql.conf +fi +if [[ $( grep "#listen_addresses" $postgresqlfile | wc -l ) == 1 ]] ; then +echo "Editing $postgresqlfile" +sed -i -e"s/^#listen_addresses =.*$/listen_addresses = '*'/" $postgresqlfile +sed -i -e"s/^#max_prepared_transactions =.*$/max_prepared_transactions = 200/" $postgresqlfile +else +echo "Already edited: $postgresqlfile: doing nothing" +fi +} + +# args: version to install: latest|image + +editpghbaconf() +{ +pghbafile=/var/lib/pgsql/data/pg_hba.conf +if [[ "latest" == "$1" ]] ; then + pghbafile=/var/lib/pgsql/9.6/data/pg_hba.conf +fi +if [[ $( grep "host all all 0.0.0.0/0 md5" $pghbafile | wc -l ) == 0 ]] ; then + echo "Editing $pghbafile" + echo "host all all 0.0.0.0/0 md5" >> $pghbafile +else + echo "Already edited: $pghbafile: doing nothing" +fi +} + +# args: version to install: latest|image + +startdatabase() +{ + pgservice=postgresql + if [[ "latest" == "$1" ]] ; then + pgservice=postgresql-9.6 + fi + if ! ( isservicerunning $pgservice ) ; then + systemctl start $pgservice + fi +} + +setpostgrespassword() +{ +su - postgres -c "psql -e -U postgres -d postgres -c \"alter user postgres with password '$1';\"" +} + +createdatabaseusingname() +{ +if [[ $( su - postgres -c "psql -U postgres -d postgres -l" | grep $1 | wc -l ) == 0 ]] ; then +echo "Database $1 not exists: create..." +su - postgres -c "psql -e -U postgres -d postgres -c \"create database $1 ENCODING 'UTF8' LC_COLLATE 'hu_HU.UTF8' LC_CTYPE='hu_HU.UTF8' template template0;\"" +else +echo "Database $1 has been already created" +fi +} + +# args: tablespace root folder ($datafolder/$databasename}, tablespace name, databasename + +createtablespace() +{ +if [[ $( su - postgres -c "echo \"\\db\" | psql $5" | grep $2 | wc -l ) == 0 ]] ; then +echo "Tablespace $2 not exists: create..." +su - postgres -c "psql $5 -e -U postgres -c \"create tablespace $2 location '$1/$2';\"" +else +echo "Tablespace $2 has been already created" +fi +} + +# args: pguser, pgpassword,tablespace name, hostname, databasename + +createuser() +{ +if [[ $( su - postgres -c "echo \"\\du\" | psql $5" | grep $1 | wc -l ) == 0 ]] ; then +echo "User $1 not exists: create..." +su - postgres -c "psql $5 -e -U postgres -c \"create user $1 with encrypted password '$2';\"" +su - postgres -c "psql $5 -e -U postgres -c \"create schema $1 authorization $1;\"" +su - postgres -c "psql $5 -e -U postgres -c \"grant create on tablespace $3 to $1;\"" +su - postgres -c "psql $5 -e -U postgres -c \"alter user $1 set default_tablespace to $3;\"" +su - postgres -c "export PGPASSWORD=$2;echo \"SET default_tablespace = $3;SET search_path = $1, pg_catalog;\" | psql $5 -e -U $1 -h $4" +else +echo "User $1 has been already created" +fi +} + +# args: pgpassword of activiti, hostname, databasename + +initactiviti() +{ +# by default when the schema is empty in PG the \d will return 'No relations found' in one row +if [[ $( su - postgres -c "export PGPASSWORD=$1;echo \"\\dt\" | psql $3 -U activiti -h $2" | wc -l ) == 1 ]] ; then +echo "Activiti schema is empty, needs to be initialized" +su - postgres -c "export PGPASSWORD=$1;echo \"SET search_path = activiti, pg_catalog;SET default_with_oids = false;\\i $(pwd)/activiti.postgres.create.engine.sql\" | psql $3 -U activiti -h $2" +su - postgres -c "export PGPASSWORD=$1;echo \"SET search_path = activiti, pg_catalog;SET default_with_oids = false;\\i $(pwd)/activiti.postgres.create.history.sql\" | psql $3 -U activiti -h $2" +su - postgres -c "export PGPASSWORD=$1;echo \"SET search_path = activiti, pg_catalog;SET default_with_oids = false;\\i $(pwd)/activiti.postgres.create.identity.sql\" | psql $3 -U activiti -h $2" +else +echo "Activiti schema is already loaded." +fi +} + +runinstallation() +{ + +# write hostfile if needed + +checkhostfile $6 $7 + +# installing packages + +installpackages $1 + +# checking firewall and opening port + +openport + +# initing database +initdatabase $1 + +# creating directories + +createdirectory $3 +createdirectory $3/$2 +createdirectory $3/$2/actspace + +# modifying confs + +editpostgresqlconf $1 +editpghbaconf $1 + +# start database + +startdatabase $1 + +# set postgres passwd + +setpostgrespassword $4 + +createdatabaseusingname $2 + +createtablespace $3/$2 actspace $2 + +createuser activiti $5 actspace $6 $2 + +# initialize the activiti database, you're gonna need to extract the necessary scripts from activiti engine jar +#initactiviti $5 $6 $2 +} + +# +# MAIN +# + +if [[ $# != 7 ]] ; then + usage +else + if (checkselinux) ; then + runinstallation "$@" + fi +fi +