script and new cron method

This commit is contained in:
2026-05-19 12:04:00 -05:00
parent 5768f75f29
commit 3f3220cdce
3 changed files with 45 additions and 19 deletions
Executable
+26
View File
@@ -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
+8
View File
@@ -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
+11 -19
View File
@@ -1,11 +1,21 @@
## 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.
<br>
## 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.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`.
<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
#### 1. Pull Contact List