script and new cron method
This commit is contained in:
Executable
+26
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
RED='\e[31m'
|
||||||
|
GREEN='\e[32m'
|
||||||
|
YELLOW='\e[33m'
|
||||||
|
RESET='\e[0m'
|
||||||
|
|
||||||
|
# root check
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo -e "${RED}You must be root to do this." 1>&2
|
||||||
|
exit 100
|
||||||
|
fi
|
||||||
|
|
||||||
|
git pull
|
||||||
|
|
||||||
|
cp ./pc-script.cron /etc/cron.d/pc-script
|
||||||
|
chmod 644 /etc/cron.d/pc-script
|
||||||
|
|
||||||
|
touch /var/log/directory.log /var/log/sidecar.log
|
||||||
|
chown asterisk:asterisk /var/log/directory.log /var/log/sidecar.log
|
||||||
|
|
||||||
|
mkdir /var/lib/asterisk/PC-Contact-Sync
|
||||||
|
cp ./sidecar.php ./directory.php ./example-config.json /var/lib/asterisk/PC-Contact-Sync
|
||||||
|
|
||||||
|
chown asterisk:asterisk /var/lib/asterisk/PC-Contact-Sync -R
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
DIR=/var/lib/asterisk/PC-Contact-Sync
|
||||||
|
|
||||||
|
# Run Polycom directory sync every 4 hours at :00
|
||||||
|
0 */4 * * * asterisk cd $DIR && /usr/bin/php /var/lib/asterisk/PC-Contact-Sync/directory.php --notify >> /var/log/directory.log 2>&1
|
||||||
|
|
||||||
|
# Run PC sidecar sync every 4 hours at :05 (5 mins after)
|
||||||
|
5 */4 * * * asterisk $DIR && /usr/bin/php /var/lib/asterisk/PC-Contact-Sync/sidecar.php >> /var/log/sidecar.log 2>&1
|
||||||
|
|
||||||
@@ -1,11 +1,21 @@
|
|||||||
## Gen PC Sidecar Script
|
## Gen PC Sidecar Script
|
||||||
The files are stored typically inside of `/var/lib/asterisk/PC-Contact-Sync` and the scripts should be run every 6 hours by a cron job.
|
The files are stored typically inside of `/var/lib/asterisk/PC-Contact-Sync` and the scripts should be run every 6 hours or so by a cron job.
|
||||||
|
|
||||||
Make sure that all files are owned by asterisk user including the output files and the cronjob.
|
Make sure that all files are owned by asterisk user including the output files and the cronjob.
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## Quickstart
|
## Quickstart
|
||||||
|
#### Install
|
||||||
|
Download this repo
|
||||||
|
```
|
||||||
|
git clone https://git.archfox.org/poslop/PC-Contact-Sync
|
||||||
|
```
|
||||||
|
Run the install script as Root
|
||||||
|
```
|
||||||
|
./install.sh
|
||||||
|
```
|
||||||
|
|
||||||
#### Config Fields
|
#### Config Fields
|
||||||
`config.json` has several fields. The config file needs to be next to the script in order to be read.
|
`config.json` has several fields. The config file needs to be next to the script in order to be read.
|
||||||
|
|
||||||
@@ -34,24 +44,6 @@ prepend_extensions
|
|||||||
5. Add extra contacts you want added to the phones in `prepend_extensions`.
|
5. Add extra contacts you want added to the phones in `prepend_extensions`.
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
#### Cronjob Example
|
|
||||||
Create the cronjob as asterisk user.
|
|
||||||
|
|
||||||
```
|
|
||||||
EDITOR=vim crontab -e -u asterisk
|
|
||||||
```
|
|
||||||
|
|
||||||
Append this to the crontab
|
|
||||||
|
|
||||||
```
|
|
||||||
# Run Polycom directory sync every 4 hours at :00
|
|
||||||
0 */4 * * * /usr/bin/php /var/lib/asterisk/PC-Contact-Sync/directory.php --notify >> /var/log/directory.log 2>&1
|
|
||||||
|
|
||||||
# Run PC sidecar sync every 4 hours at :05 (5 mins after)
|
|
||||||
5 */4 * * * /usr/bin/php /var/lib/asterisk/PC-Contact-Sync/sidecar.php >> /var/log/sidecar.log 2>&1
|
|
||||||
```
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## Process Walkthrough
|
## Process Walkthrough
|
||||||
|
|
||||||
#### 1. Pull Contact List
|
#### 1. Pull Contact List
|
||||||
|
|||||||
Reference in New Issue
Block a user