zsh.li Pinkhat Memories Me About ?

Dear My
Linux

Ip leaking, spotify and hardware clock.


Sync hardware clock with cron

My hardware clock won't keep correct time, that is the reason I should be using ntpd but this service is not working in my system, but here is how I fixed the issue, instead of reliying of ntpd, I scheduled two cronjobs like this:

0 19 * * * bash /etc/cronup.sh 
3 19 * * * hwclock --systohc

This will run a sh script everyday at 19:00 and then it will sync the hardware clock at 19:03, it way not run at the exact time, but as long as it run daily is fine, the script content is the following:


#! /bin/bash
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

Installing Spotify in Slackware

Installing spotify in Slackware is pretty strightforward, I just installed with the Slackbuilds in the Slackbuild repo using sbopkg, however I need to create a symbolic link for it to work:

ln -s /usr/lib64/libcurl.so.4.5.0 /usr/lib64/libcurl-gnutls.so.4

Thanks to the following link linuxquestions.org

Ip leaking in Linux

I never though that the ip leaking issues happened in Linux, I mean, this is not Windows, the first one filtration happens with the NetworkManager plugin, is not realiable using a VPN from this plugin, I have checked by myself, however the most realiable openvpn daemon is incredibly failing too, in the lapse between connecting to the VPN if you open a web browser, your ip is leaked, another one leaking that surprised me was an ipv6 vpn filtration, I'm not sure how this was possible, so when using a VPN in Linux, its a must to enable a firewall to only allow that VPN and if you can please disable ipv6.


World clock in awesome


awesome systray
Awesome systray

For displaying multiple clock in awesome with different timezones we need to create new clock widgets, this post is based on awesome 4.2, you will need to create a new widgets in ~./config/awesome with the following code: utc.lua

It has just two differences with the original textclock.lua widget, here the diff output from these two files:


35c35
<     format = format or " UTC:  %H:%M || "
---
>     format = format or " %d local: %H:%M "
37c37
<    timezone = timezone or TimeZone.new("Z")
---
>    timezone = timezone and TimeZone.new(timezone) or TimeZone.new_local()

I'm not a programmer, but I read the programmer Documentation and modified the code accordingly, I only was able to understand that the parameters after the OR operand was true and I don't know why, but my code works.

Its important to notice that you have to specify the timezone name in the format variable in order to show the clock's name, check the bold text in the diff output above.

The most important thing to do is to replace the Z in the TimeZone.new("Z") function, Z is the UTC timezone, in the case of Argentina the timezone would be: TimeZone.new("America/Buenos_Aires")

Then edit your ~/.config/rc.lua file and search for this string:

mytextclock = wibox.widget.textclock()

In order to use the widget we have to pass the function into a variable, so if we have the Argentina and UTC clocks besides the local one, it will look like this:


mytextclock2 = textclock2()
utc= utc()
mytextclock = wibox.widget.textclock()

Finally search for the widgets wibox session and add the declared variables there:


-- Add widgets to the wibox
    s.mywibox:setup {
        layout = wibox.layout.align.horizontal,
        { -- Left widgets
            layout = wibox.layout.fixed.horizontal,
            mylauncher,
            s.mytaglist,
            s.mypromptbox,
        },
        s.mytasklist, -- Middle widget
        { -- Right widgets
            layout = wibox.layout.fixed.horizontal,
            mykeyboardlayout,
            wibox.widget.systray(),
	   utc,
            mytextclock,
            mytextclock2,
            s.mylayoutbox,
        },
    }

Convert all htaccess files to httpd.conf directives


This post is for the Apache web server, I created a simple script that will do the job. You may use it in Wordpress or in many CMS, surely this script will be useful in a lot of situations. It will help you to increase the speed and security of your site. Requirements: root access.

#! /bin/bash
b=$(find $1 -name .htaccess)
for p in $b; do if [[ -s "$p" ]] ; then a=$(dirname $p); echo \<Directory \"$a\"\>; cat $p; echo; echo \</Directory\>; echo; fi; done

You only have to specify the website directory and it fill search for all .htaccess files in sub-directories, then it will print the directives for the httpd.conf file, you can invoke the script like this:

./script.sh /var/www/html


Add the resulting configuration manually to httpd.conf and don't forget to add AllowOverride None to the root directory, in this way my website speed increased noticeably! Also security increased. Please notice that you may end with a duplicated entry for the base directory, so please check it carefully. I read that a hacked website may include malicious code in the .htaccess files, so please check the code before adding into the config file.


All system messed when installing an application


It has been a while since the last time I did a whole system update in Slackware, this time I tried to install audacious, an audio player included in the official repos, the first thing to do was updating the list of files:

slackpkg update

Then I installed audacious:

slackpkg install audacious

At certain point it seems that it asked me to replace configuration files. It messed with my whole system. Installing just an application messed with all my /etc directory. So my advice is that you always check the configuration files that will be updated no matter what you are doing or the distro you are using.

How I solved it?

The next day I realized that I had lots of .orig files in /etc. So I restore all my important config files.

find /etc -name *.orig

Notice that I lost my /etc/rc.d/rc.local , there was not an /etc/rc.d/rc.local.orig


Script for concatenation


Here a tip for using split and cat, you can use this simple bash script for concatenating the pieces of the file, first you have to change the current directory to the one with the current files part.

You will be asked by the base name and the extension of the file. Easy!

#! /bin/bash
read -p "Base name: " basi
read -p "Extension: " ext
cat $(ls $basi*) > $basi.$ext