2015-11-04 22:59

Many users reported me that port 445 is blocked on portquiz.net.

Sorry about that : my hosting company, OVH, is probably blocking this port.

I opened a support ticket but got a response stating that no port is blocked.

I opened a thread on OVH forum (french).

Feel free to post your tcptraceroute, or contact OVH.

2015-11-04 22:59
2015-10-27 20:11

I’ve been asked a few time how Portquiz.net works.

It’s really simple. It’s just made of a few iptables rules. I’m using the iptables-persistent Debian package to make the rules persist a reboot.

Here is the content of /etc/iptables/rules.v4:


# Generated by iptables-save v1.4.14 on Sun Aug 25 12:43:34 2013
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -i lo -j RETURN
-A PREROUTING -p icmp -j RETURN
-A PREROUTING -m state --state RELATED,ESTABLISHED -j RETURN
-A PREROUTING -p tcp -m tcp --dport 22 -j RETURN
-A PREROUTING -p tcp -m tcp --dport 21 -j RETURN
-A PREROUTING -p tcp -m tcp --dport 25 -j RETURN
-A PREROUTING -p tcp -m tcp --dport 80 -j RETURN
-A PREROUTING -p tcp -m tcp --dport 443 -j RETURN
-A PREROUTING -p tcp -j DNAT --to-destination :80
COMMIT
# Completed on Sun Aug 25 12:43:34 2013
# Generated by iptables-save v1.4.14 on Sun Aug 25 12:43:34 2013
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 25 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -j DROP
COMMIT
# Completed on Sun Aug 25 12:43:34 2013

The filter table is classical: ACCEPT a few services, then DROP the rest.

Portquiz.net logic is in the nat table:

  • Forward connection on any port to port 80 (DNAT –to-destination :80)
  • Except for normal services (just RETURN for normal activity)
2015-10-27 20:11
2014-08-31 11:55

Mathilde’s contribution:

This script allows you to launch a search by filesize on opensubtitles.org, with a simple right-click on a video file.

If it does not exist, create the .local/share/nautilus/scripts directory in your personnal folder (from Nautilus, you can use the Ctrl+H shortcut to display hidden files and be able to see the .local directory).

Save the subtitle file in .local/share/nautilus/scripts

Add execution permission to the script, in file properties, or running the command chmod +x ~/.local/share/nautilus/scripts/subtitle

Open Nautilus (aka “Files”). Select the film you want to search subtitles for, right-click > scripts > subtitle.
A browser window will open directly on opensubtitles.org with your search results.

NB:
By default, the script will search subtitles in english. To change the language, open the script and change the LANG variable.

Content of subtitle script:

#!/bin/bash

LANG=eng
#LANG=fr

FILE=$1
SIZE=$(stat -c %s $FILE)

xdg-open "http://www.opensubtitles.org/eng/search/sublanguageid-$LANG/moviebytesize-$SIZE"
2014-08-31 11:55 · Tags: ,
2014-05-29 18:59

Here are the steps I used to upgrade the BIOS of my Lenovo Thinkpad X1 Carbon Gen 2.
You have to download the bootable ISO file from Lenovo support site, convert it and copy it to a usb flash drive.

You will need a USB key you can erase.

First Get the bootable ISO file from Lenovo support website. To get your product number:

sudo dmidecode -t system | grep Product

To check your BIOS version: sudo dmidecode -t bios

Get the geteltorito program from your packages or download it:

cd /tmp/
wget http://userpages.uni-koblenz.de/~krienke/ftp/noarch/geteltorito/geteltorito
chmod +x geteltorito

Extract the img from the ISO:

./geteltorito -o bios.img gruj09us.iso

Copy the img to the USB key (make sure sdb is you USB key!!):

sudo fdisk -l /dev/sdb #at least check that device size is right
sudo dd if=bios.img of=/dev/sdb

That’s it. Boot on USB stick and follow the instructions to update your BIOS.

2014-05-29 18:59 · Tags: , , , , ,
2014-04-27 14:24

If you have the problem when pushing to github for example.

You can just empty the core.askpass param:

git config --global core.askpass ''

See also man git config

2014-04-27 14:24 · Tags: , ,
2014-04-06 17:54

After searching a bit I could not find a simple and good howto to do that.
The following method should work for any Linux distribution (Ubuntu, Debian, Manjaro, Archlinux, Fedora…). Source and target systems must be on the same processor architecture (though transfer from 32bit to 64bit should work).

What you need:

  • 2 live USB keys (or cds)
  • To speed up data transfer: good quality ethernet cables (one cable between the 2 computers is OK), or a usb key/drive with a BIG ext4 partition. You can try over wifi, but it may be slow.

1. Boot source and target machines on live USB/CD

Any live USB/CD should be OK.
On the target computer, you will need a tool to partition your hard drive, like gparted.
rsync is also required for data transfer: it’s included in many live systems.

Ubuntu live cd is OK, Manjaro live cd too.

2. Partition your target hard drive

Use a tool like gparted to partition the target hard drive, with the same partitions as your source system (slash, swap, home…).
I recommend you to assign LABELs to your partitions: for the fstab, it’s easier than UUIDs.

3. Mount all partitions on both machines

On both systems, open a root terminal. Then, for each data partition (you can ignore swap):

mkdir /mnt/slash
mount /dev/sdaX /mnt/slash

If you have a home partition:

mkdir /mnt/home
mount /dev/sdaY /mnt/home

4. Transfer the data (network or usb)

This part may be tricky. Choose the method you prefer.

Network

  1. Setup the network. Test the connectivity with ping command.
    The easier is to plug the PCs on a DHCP network (like your ISP box) so that you get automatic IP addresses. If you linked the 2 pcs with a single cable, you’ll have to setup the IPs with NetworkManager (static ips, or adhoc network).
  2. On source system, as root, create a simple /etc/rsyncd.conf file:
    uid = root
    gid = root
    use chroot = no
    
    [all]
        path = /
    
  3. Then start the rsync daemon server: rsync --daemon
  4. On target PC, for each partition:
    rsync -avHX SOURCE_IP::all/mnt/slash/ /mnt/slash/
    

    Don’t forget ‘/’ at the end of paths. -a will preserve many file attributes like owner and permissions, -H will preserve hardlinks if any, -X will preserve extended attributes like setuid. You may also add -A if you are using acls. What is good with rsync is that you can stop and restart the transfer whenever you want.

USB

Prepare a USB drive with a BIG ext4 partition.

  1. Mount the USB partition on source system (mount /dev/sdbX /mnt/usb)
  2. For each partition:
    rsync -avHX /mnt/slash/ /mnt/usb/slash/
    
  3. umount, unplug and remount the USB disk on the target system.
  4. For each partition:
    rsync -avHX /mnt/usb/slash/ /mnt/slash/
    

5. Change fstab on target system

As root, edit /mnt/slash/etc/fstab
For each partition (including swap), replace the first field with the new UUID or LABEL (it’s straightforward with LABELs):
UUID=the-long-uuid, or LABEL=yourlabel

2 ways to get the UUIDs / LABELs:

ls -l /dev/disk/by-uuid/
blkid /dev/sdaX

6. Reinstall Grub

We will use a chroot (changed root environment) to be able to call the grub install inside the migrated system.

First, bind mount some system directories needed by grub, then chroot:

mount --bind /proc /mnt/slash/proc
mount --bind /sys /mnt/slash/sys
mount --bind /dev /mnt/slash/dev
mount --bind /run /mnt/slash/run
chroot /mnt/slash

Then install grub in the Master Boot Record of your hard drive, and update grub config file (with the new uuids…):

grub-install /dev/sda
update-grub

7. Reboot target machine

That’s it! Your system should be working on the new computer now.
Feel free to comment if you encounter problems.

2014-04-06 17:54 · Tags: , ,
2013-12-05 23:22

Bsync is a bidirectional file synchronization tool, using rsync for transfers. Moved files are also synchronized in a smart way.

It uses rsync for file transfers, find to generate filelist snapshots, and ssh for remote transfers.

bsync is an alternative to Unison, written in Python 3. A big strength of bsync: it can detect and apply moved files from one side to the other (Unison uses some copy calls to handle moved files).

I developped it to be able to synchronize my music directory from my laptop to my Raspberry Pi in an efficient way, and to sync with my girlfriend laptop too.

Bsync is released under GPL. Feel free to report any bugs/wishes in GitHub issues.

More info, Download and Install on the GitHub repo.

2013-12-05 23:22 · Tags: , , , , ,
2013-12-05 21:18

I just finished migrating my blog from Dotclear to WordPress.

I quickly tried some existing plugins to do the migration but none worked. My setup is a bit complicated because I was using the dc_translate plugin to translate all my posts.

Here is the migrate script. If it can be of use. Warning: you probably have to adapt the script to your needs, to remove some stuff, because it’s also reading Dotclear translation tables.

  • The script is called in command line via PHP cli
  • The script is using plain SQL to read from Dotclear database and to write to WordPress database.
  • It uses the wiki2xhtml Dotclear library to convert dotclear wiki syntax to html.
  • It uses formatting WordPress library to convert Posts url to WordPress format.
  • For each post, it also imports comments and tags.

I’m now using 3 plugins to manage my French translations in WordPress:

  • qTranslate
  • qTranslate slug
  • qTranslate Separate Comments

migrate_dc.tar

2013-12-05 21:18
2013-08-15 23:29

Thanks to:
http://vickychijwani.github.io/2012/04/15/blazing-fast-application-switching-in-linux/

I made a few improvements on the script. If you want something with more features (but also more complex).

  • Use /bin/sh so that it may use dash instead of bash (lighter)
  • Use exec to start the command so that it replaces the current script (otherwise you get unneeded bash processes in ps)
  • Raise all windows of the same class: useful to raise all terminals for example
  • “toggle mode” : when run a second time, the windows are minimized. For that I had to depend on xdotool, because wmctrl can’t do that (probably coming in a future wmctrl release. the author commited a -Y flag in github for that).

Save it to /home/USER/bin/run-or-raise, then add some keyboard shortcuts in your window manager settings and enjoy!

<Super>f /home/USER/bin/run-or-raise Navigator.Firefox firefox
#!/bin/sh
# syntax: run-or-raise WM_CLASS_name COMMAND
#   WM_CLASS_name : the WM_CALL_name of the window (from wmctrl -lx output)
#   COMMAND : the command to run if nothing to raise

#logfile=/tmp/$(basename $0).log
#exec > $logfile 2>&1

# get windows ids matching WM_CLASS_name
WINIDS=$(wmctrl -lx | awk '{ if ($3 == "'"$1"'") print $1}')

# run if nothing started. exec will end the script
[ -z "$WINIDS" ] && exec "$2"

# if the window is active, we minimize all the windows of the class
ACTIVEWIN=$(wmctrl -a :ACTIVE: -v 2>&1 | sed -n 's/^Using window: \(.*\)/\1/p')
MINIMIZE=false
if echo "$WINIDS" | grep -q "$ACTIVEWIN"; then
        MINIMIZE=true
fi

for ID in $WINIDS; do
        if $MINIMIZE; then
                xdotool windowminimize "$ID"
        else
                wmctrl -i -a "$ID"
        fi
done
2013-08-15 23:29 · Tags: