Skip to content

Instantly share code, notes, and snippets.

; Disallow international with exceptions
exten => _9810800.,1,Goto(outbound-allroutes,${EXTEN},1) ; Toll free ok!
exten => _9810.,1,GotoIf($["${CALLERID(num)}" = "335"]?outbound-allroutes,${EXTEN},1) ; Allow 8-10
exten => _9810.,1,GotoIf($["${CALLERID(num)}" = "336"]?outbound-allroutes,${EXTEN},1) ; Allow 8-10
exten => _9810.,n,Playback(feature-not-avail-line) ; Disallow 8-10
exten => _9810.,n,Hangup()
exten => _900.,1,Playback(feature-not-avail-line) ; Disallow 00
exten => _900.,n,Hangup()
#!/bin/sh
#
MyBackup="mysql.backup.`date +%Y.%m.%d.at.%H.%M.%S`.tbz"
MyBackup2="etcdir.backup.`date +%Y.%m.%d.at.%H.%M.%S`.tbz"
MyBackup3="wwwdir.backup.`date +%Y.%m.%d.at.%H.%M.%S`.tbz"
MyBackup4="varlib.backup.`date +%Y.%m.%d.at.%H.%M.%S`.tbz"
rm -f /astdb/backups/backup.sql
/usr/bin/mysqldump -udump -pdump --skip-add-drop-table --single-transaction --all-databases > /astdb/backups/backup.sql
cd /astdb/backups/
tar cjf $MyBackup backup.sql
[ $# -eq 0 ] && { echo "Usage: $0 username"; exit 1; }
if [ -d "/opt/clientconfig/$1/" ]; then
echo "Already exists"
exit 1
fi
cd /opt/client-ca
source vars
KEY_EXPIRE=183
./build-key $1
mkdir "c:\program files\zabbix\"
copy zabbix_agentd.conf "c:\program files\zabbix\"
copy zabbix_agentd.exe "c:\program files\zabbix\"
"c:\program files\zabbix\zabbix_agentd.exe" --config "c:\program files\zabbix\zabbix_agentd.conf" --install
"c:\program files\zabbix\zabbix_agentd.exe" --config "c:\program files\zabbix\zabbix_agentd.conf" --start
netsh advfirewall firewall add rule name="Zabbix agent" dir=in action=allow program="c:\program files\zabbix\zabbix_agentd.exe" profile=domain enable=yes
netsh advfirewall firewall add rule name="Zabbix agent" dir=in action=allow program="c:\program files\zabbix\zabbix_agentd.exe" profile=private enable=yes
@varnav
varnav / slack_jenkins_build_trigger_proxy.php
Created July 18, 2016 15:46
Will receive web hook from slack and trigger build job at Jenkins
<?php
if (!($_REQUEST['token'] == '')) die('I`m afraid, Dave, I can`t do that.');
$jenkins_url = 'http://jenkins.local';
$job_name = str_replace($_REQUEST['trigger_word'].' ', '', $_REQUEST['text']);
$job_name = str_replace('/', '', $job_name); // Anti-injection
//$job_name = preg_replace('/[^A-Za-z0-9\-]/', '', $job_name); // Remove special chars
$url=$jenkins_url.'/job/'.$job_name.'/build';
@varnav
varnav / gist:20ecf935a2e109fe92ec98e14d2b4d49
Created August 26, 2016 11:03
Sipura/Linksys/Cisco SPA phones BLF line for FreePBX
To add BLF enter in Line Key -> Extended Function
fnc=blf+sd+cp;sub=123@$PROXY;ext=123@$PROXY
where 123 is number to watch.
No additional settings in recent FreePBX versions needed.
@varnav
varnav / update_service.cmd
Created August 29, 2016 09:38
CMD snipped for Jenkins to update windows service binaries remotely
cmdkey.exe /add:10.15.1.15 /user:MACHINE\jenkins /pass:changeme
robocopy Project\bin\Release \\MACHINE\tempshare /s /xo /fft /R:10 /xf *.config
psservice \\10.15.1.15 -accepteula stop Service
psexec \\10.15.1.15 -accepteula robocopy c:\tempshare c:\Service /s /xo /fft /R:10 /xf *.config
psservice \\10.15.1.15 -accepteula start Service
cmdkey.exe /delete:10.15.1.15
@varnav
varnav / graylog-client.yml
Last active November 14, 2016 12:27
Graylog client playbook for Ansible
# Redirect everything that goes to syslog to Graylog
---
- hosts: localhost
tasks:
- name: Configuring Graylog client
lineinfile: line="*.* @172.16.5.147:5140;RSYSLOG_SyslogProtocol23Format"
dest="/etc/rsyslog.d/graylog.conf"
create=yes
notify:
- restart rsyslog
@varnav
varnav / queryhhjobs.php
Last active December 22, 2016 16:07
Get amount of jobs with given salaries from hh.ru
#!/usr/bin/php
<?php
// Get amount of jobs with given salaries from hh.ru
// Add this to /etc/cron for every 2 hours check and record:
// 00 */2 * * * user /home/user/queryhhjobs.php >> /home/user/jobs.csv
// or use user-level crontab with "crontab -e"
function getjobcount($salary_from = -1)
@varnav
varnav / post_load.py
Created March 16, 2017 10:41
POST load testing
#!/usr/bin/python3
# POST load testing script
# Eugene Varnavsky 2017
# MIT License
from urllib.parse import urlencode
from urllib.request import Request, urlopen
import urllib
import _thread