Difference between pages "Res ldap.conf" and "OwnCloud"

From Wikislax
(Difference between pages)
Jump to: navigation, search
(Adding Asterisk users)
 
(Configure Caching and File Locking)
 
Line 1: Line 1:
 
{{RightTOC}}
 
{{RightTOC}}
  
== LDAP configuration ==
+
== What is OwnCloud ? ==
  
The [http://studioware.com/wikislax/index.php?title=OpenLDAP OpenLDAP] directory built earlier must be modified to include the asterisk schema, that can be copied from '''/usr/local/asterisk-x.y.z.t/contrib/scripts/asterisk.ldap-schema''' into '''/usr/local/etc/openldap/schema'''. The schema must then be included from '''/usr/local/etc/openldap/slapd.conf''':
+
[http://owncloud.com/ OwnCloud] is a file synchronization server. It affords keeping a hierarchy of files synchronized on different clients and operating systems.
  
#
+
The [https://doc.owncloud.com/server/10.15/admin_manual/installation/quick_guides/ubuntu_20_04.html/ Owncloud install doc] provided is for Ubuntu.
# See slapd.conf(5) for details on configuration options.
+
 
# This file should NOT be world readable.
+
It is adapted below for Slackware 15.0.
#
+
 
include        /usr/local/etc/openldap/schema/core.schema
+
== Installing OwnCloud ==
include        /usr/local/etc/openldap/schema/cosine.schema
+
 
include        /usr/local/etc/openldap/schema/inetorgperson.schema
+
OwnCloud is a PHP application. [https://owncloud.com/download-server download] tarball then untar and install.
'''include        /usr/local/etc/openldap/schema/asterisk.schema'''
 
. . .
 
  
A restart is required:
+
# tar -C /usr/local -xvf owncloud-complete-20240724.tar.bz2
 +
# chown -R apache:apache owncloud
 +
# cd /var/www/htdocs
 +
# ln -s /usr/local/owncloud owncloud
 +
# chown -R apache:apache owncloud
  
# /etc/rc.d/rc.slapd restart
+
== Creating the occ helper script ==
  
We need to define a structure in the OpenLDAP directory where to store the asterisk information. For example we can put our '''users''' and '''extentions''' under entries by the same name just below the root of the directory. This can be done with the following LDIF file that we add to the directory using the '''ldapadd''' command:
+
occ is an OwnCloud administration command.
  
  #OU users
+
  # FILE="/usr/local/bin/occ"
dn: ou=users,dc=studioware,dc=com
+
  # cat <<EOM >$FILE
  objectClass: top
+
  > #! /bin/bash
objectClass: organizationalUnit
+
  > cd /usr/local/owncloud
ou: users
+
  > sudo -E -u apache /usr/bin/php /usr/local/owncloud/occ "\$@"
  # OU extensions
+
  > EOM
  dn: ou=extensions,dc=studioware,dc=com
+
  # chmod u+x $FILE
  objectClass: top
 
objectClass: organizationalUnit
 
ou: extensions
 
   
 
  # '''ldapadd -x -D "cn=Manager,dc=studioware,dc=com" -W -f yourLDIFpath'''
 
  
* '''-x''' : affords using a simple authentication (as opposed to SASL tricky schemes)
+
== Creating the OwnCloud database ==
* '''-D''' : affords defining the user (here cn=Manager,dc=studioware,dc=com)
 
* '''-W''' : affords being prompted to enter the password
 
* '''-f''' : affords specifying the LDIF file name
 
  
== res_ldap.conf ==
+
OwnCloud can use a variety of databases. We will be using MySQL. The database can be created as follows :
  
The '''res_ldap.conf''' file affords detailing how to access the LDAP database and which schema variables to use. Let's start with the LDAP connection information, located in the '''[_general]''' context:
+
# mysql -u root -e \
 +
  "CREATE DATABASE IF NOT EXISTS owncloud; \
 +
  CREATE USER IF NOT EXISTS 'owncloud'@'localhost' IDENTIFIED BY 'password'; \
 +
  GRANT ALL PRIVILEGES ON *.* TO 'owncloud'@'localhost' WITH GRANT OPTION; \
 +
  FLUSH PRIVILEGES;"
 +
#
  
[_general]
+
It is also possible to create user owncloud@localhost and database from phpmyadmin.
;
 
; Specify one of either host and port OR url.  URL is preferred, as you can
 
; use more options.
 
host=localhost                       ; LDAP host
 
port=389
 
url=ldap://localhost
 
protocol=3                          ; Version of the LDAP protocol to use; default is 3.
 
basedn=dc=studioware,dc=com          ; Base DN
 
user=cn=Manager,dc=studioware,dc=com ; Bind DN
 
pass=mysecret                        ; Bind password
 
  
The other contexts, '''[extensions]''', '''[sip]''', and '''[IAX]''', afford defining the correspondance between the variable names in Asterisk (on the left) and the variable names in the LDAP schema (on the right). Here is an example for the '''[extensions]''' context:
+
== setting up the owncloud database ==
  
;
+
The admin user is the one who will manage the other users and OwnCloud from the OwnCloud web page.
; Extensions Table
 
;
 
[extensions]
 
;context  =  AstExtensionContext
 
;exten  =  AstExtensionExten
 
;priority = AstExtensionPriority
 
;app = AstExtensionApplication
 
;appdata = AstExtensionApplicationData
 
;additionalFilter=(objectClass=AstExtension)
 
context  =  AstContext
 
exten  =  AstExtension
 
priority = AstPriority
 
app = AstApplication
 
appdata = AstApplicationData
 
additionalFilter=(objectClass=AsteriskExtension)
 
  
For a full content example of the res_ldap.conf file please click [{{SERVER}}/wikislax/download/res_ldap.conf here]. But please note that some names in your particular situation might differ from the names listed in this file and you could have to fix it.
+
# occ maintenance:install \
 +
    --database "mysql" \
 +
    --database-name "owncloud" \
 +
    --database-user "owncloud" \
 +
    --database-pass "password" \
 +
    --data-dir "/var/www/htdocs/owncloud/data" \
 +
    --admin-user "admin" \
 +
    --admin-pass "admin"
 +
ownCloud was successfully installed
 +
#
  
== extconfig.conf ==
+
== Configure ownCloud’s Trusted Domains ==
  
The '''[settings]''' context of '''extconfig.conf''' affords defining in which subtrees Asterisk should get the '''users''' and '''extension''' entries:
+
# my_ip=$(hostname -I|cut -f1 -d ' ')
 +
# occ config:system:set trusted_domains 1 --value="$my_ip"
 +
System config value trusted_domains => 1 set to string x.y.z.t
 +
# occ config:system:set trusted_domains 2 --value="$HOSTNAME"
 +
System config value trusted_domains => 2 set to string your.domain.tld
 +
#
  
;
+
== Configure the cron jobs ==
; Static and realtime external configuration
 
; engine configuration
 
;
 
; See https://wiki.asterisk.org/wiki/display/AST/Realtime+Database+Configuration
 
; for basic table formatting information.
 
;
 
[settings]
 
 
'''sipusers => ldap,"ou=users,dc=studioware,dc=com",sip'''
 
'''sippeers => ldap,"ou=users,dc=studioware,dc=com",sip'''
 
'''extensions => ldap,"ou=extensions,dc=studioware,dc=com",extensions'''
 
. . .
 
  
== sip.conf ==
+
Set your background job mode to cron:
  
For OpenLDAP to properly work these options must be added to the '''[general]''' context of the '''sip.conf''' file:
+
# occ background:cron
 +
Set mode for background jobs to 'cron'
 +
#
  
[general]
+
== Configure the execution of the cron job to every 15 min and the cleanup of chunks every night at 2 am: ==
rtcachefriends=yes
 
callevents=yes
 
realm=studioware.com
 
. . .
 
  
* rtcachefriends=yes // affords putting in cache the user info (mandatory at it affords keeping in memory the IP address with which the user connected).
+
# echo "MIN HOUR DAY MONTH DAYOFWEEK COMMAND" \
* callevents=yes // affords raising information about a call
+
  >> /var/spool/cron/crontabs/apache
* realm=studioware.com // LDAP domain name
+
# echo "*/15  *  *  *  * /var/www/htdocs/owncloud/occ system:cron" \
 +
  >> /var/spool/cron/crontabs/apache
 +
# echo "0  2  * *  * /var/www/htdocs/owncloud/occ dav:cleanup-chunks" \
 +
  >> /var/spool/cron/crontabs/apache
 +
# chgrp apache /var/spool/cron/crontabs/apache
 +
#
  
== extensions.conf ==
+
== Configure ldap synchronization ==
  
The switch statement can be declared in one or more contexts to include the users or extensions LDAP records that have an '''AstAccountContext''' field matching the context name, for example:
+
Note : instructions copied from OwnCloud documentation and not used at the time of this writing
  
[internal]
+
If you need to sync your users from an LDAP or Active Directory Server, add this additional Cron job. Every 4 hours this cron job will sync LDAP users in ownCloud and disable the ones who are not available for ownCloud. Additionally, you get a log file in /var/log/ldap-sync/user-sync.log for debugging.
'''switch => Realtime/@'''
 
. . .
 
 
[freephonie]
 
. . .
 
'''switch => Realtime/@'''
 
. . .
 
  
<u>Note</u> : including the extensions LDAP records in several contexts is possible thanks to the fact the the '''AstAccountContext''' field is multivalued.
+
# echo "1 */6 * * * /var/www/owncloud/occ user:sync \
 +
  'OCA\User_LDAP\User_Proxy' -m disable -vvv >> \
 +
  /var/log/ldap-sync/user-sync.log 2>&1" \
 +
  | sudo -u www-data -g crontab tee -a \
 +
  /var/spool/cron/crontabs/www-data
 +
# mkdir -p /var/log/ldap-sync
 +
# touch /var/log/ldap-sync/user-sync.log
 +
# chown www-data. /var/log/ldap-sync/user-sync.log
  
== Making sure ==
+
== Configure Caching and File Locking ==
  
At this point Asterisk should be able to take the new configuration into account (with no user defined). Connect to the asterisk console, reload the modules and the configuration files and display the ldap status:
+
If using these features the required modules must be installed.
  
# '''asterisk -r'''
+
As the installation seems to be quite cryptic, we decided not to used them for now.
Asterisk 15.0.0, Copyright (C) 1999 - 2016, Digium, Inc. and others.
 
Created by Mark Spencer <markster@digium.com>
 
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
 
This is free software, with components licensed under the GNU General Public
 
License version 2 and other licenses; you are welcome to redistribute it under
 
certain conditions. Type 'core show license' for details.
 
=========================================================================
 
Connected to Asterisk 15.0.0 currently running on inner (pid = 2563)
 
inner*CLI> '''module reload'''
 
[Nov 28 21:29:09] NOTICE[2827]: sorcery.c:1407 sorcery_object_load: Type 'system' is not reloadable, maintaining previous values
 
[Nov 28 21:29:09] WARNING[2818]: res_phoneprov.c:1230 get_defaults: Unable to find a valid server address or name.
 
[Nov 28 21:29:09] NOTICE[2818]: chan_skinny.c:8445 config_load: Configuring skinny from skinny.conf
 
[Nov 28 21:29:09] NOTICE[2818]: cel_custom.c:95 load_config: No mappings found in cel_custom.conf. Not logging CEL to custom CSVs.
 
[Nov 28 21:29:09] NOTICE[2818]: app_queue.c:8999 reload_queue_rules: queuerules.conf has not changed since it was last loaded. Not taking any action.
 
inner*CLI> '''sip reload'''
 
inner*CLI> '''dialplan reload'''
 
Dialplan reloaded.
 
inner*CLI> '''realtime show ldap status'''
 
Connected to 'ldap://localhost', baseDN dc=studioware,dc=com with username cn=Manager,dc=studioware,dc=com for 40 seconds
 
inner*CLI> quit
 
Asterisk cleanly ending (0).
 
Executing last minute cleanups
 
root@inner:/usr/local/etc/asterisk#
 
  
== Adding Asterisk users ==
+
# occ config:system:set memcache.local --value '\OC\Memcache\APCu'
 +
System config value memcache.local set to string \OC\Memcache\APCu
 +
# occ config:system:set memcache.locking --value '\OC\Memcache\Redis'
 +
System config value memcache.locking set to string \OC\Memcache\Redis
 +
# occ config:system:set redis --value '{"host": "127.0.0.1", "port": "6379"}' --type json
 +
System config value redis set to json {"host": "127.0.0.1", "port": "6379"}
 +
#
  
A small [{{SERVER}}/wikislax/download/cu.sh script] will afford adding users to the '''users''' and '''extensions''' subtrees of the directory. In this script we create users in context '''[internal]''' and extensions in contexts '''[internal]''' and '''[freephonie]''', creating two values in multivalued field '''AstAccountContext'''. Once the user created in LDAP,  SIP registration can be checked on the display of the phone and on the Asterisk console:
+
== Configure Log Rotation ==
  
  root@inner:/usr/local/etc/asterisk# '''asterisk -r'''
+
  # FILE="/etc/logrotate.d/owncloud"
Asterisk 15.0.0, Copyright (C) 1999 - 2016, Digium, Inc. and others.
+
  # cat <<EOM >$FILE
  Created by Mark Spencer <markster@digium.com>
+
  /var/www/htdocs/owncloud/data/owncloud.log {
  Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
+
  size 10M
  This is free software, with components licensed under the GNU General Public
+
  rotate 12
  License version 2 and other licenses; you are welcome to redistribute it under
+
  copytruncate
  certain conditions. Type 'core show license' for details.
+
  missingok
  =========================================================================
+
  compress
  Connected to Asterisk 15.0.0 currently running on inner (pid = 2563)
+
  compresscmd /bin/gzip
  [Nov 28 21:39:46] NOTICE[2678]: chan_sip.c:24648 handle_response_peerpoke: Peer 'jp' is now Reachable. (9ms / 2000ms)
+
  }
  inner*CLI> '''quit'''
+
  EOM
  Asterisk cleanly ending (0).
+
  #
  Executing last minute cleanups
 
root@inner:/usr/local/etc/asterisk#
 
  
<br/>
+
<br clear=all>
  
{{pFoot|[[Sip.conf]]|[[Main Page]]|[[Confbridge.conf]]}}
+
{{pFoot|[[Asterisk]]|[[Main Page]]|[[Desktop software]]}}

Revision as of 16:42, 19 January 2025

What is OwnCloud ?

OwnCloud is a file synchronization server. It affords keeping a hierarchy of files synchronized on different clients and operating systems.

The Owncloud install doc provided is for Ubuntu.

It is adapted below for Slackware 15.0.

Installing OwnCloud

OwnCloud is a PHP application. download tarball then untar and install.

# tar -C /usr/local -xvf owncloud-complete-20240724.tar.bz2
# chown -R apache:apache owncloud
# cd /var/www/htdocs
# ln -s /usr/local/owncloud owncloud
# chown -R apache:apache owncloud

Creating the occ helper script

occ is an OwnCloud administration command.

# FILE="/usr/local/bin/occ"
# cat <<EOM >$FILE
> #! /bin/bash
> cd /usr/local/owncloud
> sudo -E -u apache /usr/bin/php /usr/local/owncloud/occ "\$@"
> EOM
# chmod u+x $FILE

Creating the OwnCloud database

OwnCloud can use a variety of databases. We will be using MySQL. The database can be created as follows :

# mysql -u root -e \
  "CREATE DATABASE IF NOT EXISTS owncloud; \
  CREATE USER IF NOT EXISTS 'owncloud'@'localhost' IDENTIFIED BY 'password'; \
  GRANT ALL PRIVILEGES ON *.* TO 'owncloud'@'localhost' WITH GRANT OPTION; \
  FLUSH PRIVILEGES;"
#

It is also possible to create user owncloud@localhost and database from phpmyadmin.

setting up the owncloud database

The admin user is the one who will manage the other users and OwnCloud from the OwnCloud web page.

# occ maintenance:install \
    --database "mysql" \
    --database-name "owncloud" \
    --database-user "owncloud" \
    --database-pass "password" \
    --data-dir "/var/www/htdocs/owncloud/data" \
    --admin-user "admin" \
    --admin-pass "admin"
ownCloud was successfully installed
#

Configure ownCloud’s Trusted Domains

# my_ip=$(hostname -I|cut -f1 -d ' ')
# occ config:system:set trusted_domains 1 --value="$my_ip"
System config value trusted_domains => 1 set to string x.y.z.t
# occ config:system:set trusted_domains 2 --value="$HOSTNAME"
System config value trusted_domains => 2 set to string your.domain.tld
#

Configure the cron jobs

Set your background job mode to cron:

# occ background:cron
Set mode for background jobs to 'cron'
#

Configure the execution of the cron job to every 15 min and the cleanup of chunks every night at 2 am:

# echo "MIN HOUR DAY MONTH DAYOFWEEK COMMAND" \
  >> /var/spool/cron/crontabs/apache
# echo "*/15  *  *  *  * /var/www/htdocs/owncloud/occ system:cron" \
  >> /var/spool/cron/crontabs/apache
# echo "0  2  *  *  * /var/www/htdocs/owncloud/occ dav:cleanup-chunks" \
  >> /var/spool/cron/crontabs/apache
# chgrp apache /var/spool/cron/crontabs/apache
#

Configure ldap synchronization

Note : instructions copied from OwnCloud documentation and not used at the time of this writing

If you need to sync your users from an LDAP or Active Directory Server, add this additional Cron job. Every 4 hours this cron job will sync LDAP users in ownCloud and disable the ones who are not available for ownCloud. Additionally, you get a log file in /var/log/ldap-sync/user-sync.log for debugging.

# echo "1 */6 * * * /var/www/owncloud/occ user:sync \
 'OCA\User_LDAP\User_Proxy' -m disable -vvv >> \
 /var/log/ldap-sync/user-sync.log 2>&1" \
 | sudo -u www-data -g crontab tee -a \
 /var/spool/cron/crontabs/www-data
# mkdir -p /var/log/ldap-sync
# touch /var/log/ldap-sync/user-sync.log
# chown www-data. /var/log/ldap-sync/user-sync.log

Configure Caching and File Locking

If using these features the required modules must be installed.

As the installation seems to be quite cryptic, we decided not to used them for now.

# occ config:system:set memcache.local --value '\OC\Memcache\APCu'
System config value memcache.local set to string \OC\Memcache\APCu
# occ config:system:set memcache.locking --value '\OC\Memcache\Redis'
System config value memcache.locking set to string \OC\Memcache\Redis
# occ config:system:set redis --value '{"host": "127.0.0.1", "port": "6379"}' --type json
System config value redis set to json {"host": "127.0.0.1", "port": "6379"}
#

Configure Log Rotation

# FILE="/etc/logrotate.d/owncloud"
# cat <<EOM >$FILE
/var/www/htdocs/owncloud/data/owncloud.log {
size 10M
rotate 12
copytruncate
missingok
compress
compresscmd /bin/gzip
}
EOM
#


Asterisk Main Page Desktop software