Most Popular: Programming

Bash Script – OpenMCU-ru Service Monitor -OR- Monitor and Automatically Restart a Service Upon Failure

I threw this service monitoring script together because occasionally the OpenMCU-ru process in the developmental versions can crash out on my Ubuntu Server from time to time, so I wanted it to auto-restart. The script could easily be modified and used for any other service you like, but it was written specifically for OpenMCU-ru and Debian based operating systems.

There are two pieces to this puzzle (which makes for an awfully pathetic and simplistic puzzle), the “/etc/init.d/mcu-monitor” startup script to run the monitoring script as a daemon and the “/usr/local/bin/mcu-monitor.sh” monitoring script itself, both are fairly simple and straight forward. Continue reading “Bash Script – OpenMCU-ru Service Monitor -OR- Monitor and Automatically Restart a Service Upon Failure”

Batch Script – RDS Start Menu Application and Taskbar Shortcut Removal Tool

Customizing or locking down a new server for Remote Desktop Services in a Server 2012 environment can be quite a time consuming and daunting task. Countless hours will be spent setting up Group Policies, testing them, and deploying them. But far worse than that, you will waste massive amounts of time researching for jacked up ways to do simple things, such as unpinning items from the Taskbar and customizing the Start Screen.

In the past, I had already configured a company wide Group Policy for our old 2003 Terminal Server environment and it was simple and easy. No guesswork, no crazy workarounds, shit just worked. The Group Policies covered almost every scenario or task needed to lock down a server but unfortunately, that is not the case any more.

It seems Microsoft has made the process of doing pretty much anything ridiculous and overcomplicated. As a side rant, we (the world) desperetely need a good open source solution for a thin client type environment with something that mimicks Group Policy. I know I’m not the only person out there that would love to give Microsoft the old stink finger once and for all! I for one am tired of sitting and watching companies succumb to the endless money pit that is Microsoft licensing. Where you at Linux Devs?

Anyhow, I decided to write this script for a lot of shortcomings I’ve encountered along the way. One of which that I want to gripe about is that resorting to changing file permissions to remove shortcuts is just plain fucking retarded and redirecting all of the user’s start menus to a network share seemed like massive overkill to an already complicated scenario. On top of that, I had 6 separate Remote Desktop servers to fully setup and configure so I needed to streamline the process a bit. Suprisingly enough, my solution relies solely on batch scripting (and a little makeshift VB).

Enough chit chat, the script is extremely well documented so here are the highlights/features:

  • Removal of the Server Manager and PowerShell links in the Taskbar
  • Ability to backup the All User’s and Default User’s Programs directories to a zip file
  • Ability to copy the All Programs Start Menu shortcuts to a list of administrator or power user profile directories
  • Customized list of applications to remove from the Classic Shell Start Menu or the Windows Start Screen
  • Deleted Start Menu Program entries go into the active user’s Recycle Bin and can be restored if necessary
  • Remove System Tools, Accessories, Accessibility, Administrative Tools, Windows Store, PC Settings, Control Panel, Run, Command Prompt, and PowerShell shortcuts from Menus

Download the “Custom_RDS_Start_Menu.bat” script here.

:: RDS SERVER 2012 CUSTOM START MENU AND TASKBAR SHORTCUT REMOVAL
:: Author: Nathan Thomas
:: Date: 02/11/2015
::
:: This script should be ran on the RDS server after your server administrators have already
:: logged in at least once so that they get all the shortcuts they need (otherwise you will 
:: need to manually copy them later on) but before your end users log in for the first time.
:: In addition, it assumes you have not already made changes or any customizations to the
:: All User's or Default User's Start Menus profiles and that you have already installed all
:: of the applications that the server will be running. Please note that if you decide
:: to install software after you've ran the script, you will manually have to remove that
:: program from the All User's Start Menu folder and copy it to your administrator profiles
 Continue reading "Batch Script – RDS Start Menu Application and Taskbar Shortcut Removal Tool"

Batch Script – Sending Items to the Recycle Bin Without Calling Any Third-Party Applications

While writing another larger script, I wanted the ability to send folders or files to the Recycle Bin, which I found out you can’t do natively via the command line without using some third-party apps or PowerShell.

I also found that when looping through a list of files in a batch script, it makes it really difficult to delete folders versus files because you have to either use the “del” command for files or the “rmdir” command for folders. With no simple way to differentiate between the two without a bunch of extra code, I kept looking for an alternative solution.
Continue reading “Batch Script – Sending Items to the Recycle Bin Without Calling Any Third-Party Applications”

Batch Script – Zip/Compress Files Without Calling Any Third-Party Applications

While writing another batch script the last several days, I found out that you cannot zip or compress files or folders natively from the command line without having additional third-party software or PowerShell. After a while of scouring the forums, I came up with this pure batch solution that uses VB script.

Basically, from this chunk of code in a single batch file, we can both generate the VB script, zip up whatever files we want, and then just delete the VB script when we’re done. Within the batch file, we can just call on the VB script using “CScript” and it works pretty much like any other function in any other programming language.
Continue reading “Batch Script – Zip/Compress Files Without Calling Any Third-Party Applications”

Batch Script – Get User’s SID One-Liner

While researching a way to try and send files to a user’s Recycle Bin from a batch script, I came across this one liner either at StackExchange or SuperUser forums somewhere. FYI, there is no way natively to send something to the trash without using a VB script or some third party utility. Yes you can physically move the files into the C:\$Recycle.Bin\<UsersSID> folder, but the files will not show up in Explorer and won’t be removed when you empty the trash that way.
Continue reading “Batch Script – Get User’s SID One-Liner”

Cisco SPA500S Excel Sidecar Template

Here is an Excel spreadsheet I found somewhere on the internet and modified to be the exact dimensions for the Cisco SPA500S sidecar (aka the Attendant Console) that works with any of the SPA 5xxG series of IP phones. I’ve even added extra columns to be able to add an extension and a description if you want for each line key button, which is perfect for a call center type environment. All you have to do is fill out the line keys you want on the template, print it out on any 8.5×11 sheet of paper (or any size paper that will fit the cells for that matter), then brush up on your kindergarten cutting skills and you’re in business. Enjoy!
Continue reading “Cisco SPA500S Excel Sidecar Template”

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 – Convert a Batch of WAV Files to SLINEAR Format for Asterisk Hold Music

Here are a couple of useful one-liners that I picked up from voip-info.org a while back to manipulate a bunch of audio files in a single directory with Sox. You can save yourself some processing power on your Asterisk PBX if all of your hold music is in SLINEAR format that way no transcoding has to take place.
Continue reading “Bash Script – Convert a Batch of WAV Files to SLINEAR Format for Asterisk Hold Music”

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”