I do upgrade packages manually on my machine because I want to control when and what to upgrade. Security freaks could argue that it is not secure not to update computers frequently but I believe that chances to get hacked because of an outdated package are less than receive an upgrade that bricks your computer. The recent Canonical fuck up with activating experimental Intel SPI drivers in kernel that bricked some Lenovo laptops is a very good example. Another reason is the time needed to upgrade packages because apt-get is really slow. So basically I need to check what has been changed and only upgrade if really needed.
Thoughts and ideas about programming, scripting, automation, electronics, gadgets, web and technology
Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts
Thursday, January 4, 2018
Saturday, April 29, 2017
How to Connect the rtl_433 to a remote rtl_tcp server
One of the issues with the rtl_433 application is that it is not
possible to connect it to a remote rtl_tcp server using syntax supported
by other SDR application like gqrx. One of proposed solutions is to use the TCP enabled version of the librtlsdr which is a bit complicated. There's actually a much simpler solution.
Saturday, December 3, 2016
How to create gists from the command line
Wednesday, February 17, 2016
Saturday, February 14, 2015
Sound volume change notifications using pynotify
As I started to use the i3 window manager I wanted to have a visual feedback on sound volume change events. Usually it's done by a daemon that binds to specific keyboard combinations to adjust volume and to send notifications to a notify daemon. In xfce this is done by the xfce4-volumed. I should also point here to other lightweight volume daemons like volnoti or pa-applet. Without a dedicated daemon it is also pretty much simple to handle sound volume keys by a simple bash script which is bind to specific keyboard combinations.
Labels:
bash,
notify-send,
python,
sound
Saturday, August 10, 2013
Redirecting terminal output into any X application
Sometimes I want to redirect bash output directly into an X application for further editing. Normally this is done using a temporary file where the bash output is saved and then it is opened by an application. There's a way though to start an X application and paste the bash output into its window automatically.
Thursday, July 4, 2013
Saturday, May 11, 2013
Using ssmtp to send email notifications
I've been using ssmtp for a long time to send automatic notifications from all my embedded systems like routers or NASes and also to send anything from a command line to a desired email address. The program is only 8K (whereas mutt is 3.5M) but it can handle secure TLS/SSL connections to SMTP servers. Setup is very easy as only one file has to be adapted. Please read this tutorial to set the ssmtp up.
To make it easier to use I have written a bash script that handles email header creation and adds a simple command line interface:
Monday, April 15, 2013
Vacuum cleaning of $HOME to back it up
I've started with a simple script to compress Firefox's sqlite databases before creating a backup of my $HOME directory
alex@xubuntu:~$ cat bin/vacuumFirefox.sh
#!/bin/bash
[ -n "$(pidof firefox)" ] && {
echo "ERROR: firefox is still running, close it first!"
exit 1
}
counterBefore=0
counterAfter=0
for i in ~/.mozilla/firefox/*/*.sqlite; do
fileSizeBefore=$(du -b $i|awk '{ print $1 }')
counterBefore=$((counterBefore + fileSizeBefore))
sqlite3 "$i" vacuum
fileSizeAfter=$(du -b $i|awk '{ print $1 }')
counterAfter=$((counterAfter + fileSizeAfter))
echo "$fileSizeBefore $fileSizeAfter - $(basename $i)"
done
echo "Bytes saved: $(( counterBefore - counterAfter ))"
Here is a sample output:
Thursday, March 28, 2013
Ubuntu with the NetworkManager as a NAT gateway
Sometimes I use my Xubuntu notebook as a NAT gateway for my Windows 7 computer because its WLAN interface works in 5GHz band and Windows computer works only in 2.4GHz. So I connect my Win7 computer to my Xubuntu notebook using a crossover Ethernet cable and turn it ito a NAT gateway using a bash script.
Labels:
bash,
dnsmasq,
nat,
NetworkManager,
ubuntu
Saturday, December 15, 2012
Annotate a JPG with its EXIF date and time
If you need to annotate a bunch of JPG pictures the following simple bash script could come in handy. Script uses pictures EXIF date and time information but could be easily patched to include any other text. The only dependencies script has are Image Magic and awk:
Labels:
bash,
Image Magic
Monday, July 16, 2012
AVR-Stick as an infrared receiver and logger
I have already described a project based on the AVR-Stick hardware. The next thing I wanted to try with that hardware is to create an infrared receiver and logger. In fact I wanted to emulate the dongle I described some time ago. But to emulate it I needed to know the protocol that is used. The easiest way to find out what protocol is used is to analyze signals with an oscilloscope of course but I didn't have one. So first of all I needed to implement a signal logging functionality.
Friday, June 29, 2012
AVR-stick as a temperature logger
I've stumbled recently upon a little gem called AVR-Stick and bought two of them for about 7€ per stick. I also had a thermoregulated fan controller salvaged from a recycled computer. I decided to desolder a thermistor from that controller and put it onto the stick to use it as a USB temperature logger. Stick's ATtiny85 has an internal temperature sensor too but it should be calibrated otherwise its precision is ±10°C. Thermistor that I'm using is equivalent to the NTCLE100E3103JB0 and its resistance is 10K at 25°C. Any other NTC thermistor that has resistance around 10K at room temperature could also be used but it should be checked if manufacturer specifies Steinhart-Hart equation coefficients for it.
Labels:
attiny85,
avr-stick,
bash,
bootloader,
C,
collectd,
logger,
lua,
temperature
Friday, June 10, 2011
A simple bash IRC logging bot
Couple of years ago I googled for a simple bash IRC logging bot that I could start on my router to log some channels. I've found a very simple script that worked but didn't handle PINGs from the server. So I extended it a bit trying to keep it as simple as possible.
Thursday, March 3, 2011
Encrypting with the openssl in bash
With a bit of commandlinefu it becomes easy to encrypt and decrypt files with the strong 256 bit aes algorithm using openssl.
Add the following into your ~/.bashrc
# crypting functions
function encrypt {
if [ -t 0 ]; then
# interactive
local fname="$1"
shift
openssl aes-256-cbc -salt -in "$fname" -out "${fname}.enc" $@
else
# piped
perl -e 'use IO::Select; $ready=IO::Select->new(STDIN)->can_read();'
openssl aes-256-cbc -salt $@
fi
}
function decrypt {
if [ -t 0 ]; then
# interactive
local fname="$1"
shift
openssl aes-256-cbc -d -in "$fname" -out "${fname%\.*}" $@
else
perl -e 'use IO::Select; $ready=IO::Select->new(STDIN)->can_read();'
openssl aes-256-cbc -d $@
fi
}
and source it to let changes take effect (source ~/.bashrc).
Labels:
bash,
encrypting,
openssl
Thursday, January 27, 2011
collectd-mod-exec Part 5
Part 1
Part 2
Part 3
Part 4
In this final part I'm publishing a real world example of the collectd-exec usage - weather info collecting script.
I'm using yahoo weather api to get weather information because it sends back very concise xml formatted text file which is only 2k in size. The weather info is updated once per hour so I've added special logic to retrieve it once per hour and feed same values in between.
Part 2
Part 3
Part 4
In this final part I'm publishing a real world example of the collectd-exec usage - weather info collecting script.
I'm using yahoo weather api to get weather information because it sends back very concise xml formatted text file which is only 2k in size. The weather info is updated once per hour so I've added special logic to retrieve it once per hour and feed same values in between.
Labels:
bash,
collectd-exec,
OpenWRT,
weather
Wednesday, January 26, 2011
collectd-mod-exec Part 4
Part 1
Part 2
Part 3
There is only one thing left to explain - how to get notified if some values go out of scope. As an example I'm going to send notification emails if CPU temperature reaches 57 degree Celsius. This could be implemented with only one additional if statement and this would work perfectly if I only had one script that sends notifications. It would become cumbersome if I needed to edit multiple scripts to change say an email address where my notifications are sent. In other words the collecting and notification logics shall be separated. To do this one can use 'PUTNOTIF' statement that shall be sent to the script STDOUT - exactly the same way like 'PUTVAL' is sent. Documentation of the 'PUTNOTIF' arguments can be found on the collect-exec module documentation page. Additionally there shall be some logic added to send notification after some time out period otherwise emails would be sent after each $COLLECTD_INTERVAL which is by default 30 seconds. Updated tmpcollect.sh script is shown below:
Part 2
Part 3
There is only one thing left to explain - how to get notified if some values go out of scope. As an example I'm going to send notification emails if CPU temperature reaches 57 degree Celsius. This could be implemented with only one additional if statement and this would work perfectly if I only had one script that sends notifications. It would become cumbersome if I needed to edit multiple scripts to change say an email address where my notifications are sent. In other words the collecting and notification logics shall be separated. To do this one can use 'PUTNOTIF' statement that shall be sent to the script STDOUT - exactly the same way like 'PUTVAL' is sent. Documentation of the 'PUTNOTIF' arguments can be found on the collect-exec module documentation page. Additionally there shall be some logic added to send notification after some time out period otherwise emails would be sent after each $COLLECTD_INTERVAL which is by default 30 seconds. Updated tmpcollect.sh script is shown below:
Labels:
bash,
collectd-exec,
OpenWRT
Monday, January 24, 2011
Friday, January 21, 2011
collectd-mod-exec Part 2
Part1
My router SBC is equipped with two temperature sensors to monitor cpu and board temperatures. Executing 'sensors' command produces the following result:
My router SBC is equipped with two temperature sensors to monitor cpu and board temperatures. Executing 'sensors' command produces the following result:
root@Alix:~# sensors
lm86-i2c-0-4c
Adapter: CS5536 ACB0
temp1: +36.0 C (low = +0.0 C, high = +70.0 C)
(crit = +85.0 C, hyst = +75.0 C)
temp2: +42.5 C (low = +0.0 C, high = +70.0 C)
(crit = +85.0 C, hyst = +75.0 C)
With a bit of the script-fu I'm stripping temperature values and feeding them into the database:
Labels:
bash,
collectd-exec,
OpenWRT
Thursday, January 20, 2011
collectd-mod-exec Part 1
Having some spare time I decided to write about powerful yet not well documented feature of the OpenWRT's luci-app-statistics plugin -- collectd-mod-exec module. This module allows collecting any type of data an external application could supply. In other words the module starts a user specified application which feeds collectd module with data. Principally having this module installed one could simulate all other collectd-mod-* modules.
Labels:
bash,
collectd-exec,
OpenWRT
Subscribe to:
Posts (Atom)





![[Image]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEij7wn8-6isQknV718kDbxmP8977k-MtJz32FsNCGy_TJxQNwfm4eK_c4r24eN9GSFfvkqbAPlyGqCfxgKs5KHJynh3cdREF3hbfWOVG_SqGA4-T3sBrra4iR1YXY3nbOIvesGVh6XAo4Y/s320/img_resized.annot.jpg)
![[Image]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCuAzhIeJuHP21BngOMt_gsrOJMjF2MhRFLwa_5ywQeziSBou-DMXrogI8k2SSwCKyIo25tDqdJ01PblWioCRXkst0mXW_cs83S-XxZlKWjOWFWfATXsT26Zy_Az-IluCzKpo03fVADZU/s320/irmodule_main.jpg)
![[Image]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAgYJLD5BudImPD7BAh8oKKm-2Hl1UzQSY0NmZJz46aWfzyKuyCf-iFuO-aP-dDxB6WzMVTUSEHmPd9k0XZOq0sAjSbxo1ZcKT6rXWZeuqzzsujdUViawjADmt21m3FCwqnE2I12cHlS0/s1600/avrstick.jpg)