#!/bin/sh : ${davical_username:='s-davical'} : ${davical_dbname:='davical'} : ${davical_dbhost:="$postgres_host"} : ${davical_admin_email:="$root_mail_alias"} : ${davical_access_role:='dav-access'} : ${davical_repo:='https://gitlab.com/davical-project/davical.git'} : ${davical_branch:='master'} : ${davical_awl_repo:='https://gitlab.com/davical-project/awl.git'} : ${davical_awl_branch:='master'} : ${davical_admins:=''} davical_dn="uid=${davical_username},${robots_basedn}" davical_repo_dir=/usr/local/www/davical davical_awl_repo_dir=/usr/local/share/awl davical_webroot="${davical_repo_dir}/htdocs" davical_https_cert="${nginx_conf_dir}/davical.crt" davical_https_key="${nginx_conf_dir}/davical.key" davical_https_cacert="${nginx_conf_dir}/davical.ca.crt" davical_keytab="${keytab_dir}/davical.keytab" davical_client_keytab="${keytab_dir}/davical.client.keytab" davical_fpm_socket=/var/run/fpm-davical.sock davical_psql(){ postgres_run --host="$davical_dbhost" --dbname="$davical_dbname" "$@" } # Install required packages. pkg install -y \ git-lite \ nginx \ php${php_version} \ php${php_version}-calendar \ php${php_version}-curl \ php${php_version}-gettext \ php${php_version}-iconv \ php${php_version}-ldap \ php${php_version}-opcache \ php${php_version}-pdo_pgsql \ php${php_version}-pgsql \ php${php_version}-session \ php${php_version}-xml \ p5-DBD-Pg \ p5-DBI \ p5-YAML # Install davical from git. [ -d "$davical_repo_dir" ] || git clone "$davical_repo" "$davical_repo_dir" [ -d "$davical_awl_repo_dir" ] || git clone "$davical_awl_repo" "$davical_awl_repo_dir" # Update git repos. git -C "$davical_repo_dir" pull --ff-only git -C "$davical_repo_dir" switch "$davical_branch" git -C "$davical_awl_repo_dir" pull --ff-only git -C "$davical_awl_repo_dir" switch "$davical_awl_branch" # Create davical principal and keytab. ldap_add "$davical_dn" < /usr/local/etc/php-fpm.d/www.conf # Enable and start daemons. sysrc -v \ nginx_enable=YES \ php_fpm_enable=YES service nginx restart service php_fpm restart # Sync groups from LDAP. su -m "$nginx_user" -c "${davical_repo_dir}/scripts/cron-sync-ldap.php ${fqdn}" # Create cron job for keeping LDAP groups up-to-date. install_template -m 0644 /etc/cron.d/davical # Create access role. ldap_add "cn=${davical_access_role},${roles_basedn}" <