NextCloud – Purge Music Library from DB

I recently posted an old bash script I had written to forcefully rescan the music library for the music app in NextCloud when new files aren’t being found, but what happens when you delete or make some changes to the MP3’s or file structure of your music library, then you go to run the rescan library occ script, and NextCloud proceeds to go ape shit, spewing a whole lot of errors in RED, and you can’t do anything? What now, home slice?

Welp, after some research, I found the easiest fix was just to dump the corresponding “oc_music_tracks” table from the database and start fresh. So again, it’s script writin’ time, boyz and girlz!

Continue reading “NextCloud – Purge Music Library from DB”

NextCloud – Rescan Music Library for All Users

NextCloud is a kick-ass piece of open-source software for personal cloud file sharing, backing up cell phones, email, and other forms of data, syncing contact lists, online collaboration, communication, and a variety of other use cases, but over the last few years, I’ve come across a few pitfalls and annoyances that required manual interventions. In doing so, I’ve lost quite a few man-hours of my pitiful existence on this planet scouring forums and GitHub posts, so let my loss be your gain.

Continue reading “NextCloud – Rescan Music Library for All Users”

Bash Script – Move Files into Subdirectories Based on Modified Date – OR – Moving Ntop Netflow Dumps into Subdirectories by Date

In a busy network environment, it is critical to have some form of network monitoring on all your servers and equipment. Network monitoring comes in many different forms and flavors, whether it be to monitor critical system services and applications via SNMP, WMI, or some proprietary third party software, or just generically pinging some devices to make sure they are up.

Nowadays, it is getting more and more necessary to dig deeper to be able to track what end users are doing and what websites they are visiting and this is where the Cisco Netflow comes in handy. Essentially, netflow allows us to peer down into the network traffic streams and give us vital source, destination, and protocol information coming to and from our network hosts but isn’t quite as storage intensive as doing a full fledged pcap dump, which makes historical accounting of this data a whole lot nicer.
Continue reading “Bash Script – Move Files into Subdirectories Based on Modified Date – OR – Moving Ntop Netflow Dumps into Subdirectories by Date”

Asterisk – How to Host a PRI Circuit with a Sangoma Card

These are just a few quick notes of mine on how to host a PRI circuit from a Sangoma card in an Asterisk server to another Asterisk server or wherever for that matter.

This config here is for a Sangoma A102 with two ports and Asterisk will provide the clocking source. Channels 1-23 will be the B channels and channel 24 will be the D channel for signaling. Echo cancelling will be enabled as well.
/etc/dahdi/system.conf

#autogenerated by /usr/sbin/wancfg_dahdi do not hand edit
#autogenrated on 2015-08-28
#Dahdi Channels Configurations
#For detailed Dahdi options, view /etc/dahdi/system.conf.bak
loadzone=us
defaultzone=us

#Sangoma A102 port 1 [slot:4 bus:6 span:1] 
span=1,0,0,esf,b8zs
bchan=1-23
echocanceller=mg2,1-23
hardhdlc=24

#Sangoma A102 port 2 [slot:4 bus:6 span:2] 
span=2,2,0,esf,b8zs
bchan=25-47
echocanceller=mg2,25-47
hardhdlc=48

Continue reading “Asterisk – How to Host a PRI Circuit with a Sangoma Card”

PHP – Simple PDO Class for Connecting to a MySQL Database

Here’s an extremely basic, reusable PHP and MySQL based PDO class for easily connecting to multiple database servers simultaneously within a script without having to go through a bunch of hoopla. Tidbits have been pieced together from the following sources with a little tweaking of my own (such as the ability to have default database values or to pass them as arguments):
http://simple_pdo_implementation.onlinephpfunctions.com/
http://culttt.com/2012/10/01/roll-your-own-pdo-php-class/
http://code.tutsplus.com/tutorials/why-you-should-be-using-phps-pdo-for-database-access–net-12059
Continue reading “PHP – Simple PDO Class for Connecting to a MySQL Database”

OpenMCU-ru – DSCP Based QoS Packet Tagging Rules for Linux IP Tables

In Ubuntu, the best way to ensure that the firewall is up and running and that your packet filtering or mangling rules are in place any time the network connection comes up, you should create a rule in the /etc/network/if-up.d folder. An alternative approach to that would be to put a “post-up” rule on whatever interface in you /etc/network/interfaces file. From my experience, so that your firewall rules can be easily maintained as well having the ability to make comments for each rule, it’s ideal to take advantage of the iptables-save and iptables-restore functionality.

In order to follow this procedure, the first time you set up the firewall, you will have to manually add all the firewall rules and then issue the iptables-save command. For sake of saving time, I will just provide you with the contents of my config file that can be restored with the iptables-restore < config_file command. Continue reading “OpenMCU-ru – DSCP Based QoS Packet Tagging Rules for Linux IP Tables”

MySQL Script – Alter/Convert All Tables in a Database from MyISAM to InnoDB

Pieced together from various tutorials on the web with a lot of my own additions, here is a snippet of SQL that will alter or convert all tables in a database from “MyISAM” to “InnoDB”. As long as your MySQL user account has privileges to create stored procedures, all you have to do is simply edit the @DATABASE_NAME variable at the top of the script and run it in PhpMyAdmin if you’ve got it. Enjoy! Continue reading “MySQL Script – Alter/Convert All Tables in a Database from MyISAM to InnoDB”

Bash Script – Log Concurrent Asterisk Calls to MySQL and Other Useful One-Liners

Here is a quick and dirty bash script I threw together today to log the concurrent calls for each of my long distance trunks in Asterisk to a MySQL database to be able to quickly analyze usage trends. Sure there is probably other open-source software out there that can do this and give pretty little graphs and what not (cdr-stats or maybe queue metrics come to mind), but where’s the fun in that? As I mentioned, the script is extremely primitive (just the bare minimum as I didn’t have much time to spend on it) and contains no error checking whatsoever but it could also be used as a pretty handy one-liner in bash.

Show all active SIP Calls on a single trunk

asterisk -x "core show channels verbose" | grep "^SIP/yourSIPTrunkName-"

Show concurrent number of SIP Calls on a single trunk

asterisk -x "core show channels verbose" | grep -c "^SIP/yourSIPTrunkName-"

Show all active DAHDI calls on channels 1-24
Continue reading “Bash Script – Log Concurrent Asterisk Calls to MySQL and Other Useful One-Liners”

Bash Script – An Alternative to Logrotate.d for Asterisk Log Files

For the longest time, I was having trouble getting the log rotate daemon to work properly with Asterisk. I tried using both postrotate and prerotate options on Ubuntu Server and no matter what, I always ended up with dozens or even hundreds of files if I wasn’t keeping a close eye on them. I never figured out why or wanted to spend a ton of time searching for answers but for some reason, the numbering on the log files would always get messed up and it would start adding extra periods on the end of the filenames and everything would get all out of whack.
Continue reading “Bash Script – An Alternative to Logrotate.d for Asterisk Log Files”