2024/04/02

slackware local mirror copy

a work in progress ...
to make sure it is working, first do a full slackpkg update. 
create /data/mirror
then run this script, adapt to your needs:

MIRROR_HOST="ftp.slackware-brasil.com.br"
MIRROR_DIR="/data/mirror"
BWLIMIT=0
RSYNC_OPTS="-avPH --bwlimit=$BWLIMIT --delete --delete-excluded --progress "

rsync $RSYNC_OPTS \
--exclude source \
$MIRROR_HOST::slackware/slackware64-current/ $MIRROR_DIR/slackware64-current
echo "Done!" 


create a vhost inside /etc/httpd/extra/http-vhosts.conf
run/restart httpd
update mirrors in /etc/slackpkg to point to the new virtual web host
run slackpkg update
should give no error

2023/10/05

Show "X" as Twitter in your browser

On a desktop computer (forget about cellphone), grab Firefox if you don't have it already and install FoxReplace addon. Then add a rule with the following substitutions (do not include quotes):

" X " -> " Twitter ", Match case: yes

" X:" -> " Twitter:", Match case: yes

url section can be blank which means all sites having  that text will have it replaced (ie: news)


2021/08/28

PhpUnit Code Coverage Analysis

goal is to be able to select individual directories for the CCA:

 $phpunit --coverage-html=./cca \
--coverage-filter=./app \
--coverage-filter=class   \
--coverage-filter=common  \
--coverage-filter=helpers   \
--no-configuration --color tests/testSuite.php

TODO: rant about XML.

2021/08/26

extracting PHP errors & warnings from apache log

slackware:

cd /var/log/httpd 

or  debian

cd  /var/log/apache2

clear ; cat error.log | grep PHP | grep -P  '(.*])\K.*' -o |sort -u



2021/03/30

How to prevent web admin session expiration on routers (Huawei at least)

Note: this post is just a  public draft.

1)  open Firefox

2) visit your router's administration web page. 

3) Open debugger. 

4) Log in

5) on the Network tab, right click on the first entry (usually index.php or whatever) and under "Copy" select "Copy as cURL"

6) open konsole or whatever terminal you preffer

7) write watch -n 30 and a double quote, then paste and add -k -o /dev/null and close the double quotes

8) hit enter to run watch and go back to your browser.

leave your web admin tab open, otherwise you will have to repeat all the steps.


this trick might be useful on every site that makes your session expire via ajax calls.


2021/01/05

Script to prevent SSH attacks while allowing you to connect from dynamic IP address.

while most of the time connecting to a remote server using openvpn would be a smart choice, sometimes it's not an option. This script is for a linux behind a firewall/router. It's intended to prevent SSH attacks (by simply denying access to the SSH port) while allowing you to connect from your own dynamic DNS, that is, if you have a dynamic ip given by your ISP, otherwise you could simply use iptables.

#!/bin/bash
valor=`host yourdyndns`
OK=$?
if [ $OK -ne 0 ]; then
  exit
fi
addr=$(echo $valor |egrep "address .*" -o)
ip=$(echo $parte |egrep "[0-9\.]*" -o)

whitelist=/root/whitelist
touch ${whitelist}

exists=`cat ${whitelist} | grep "${parte2}"`

if [ $? -ne 0 ]; then
  echo $ip >$whitelist
  iptables -F   iptables -A INPUT -s $ip -j ACCEPT
  iptables -A FORWARD -s $ip -j \ ACCEPT                                                                                         
  iptables -A INPUT -p tcp --dport 22022 -j DROP                                                                                   
fi

add this to rc.local to reload iptables during bootup:

# delete whitelist

rm /root/whitelist

# run previous script

/root/bin/testso.sh


2021/01/03

x2x on Slackware

 I had to write something. This was kinda shocking to me. I was looking for a KVM (Keyboard, Video and Mouse) software to be able to control my notebook from my PC.  Been using an old free version of Synergy, but for some odd reason seems to be compiled for 32 bits and I felt it was a terrible waste to install multilib just to run it. So I decided to look for an alternative.

As usual, went to google and discovered that Slackbuilds has Barrier but when I tried to install it, it asked for avahi, and avahi asked for something else and that something else asked for other-something-else. So I gave up. Then I came across x2x.

This particular software has a wikipedia page so I wont bother telling the story about it.

    cd

    mkdir -p install/util/x2x

    cd install/util/x2x

    wget https://slackbuilds.org/slackbuilds/14.2/desktop/x2x.tar.gz

    tar xf x2x.tar.gz 

    cd x2x

    wget https://slackware.uk/~urchlay/src/x2x-1.30_beta+20200121_ec10215.tar.xz

    su

    ./x2x.SlackBuild

    installpkg /tmp/x2x-1.30_beta+20200121_ec10215-x86_64-1_SBo.tgz

then I have to create an script to connect to my notebook, but before I get into that I had to read the man page, last section, after the examples, gives an important tip when you have multiple monitors 

Left: 1920*1080 (primary)

Right: 1366*768

So I had to do the math and write the parameters to x2x according to the man page:

#!/bin/bash
ssh -YC rudy@macabra x2x -north -to :0.0 -big  -completeregionleft 0 -completeregionup 0 -completeregionright 3286 -completeregionlow 768

I have ssh configured so it wont ask me for password. North parameter means I placed my notebook "over" my monitors and it doesn't really matter from which monitor my mouse goes up, it appears on my notebook and it's able to travel  the entire notebook screen.

What shocked me about this is the fact it's a very old proyect, but works like a charm.