Ana içeriğe atla

Kayıtlar

Dnf fastestmirror

I was trying to upgrade Fedora 24 to 25. The mirror dnf using was poor. I interrupted the download process many times with the hope that it will connect at a much more speed. But at last I decided to change the mirror that dnf uses. While searching for the correct code to do this, I noticed that there is a plugin that forces dnf use the fastest mirror (fastestmirror). It was already installed in my box but dnf was not instructed to use it. Hence a simple line fastestmirror=true in dnf.conf solved my issue.

Beautiful Soup get contents of a tag

I was embodying multiple body tags into a huge body tag to make a web page printable more efficiently. I used bash and python BeautifulSoup to get the web pages and parse them. Actually all of the job could have been done with python BeautifulSoup as the name suggests, but because I used some sed stuff previously, I did not attempt to change them into python equivalents (this requires usage of some libraries like urllib2 which I did not use since much time). By using such a code str(soup.find('body')) BeautifulSoup returns all the contents of body including and tags. Because I aggregate these tags into a new one, multiple tags appear in the new html document. This might cause some CSS problems in the presentation of the document, I propose. Thats why I needed to eliminate those superfluous tags.  This page from stackoverlow has helped me.  The required code was like that   body=body+''.join(map(str,soup.find('body').contents)) I really like  Beauti...

Html to Pdf conversion with wkhtmltopdf

Still need to convert html to pdf. I was looking for a batch converter. wkhtmltopdf seems to be a nice converter. It has many options including batch converting (ie. converting multiple html pages into one pdf file) and it does its job nicely except some pitfalls. When installed from standard Ubuntu repo, a cropped version is installed which does not have the ability of batch conversion. After you install full version from its website, it gives you broader options. By the way, since the web pages I needed to print to pdf contain many mathematical formulas, wkhtmltopdf conversion ability was limited and I preferred not to use it. Instead I used some bash hacking, and Firefox's print to pdf file option with Stylish addon as I have described in a previous post . 

Some tmux commands

I spent a lot of time in shells. Tmux is a late-discovery must-have for me. It is terminal multiplexer. I used to use screen command. But tmux is next generation of it. Tmux has 3 basic constructs: session,window and pane. Think session as a global container of insider elements: windows and panes. As described here Ctrl-b is the prefix command. After prefix s shows sessions and enables navigation d detaches from that session (not quit) w lists windows c create new window % splits a window horizontally " splits a window vertically n passes to next window p passes to previous window x kills the current pane & kills the current window ! breaks the pane out of window (making it a seperate window) arrow keys enables navigation through panes, windows $ tmux a  attaches a previous session. Have fun.

Centos 7 FirewallD Add/Delete/Log Rich Rule

Centos 7 has firewalld which has many options and a new language "rich language". I was looking for deleting a rich rule syntax which I found at last at fedora project wiki . Here is a delete rich rule   firewall-cmd --zone=public --remove-rich-rule='rule family="ipv4" source address="ip adress" reject'   which is added previously to the active zone=public by the following firewall-cmd --add-rich-rule="rule family=ipv4 source address=ip_adress reject" Here is to list all rich rules at a zone firewall-cmd --zone=public --list-rich-rules  If you wish to log packets you might need a rule like this   firewall-cmd --zone=public --add-rich-rule='rule family="ipv4" source address="ip adress" log prefix="badboy" level="info" limit value="1/m" reject' For further information please consult to wiki and official Redhat documentation .

Fail2ban Error on Centos 7 KVM instance

On Centos 7 I was struggling with fail2ban on different vm templates eg. OpenVZ and KVM. Previous post is about OpenVZ problems (not only about fail2ban) to which I could not find a solution yet. Now I would say some words about KVM instance. fail2ban 0.9.2 was running on Centos 7.1.1503 with systemd backend. I was struggling to ban failed ssh attempts with the following config options in jail.local file [DEFAULT] backend = systemd banaction = firewallcmd-ipset bantime = 3600 [sshd] enabled = true Nothing seemed to be wrong with these options and log files. But I was getting an error like this ERROR   ipset create fail2ban-sshd hash:ip timeout 3600 firewall-cmd --direct --add-rule  filter INPUT 0 -p tcp -m multiport -m set --match-set fail2ban-sshd src -j REJECT --reject-with icmp-port-unreachable -- stdout: '\x1b[91mwrong priority\nusage: --direct --add-rule { ipv4 | ipv6 | eb } \x1b[00m\n' As is easily seen, this is an error about ipset command whi...