Planet dgplug

September 25, 2016

Shakthi Kannan

GNU Emacs - Shells, spell-checkers, abbreviations and printing

In this next article in the GNU Emacs series, we shall learn how to execute shell commands, run shells, use spell-checkers and abbreviations, and print from GNU Emacs.

Shell mode commands

You can run a shell command from GNU Emacs using the M-! shortcut. For example, typing ‘M-!’ will prompt you with the message ‘Shell command:’ in the minibuffer. If you then type ‘date’, it will produce the output ‘Tue Dec 8 21:19:24 IST 2015’ in the minibuffer. But, if you want the output to be inserted in the current buffer you can use the C-u M-! command sequence.

Consider the following poem that I wrote:

"Water, water everywhere
Little power and aid to spare
Really tough for us to bear
We will face it with Chennaites' flair.

Lakes and rivers overflowing everywhere
No road, rail or plane to go anywhere
People really are in big despair
But we will ride it with Chennaites' flair.

More storms are forecast to be aware
Nothing like this in 100 years to compare
Stay indoors and please do take care
And we will take it with Chennaites' flair."

Suppose I want to know the number of words used, I can mark the poem as a region in the GNU Emacs buffer, and execute a shell command for the region using M-| shortcut. It then prompts with the string ‘Shell command on region’, and when I type in ‘wc -w’ it returns ‘90’.

Shells

There are three shells available in GNU Emacs - shell, ansi-term and eshell. Using M-x shell will invoke a shell for you. This starts a new buffer with the name ‘shell’ in it. You can use all the GNU Emacs buffer commands in this window. For example, C-p will move the cursor up, and C-n will move the cursor down. In order to interrupt a current job in the shell buffer, you can use C-c C-c. If you want to suspend the current job, you can use C-c C-z. You can also clear the output from the previous command using C-c C-o. For example, the output of ‘ifconfig’ command is shown below:

/tmp $ ifconfig docker0
docker0   Link encap:Ethernet  HWaddr 56:84:7a:fe:97:99
          inet addr:172.17.42.1  Bcast:0.0.0.0  Mask:255.255.0.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
/tmp $

After executing ‘C-c C-o’, the previous command output gets cleared as shown below:

/tmp $ ifconfig docker0
 *** output flushed ***
/tmp $

You can move the cursor up to the previously executed commands using C-c C-p and move down using C-c C-n. You can also cycle backwards and forwards through the command history using the M-p and M-n shortcuts respectively. The C-c C-r shortcut moves to the first line of the output to the top of the window. You can move the cursor to the bottom of the window using C-c C-e. The C-r key binding allows you to search for a previously typed command from history.

The default shell is Bash, but, you can change it to use other shells like ksh, csh or zsh. You can open another shell buffer using C-u M-x shell. The new shell buffer will be called ’shell<2>". You can, of course, rename this buffer. You can thus open multiple shells to work inside GNU Emacs.

GNU Emacs also has a terminal emulator that you can invoke using M-x ansi-term. You can start a Bash session with this command to get the actual colours that you see in a terminal session. This is like a fallback shell if you do not want to use ‘M-x shell’. Eshell is the Emacs built-in shell written completely in Emacs Lisp (Elisp). You can start it using M-x eshell. The advantage of using this is that you can extend it, write your own customized Elisp functions and use it similar to shell scripting.

Screenshots of shell, ansi-term and eshells in GNU Emacs are shown in Figure 1, 2 and 3 respectively:

shell ansi-term eshell

Spell check commands

You can check the spelling of a word by placing the cursor on it and using M-$ shortcut. For example, for the word ‘hte’, GNU Emacs provides the following spelling options:

(0) hate (1) HT (2) ht (3) GTE (4) the (5) He (6) Te (7) he (8) Hts
(9) hie (:) hoe (;) hue (<) Rte (=) Ste (>) Ute (@) ate (B) rte

It also lists some options in the minibuffer:

C-h or ? for more options; SPC to leave unchangedo Character to
replace word

On pressing the number 4, the word is replaced with the correct spelling. If the spelling is already correct, then GNU Emacs will tell you that the word is correct. You can also spell check a region using M-x ispell-region and a buffer using M-x ispell-buffer. If you would like to stop the spell checker while it is running, you can use M-x ispell-kill-ispell. There is a flyspell mode that can check your spelling as you type. You can enable it using M-x flyspell-mode. If you want this mode only in a buffer, you can use M-x flyspell-buffer.

Word abbreviation

GNU Emacs can complete words for you. If you type ‘ba’ and then hit M-/, then GNU Emacs will try to complete the word for you. If you continue to use ‘M-/’, it will cycle through the various options such as ‘backwards’, ‘ball’, ‘bash’, ‘bar’, ‘back’, ‘based’ etc. To enter into the abbreviation mode, you need to use M-x abbrev-mode followed by the Enter key.

The abbreviations can either be local or global. Suppose, you want to define a local abbreviation for ‘international’, you can type in ‘intl’ and use C-x a i l to define the expansion. It will prompt you with the message ‘Mode expansion for “intl”:’. You can then type the word ‘international’. The next time you enter ‘intl’ followed by the space key, GNU Emacs will automatically expand the same for you. In order to define a global expansion, you need to use C-x a i g command sequence. If you would like to remove all abbreviations for the current session, you can use M-x kill-all-abbrevs followed by the Enter key.

You can save the abbreviations to a file, say ~/.emacs.d/.abbrev_defs, using M-x write-abbrev-file for future use. You can also edit the stored abbreviations using M-x edit-abbrevs shortcut. If you would like to view all the defined abbreviations, you can use M-x list-abbrevs. The relevant contents of ~/.emacs.d/.abbrev_defs are shown below:

;;-*-coding: utf-8;-*-
(define-abbrev-table 'Buffer-menu-mode-abbrev-table '())

(define-abbrev-table 'completion-list-mode-abbrev-table '())

(define-abbrev-table 'edit-abbrevs-mode-abbrev-table '())

(define-abbrev-table 'emacs-lisp-mode-abbrev-table
  '(
    ("intl" "international" nil 2)
   ))

(define-abbrev-table 'fundamental-mode-abbrev-table '())

(define-abbrev-table 'global-abbrev-table '())

(define-abbrev-table 'lisp-mode-abbrev-table '())

(define-abbrev-table 'sh-mode-abbrev-table '())

(define-abbrev-table 'shell-mode-abbrev-table '())

Printing

You can print the buffer contents from GNU Emacs using M-x print-buffer command. If you would like to print a selected region, you can use M-x print-region command. These will be printed with page numbers and headers. You can also print a buffer without page numbers using M-x lpr-buffer. Similarly, to print a region without page numbers, use M-x lpr-region. If you are already using the Dired mode, you can select the files that you want to print using the P shortcut, and then execute in Dired mode to print them.

September 25, 2016 05:00 PM

September 23, 2016

Anwesha Das

See you PyLadies at PyCon India

PyCon India 2016 has started today. The Day 0 was the devsprint. Reached the venue late ( actually never thought would be able to attend due to my food pipe infection issue). Met friends which is one of the most attractive point of attending the conference apart from learning new things and other. Checked the Red Hat booth where we, PyLadies will be standing. Made preparations and plans regarding the set up. Discussed plans for the conference with other PyLadies. I have already asked them to give some lighting talks about what they have learnt and what do we do in PyLadies Pune since I have rebooted the PyLadies Pune Chapter.

Tomorrow there will be my talk on PyPI Licensing Scenario. This year's PyCon, we will be having a good number of PyLadies attending the conference. Meet us, Trishna Guha, Nisha Menon Poyarekar,Rupali Talwatkar,Pooja Yadav at PyCon beside Red Hat booth. This is for the first time I left Py(my 21 months old daughter) at home. Hopefully this PyCon will turn out to be a worthwhile experience. I know Nisha Menon Poyarekar has the same feeling. So, see you at PyCon India, 2016.

by Anwesha Das at September 23, 2016 04:49 PM

September 21, 2016

Kushal Das

Dgplug contributor grant recipient Trishna Guha

I am happy to announce that Trishna Guha is the recipient of a dgplug contributor grant for 2016. She is an upstream contributor in Fedora Cloud SIG, and hacks on Bodhi in her free time. Trishna started her open source journey just a year back during the dgplug summer training 2015, you can read more about her work in a previous blog post. She has also become an active member of the local Pune PyLadies chapter.

The active members of dgplug.org every year contribute funding, which we then use to help out community members as required. For example, we previously used this fund to pay accommodation costs for our women contributors during PyCon. This year we are happy to be able to assist Trishna Guha to attend PyCon India 2016. Her presence and expertise with upstream development will help diversity efforts at various levels. As she is still a college student, we found many students are interested to talk to and learn from her. So, if you are coming down to PyCon India this weekend, remember to visit the Red Hat booth, and have a chat with Trishna.

by Kushal Das at September 21, 2016 02:20 PM

September 11, 2016

Kushal Das

One week with Fedora Atomic in production

I was using containers for over a year in my personal servers. I was running a few services in those. For the last one week, I moved all my personal servers into Fedora Atomic, and running more number of services in those.

Server hardware & OS

These are actually VM(s) with couple of GB(s) of RAM, and a few CPU(s). I installed using the Fedora Atomic ISO image (get it from here) over virt-manager.

The containers inside

You can find all the Dockerfiles etc in the repo. Note: I still have to clean up a few of those.

Issues faced

In day zero the first box I installed, stopped printing anything on STDOUT, after a reboot I upgraded with atomic host upgrade command. I never had any other problem still now. So, try to stay updated.

Building my own rpm-ostree repo

My next target was to compose my own rpm-ostree repo. I used Patrick’s workstation repo files for the same. In my fork I added couple of files for my own tree, and the build script. The whole work is done on a Fedora 24 container. You can view the repo here. This whole thing is exposed via another apache container. I will explain more about the steps in a future blog post.

What is next?

First step is clean up my old Dockerfiles. I will add up any future service as containers in those boxes. Even though we are automatically testing our images using Autocloud, using this in my production environment will help me find bugs in more convenient manner.

by Kushal Das at September 11, 2016 11:04 AM

September 08, 2016

Trishna Guha

Run commands on Fedora Atomic host from Remote host using Ansible

This post will show how to run commands on your atomic host from remote.

I am using Fedora Atomic host. Boot up your atomic instance. Make your you have Ansible installed on your control host.

The user of fedora instance is “fedora” by default and there is no password authentication. So first we will need to create password on the atomic for user “fedora”.

For that type the following command. It will ask for new password.

$ passwd

Now we will need to change PasswordAuthentication to YES . Open /etc/ssh/sshd_config on atomic host and change PasswordAuthentication to YES. Now The atomic host is all set🙂.

Go to your Remote host/Control host. I am using Fedora Workstation.

Now we need to generate ssh key on our control host.

Type the following command. This will create ssh key(private and public) on your host. The default location is of public key is ~/.ssh/id_rsa.pub.

$ ssh-keygen

It is time to add the ssh key to the Atomic host.
Type the following command. This will add your ssh public key to .ssh/authorized_keys on atomic host.

$ ssh-copy-id username@IPofAtomicHost

Now we will create inventory and config file for Ansible.

$ mkdir test && cd test
$ touch inventory
$ touch ansible.cfg

Inside the inventory file add the following:

[atomic]
IP-of-Atomic-Host

Inside the ansible.cfg file add the following:

[default]
inventory=inventory

Now let’s ping the atomic host🙂.

$ ansible atomic -i inventory -m ping

If the above returns Success we will try to run command on atomic host from our remote host🙂.
Type the following to run command on your atomic host.

$ ansible atomic -i inventory -m command -a "sudo atomic host upgrade"

 

NOTE: If you have you atomic instance running on Openstack make sure to add icmp to the security groups of the instance.

fotoflexer_photo1

fotoflexer_photo


by Trishna Guha at September 08, 2016 10:57 AM

September 06, 2016

Shakthi Kannan

GNU Emacs - Games

In this article in the GNU Emacs series, we shall learn how to play games and try out some software for fun.

Ten games that are available and can be played easily in GNU Emacs are listed and discussed in this article. We start with the Tetris game.

Tetris

Tetris is available in GNU Emacs and you can launch it using M-x tetris. The ‘Up’ arrow key can be used to spin the tile, while the space key can quickly drop the tile. You can pause the game by pressing the ‘p’ key. At the end of the game, a score is displayed in a buffer. For example:

112 shakthi shakthi <author@shakthimaan.com>  Mon Nov  2 21:12:04 2015
52 shakthi Shakthi Kannan <author@shakthimaan.com>  Mon Nov  2 15:24:43 2015
11 shakthi shakthi <author@shakthimaan.com>  Mon Nov  2 15:29:39 2015

A screenshot of Tetris in GNU Emacs:

Tetris

Pong

You can play Ping Pong in GNU Emacs with two players using M-x pong. One player can use the ‘Up’ and ‘Down’ arrow keys, and the second player can use the number keys - ‘4’ and ‘6’. Each paddle is represented by three square tiles. If the ball hits the edge of the paddle, it changes its direction. You can use the ‘p’ key to pause the game. A live score is displayed during the game. A screenshot of Ping Pong:

Pong

Doctor

GNU Emacs comes with a psychotherapist with whom you can chat. Simply type M-x doctor and it will start a session with the therapist. After you type in your statement, you need to hit Enter twice, and the therapist will reply. It will usually ask you another question, and you can continue to chat with the doctor. An example of a session is given below:

I am the psychotherapist.  Please, describe your problems.  Each time
you are finished talking, type RET twice.

Hi

How do you do?  What brings you to see me?

I am trying to talk to the doctor.

Why do you say you are trying to talk to the doctor?

I want to share this transcript with my readers.

What makes you believe you might want to share this transcript your
readers?

I can, from GNU Emacs, copy this text and paste it in my article.

Emacs?  Hah!  I would appreciate it if you would continue.

I am looking forward to watching today's cricket match that India is playing.

Is it because india is playing that you came to me?

Yes, who do you think will win?

Earlier you said you would like to share this transcript your readers?

Yes, I am still going to do that.

Can you elaborate on that?

I am writing a GNU Emacs series for the OSFY magazine.

Are you sure?

Yes, I have been writing for the past few months.

Maybe your life has something to do with this.

I want people to learn and use GNU Emacs to improve their productivity.

Are you sure that that?

Absolutely!

Perhaps you could continue.

Bubbles

The objective of the Bubbles game is to remove a series of connected bubbles in the fewest number of moves. The game can be started using M-x bubbles. As you move through the grid of bubbles, the connected bubbles with the same colour get highlighted. You can press the space bar to remove them. A screenshot of bubbles:

Bubbles

At the end of the game, a summary of the score is shown.

Selected:    9
Score:    1932
Game Over!

GNU Emacs also keeps a record of the scores:

01959   Mon Nov  2 21:26:41 2015        shakthi <author@shakthimaan.com>
01932   Mon Nov  2 21:20:38 2015        shakthi <author@shakthimaan.com>

Conway’s life

The shortcut M-x life will start the Conway’s Game of Life in a new GNU Emacs buffer. The population increases in course of time, and the generation count is shown in the mode line. A screenshot of the cellular automation running inside GNU Emacs:

Conway's Life

Morse and NATO conversions

You can convert text to Morse code and vice versa by selecting the text in a buffer and using M-x morse-region. For example, the text ‘morse code’ gets converted to the following:

--/---/.-./.../. -.-./---/-../.

You can get back the text by selecting the Morse text and applying M-x unmorse-region. Similarly, if you have a word that you would like to spell using the NATO phonetic alphabet, you can use M-x nato-region. To convert it back, you need to use M-x denato-region. For example, the text ‘abc’ gets converted to:

Alfa-Bravo-Charlie

Snake

The Snake game can be started using M-x snake. You can use the arrow keys to move the head. As you play, red boxes appear in the window. If you go over them, the length of the snake increases along with the score. At the end of the game, a summary of the scores is shown. A screenshot of the Snake game:

Snake

Dunnet

Dunnet is a text based adventure game that needs to be started in batch mode as shown below:

$ emacs -batch -l dunnet

Dead end
You are at a dead end of a dirt road.  The road goes to the east.
In the distance you can see that it will eventually fork off.  The
trees here are very tall royal palms, and they are spaced equidistant
from each other.
There is a shovel here.

The help command gives you the context of the game:

>help
Welcome to dunnet (2.01), by Ron Schnell (ronnie@driver-aces.com).
Here is some useful information (read carefully because there are one
or more clues in here):
- If you have a key that can open a door, you do not need to explicitly
  open it.  You may just use 'in' or walk in the direction of the door.

- If you have a lamp, it is always lit.

- You will not get any points until you manage to get treasures to a certain
  place.  Simply finding the treasures is not good enough.  There is more
  than one way to get a treasure to the special place.  It is also
  important that the objects get to the special place *unharmed* and
  *untarnished*.  You can tell if you have successfully transported the
  object by looking at your score, as it changes immediately.  Note that
  an object can become harmed even after you have received points for it.
  If this happens, your score will decrease, and in many cases you can never
  get credit for it again.

- You can save your game with the 'save' command, and use restore it
  with the 'restore' command.

- There are no limits on lengths of object names.

- Directions are: north,south,east,west,northeast,southeast,northwest,
                  southwest,up,down,in,out.

- These can be abbreviated: n,s,e,w,ne,se,nw,sw,u,d,in,out.

- If you go down a hole in the floor without an aid such as a ladder,
  you probably won't be able to get back up the way you came, if at all.

- To run this game in batch mode (no Emacs window), use:
     emacs -batch -l dunnet
NOTE: This game *should* be run in batch mode!

If you have questions or comments, please contact ronnie@driver-aces.com
My home page is http://www.driver-aces.com/ronnie.html

You can then give directions and proceed with the game. An example of a session is shown below:

>n
You can't go that way.
>s
You can't go that way.
>e
E/W Dirt road
You are on the continuation of a dirt road.  There are more trees on
both sides of you.  The road continues to the east and west.
There is a large boulder here.
>in
You can't go that way.
>w
Dead end
There is a shovel here.
>d
You can't go that way.
>e
E/W Dirt road
There is a large boulder here.
>n s e
You can't go that way.
>in
You can't go that way.
>e
Fork
You are at a fork of two passages, one to the northeast, and one to the
southeast.  The ground here seems very soft. You can also go back west.
>w
E/W Dirt road
There is a large boulder here.

You can exit the game by typing ‘quit’ at the prompt (>).

Gomoku

Gomoku is a strategy board game where you need to get five pieces in a row (any direction) to win. You and the computer will take turns to play the game. You need to use the Enter key to mark your cross in a position, and the computer will mark its position with a circle. The game ends when either player gets five continuous pieces. A screenshot of Gomoku is shown below:

Gomoku

Le Solitaire

Le Solitaire is a strategy game that consists of stones represented by ‘o’ and holes represented by ’.’ (a dot). The objective of the game is to remove all the stones except the last one. You can jump over another stone to create a hole. You can use the Shift key with the arrow keys to move a stone. A screenshot of the game in progress:

Le Solitaire

All the games and examples were tried on GNU Emacs 24.5.1.

September 06, 2016 04:30 PM

Trishna Guha

Run Apache on Fedora Atomic Host

This post describes how to run Apache on Atomic host. I am using Fedora atomic host.

Boot up an atomic instance (Fedora preferred).

To test the Apache container, just run

atomic run docker.io/fedora/apache

Make sure you are using

sudo

After the container has started successfully, Now do

curl http://localhost:80

This will display

Apache

Now If you want to build your own image copy the source https://github.com/fedora-cloud/Fedora-Dockerfiles/tree/master/apache down to your host. 

Then Edit the Dockerfile and make your changes.

Now Build the image:

# docker build --rm -t /httpd .

After the build is successful, Run the container:

# docker run -d -p 80:80 /httpd #To assign port 80 of your host that maps to port 80 on the container
# docker run -d -p 80 /httpd #To assign random port that maps to port 80 on the container

If you do curl http://localhost you will see the required output.

Screenshot from 2016-09-06 10-55-07

Screenshot from 2016-09-06 10-58-21


by Trishna Guha at September 06, 2016 08:30 AM

September 04, 2016

Anwesha Das

Introducing PyLadies in Ericsson India Global Services Pvt Ltd

PyLadies is all about loving to code in Python. So to built the community we should have the people who uses Python for their jobs. In the rebooting phase of PyLadies Pune we decided that we should built the nexus with those people.

Keeping that in mind, I started contacting to local I.T companies. Tried to get in touch with them. Tried to get to know if they are using Python for their projects. Whether they want to introduce Python to their employees? Ericsson India Global Services Pvt Ltd was a Company who responded to it. They asked us whether we can hold a promotion kind of event at their office. Bidyut kumar Mitra, Head - Cloud & Analytics wanted us to give an introductory session on PyLadies and Python. Along with some basic ideas about Open Source and FOSS.

On 26th August, we had the PyLadies event at the office of the Ericsson India Global Services Pvt Ltd. We were quite happy to see that there were a good number of women employees present. As per their requirements we had set the schedule for the meet up.

Rupali started the session with an initial introduction to community. She gave an nice and useful introduction to what a community is and how does it work. She emphasized on contribution and giving back to the community. She had actually shared some incidents and her experiences on how she has started the community initiative at Red Hat. She suggested people to join other meetups, events that keeps happening in the Red Hat office every weekend. She also talked about PyLadies and its rebooting phase. Her talk had set the tone for the event in true sense. Personally I was very happy to have her in this event. She is one of the major backbone of the Pune Chapter of PyLadies. She stays in background, but provides all the infrastructures for holding the meetups. I am sincerely thankful to her and Red Hat for supporting PyLadies to grow.

The next was my talk on "The World of PyLadies". I stressed on the point that what do we do in our PyLadies meet up. Most of them were unaware of Python, Open Source, FOSS. So I re framed my talk. I initiated my talk with the basic philosophy of Open Source, FOSS, community and then Python. I gave them an quick overview of PyLadies, the organization its history and values. I explained them what do we do in the meet ups. I said that we learn some new Python API in the first half and with those newly learned skills we code in the second half. I informed them about next meet up venue and date.

Then Kushal took a Python workshop. Kushal started his talk with FSF, and PSF. Then he showed some basic Python syntax. He is emphasized on the point that how Python is an easy language to write and how it makes the life of the developers easy. To establish this by showing the same code in different programming languages. He showed some real life examples, some common interview problems( the girls got really excited about this).

After that there was the QA session and the most interactive session indeed. In this session there where several questions where asked like :

  1. Open source vs closed source?
  2. Advantages of Open Source.
  3. Why is it beneficial to the organisation?
  4. Why should employees learn to contribute in open source?
  5. How you can engage more women to technology via open source?
  6. How does open source community function?
  7. How to join?

The session ended with hope and happy note.

by Anwesha Das at September 04, 2016 02:29 PM

August 24, 2016

Sayan Chowdhury

Autocloud: What's new?

Autocloud was released during the Fedora 23 cycle as a part of the Two Week Atomic Process.

Previously, it used to listen to fedmsg for successful Koji builds. Whenever, there is a new message the AutocloudConsumer queues these message for processing. The Autocloud job service then listens to the queue, downloads the images and runs the tests using Tunir. A more detailed post about it’s release can be read here.

During the Fedora 24 cycle things changed. There was a change on how the Fedora composes are built. Thanks to adamw for writing a detailed blogpost on what, why and how things changed.

With this change now autocloud listens to the compose builds over the fedmsg. The topic being “org.fedoraproject.prod.pungi.compose.status.change”. It checks for the messages with the status FINISHED and FINISHED_INCOMPLETE.

After the filtration, it gets the Cloud Images built during that particular compose using a tool called fedfind. The job here is parse the metadata of the compose and getting the Cloud Images. These images are then queued into both libvirt and vbox boxes. The Autocloud job service then downloads the images and run the tests using Tunir.

Changes in the Autocloud fedmsg messages.

Earlier the messages with the following topics were sent

Now along with the fedmsg message for the status of the image test. Autocloud also sends messages for the status of a particular compose.

The compose_id field was added to the autocloud.image.* messages

Changes in the UI

  • A page was added to list all the composes. It gives an overview of the composes like if it’s still running, number of tests passed, etc
  • The jobs page lists all the tests data as earlier. We added filtering to the page so filter the jobs based on various params
  • You need to agree that the jobs output page looks better than before. Now, rather the showing a big dump of text the output now is properly formatted. You can now reference each line separately.

Right now, we are planning to work on testing the images uploaded via fedimg in Autocloud. If the project looks interesting and you are planning to contribute? Ping us on #fedora-apps on Freenode.

August 24, 2016 11:58 AM

August 20, 2016

Sayan Chowdhury

Fedora Meetup Pune August 2016

Fedora Pune Meetup for the month of August 2016 happened today at our usual location. We had in total 12 people turning out for the meetup.

The event started with introductions and we had two new comers joining us this time, Trishna and Prathamesh.

This time the event was mostly foccused around re-writing the GNU C Library Manual using reStructuredText and Sphinx. This task was decided during the release event that we had last month. We did create a Etherpad link to maintain the status of the task1.

The aim is to build a modern version, good looking version of the GNU C Library Manual.

In today’s meetup, we sat down and tried completing the chapters we picked. A couple of us sent a PRs to the docs repo that we are maintaing in Github. The generated read the docs can be seen here

If you are planning to contribute, ping /me (sayan) or kushal in #dgplug channel on Freenode.

August 20, 2016 04:22 PM

Farhaan Bukhsh

GSoC: Final Submission

This summer has been really amazing, I learnt a lot and worked crazy hours it has been a crazy yet amazing ride. I am not going to stop working on open source projects and with Pagure it is something really close to my heart.

There are a few things left but I can conclude that I am able to achieve what I wanted to at the beginning of this program , but there is never a feeling of satisfaction it is just like you want to achieve the best possible and most beautiful solution.

Pagure has CI integration which was one of my major goals to achieve and with the coming release it will be out and will be usable to people. This gives me immense pleasure to say that the foundation of CI was laid by me although Pingou kind of wrote a lot after that but that helped me to learn the depth of thinking one needs to have when you are working on a feature like this. Selection_027

I also worked on Private Repo feature which took more time than expected and it was pretty challenging to achieve , this feature is in  feature branch and it may get merged after it is checked in the staging first. Selection_028

It was so challenging that I got stuck on a data fetching problem from the database , we use Sqlalchemy as ORM in Pagure. I went through a lot of ups and downs at times I was about to give up but then I get some small part of it and Pingou has been so amazing mentor he never spoon fed me instead he asked the right question the moment he ask something the idea bulb use to glow.

I still remember struggling with  Xapian and Whoosh. This was again a very big task and still is , it requires a lot of time to optimize it to a level where it doesn’t slow the site. I gave a lot of time on it but since I few other goals and various issue to solve so I eventually moved on to those just to come back.

Pagure pages is one of the last goals that I worked on recently and there are discussion pending over it.

At a glance I was able to achieve a lot of the big goals on my proposal and still work has to be done, and I will continue to work on achieving various other goals. Few links that I want to share :

Commits made to the master branch

Commits on private-repo branch on pagure 

Pull-request for static page hosting

This kinds of makes me feel happy that I have around 102 commits on the master branch now and I believing I will be working a lot more on Pagure to bring a lot of cool and useful feature to it. In case you have any suggestion feel free to file issues on Pagure.

To be really frank I am not at all sad that GSoC is getting because I have received so much love and inspiration from Fedora Community that contributing to projects has actually become my daily routine the day I don’t commit code, review patches or comment on issues I start feeling something is missing .

And some of my fellow GSoCers said That’s all folks!  ;)

Happy Hacking!

 


by fardroid23 at August 20, 2016 03:35 PM

August 08, 2016

Farhaan Bukhsh

Docs in Pagure

I took this week to hack on this feature called Docs which gives you the ability to host documentation of your project in Pagure. I have never explored this feature before so I started to hack on it .

This feature is pretty straight forward to use. Once you have your project up and running you can go to Setting of the project and under  Project Option  click on Activate Documentation this will actually activate a Doc tab in the main project. This can be used to host your docs specifically now this is a little tricky because you need to clone and push to a different URL, the docs are maintain in a separate location this is due to security concerns. When you activate the Project option you are provided with a Doc specific URL, you need to push your document or static pages to that URL and automatically any page named as index will be taken as the first page.

Selection_026

You have to click on the more button beside GIT URLs to get your Docs URL and then you are good to go to host your static page.

For people who want to hack on Docs in Pagure you need to pull a few tricks to do that.

First and foremost is you need to get the code from pagure.io and then after setting up Pagure for development, you need to run two servers :

  1. Pagure server
  2. Doc server

The script corresponding to them are  runserver and rundocserver.

So if you have ever hacked on Pagure then you will know that you have to log in make repo  and follow the same steps mentioned above to see the Doc tab.

Under pagure/default_conf.py a new conf key has to be added which is

DOC_APP_URL = 'https://localhost:5001'

This tells Pagure that this instance supports Doc.

Now comes the tricky part, if you need to see Doc there should be a <project_name>.git created in the docs repo which is not there you just need to copy the file from repo directory to docs. Once this is done you need to clone the project repo from docs delete all the files there put the files you want in the static page , we support a lot of formats like md, rst etc. Add, commit and push and voila you will see them in your local instance.

I am actually working on issue 469 in which Ryan has suggested to make docs more specific to static page  hosting with the architecture that docs is based on this is actually a straight forward task but a really beautiful one which need a bit of deliberation on things we want to achieve.  Hope it gave you insight in what I am trying to to do.

More documentation on this can be found in the usage section of Pagure Docs.

Happy Hacking!🙂


by fardroid23 at August 08, 2016 05:20 AM

July 30, 2016

Suraj Deshmukh

Kubernetes: HorizontalPodAutoScaler and Job

To try out following demos setup your environment as mentioned in here.

Git clone the demos repo:

git clone https://github.com/surajssd/k8s_demos/
cd k8s_demos/

Horizontal Pod Autoscaler

Once you have all the setup done follow the video for demo instructions

Job

Once you have all the setup done follow the video for demo instructions


by surajssd009005 at July 30, 2016 11:53 AM

July 20, 2016

Suraj Deshmukh

Run aircrack-ng without external “wifi card” [UPDATED]

Note: This is updated version of my previous blog, which goes by the similar title.

home-kali-slider-1
I wanted to use pentesting tools provided in Kali-Linux. I use a Fedora machine as my primary desktop, I can install some of those tools locally, but then I wanted to keep these things separate. So I use Kali Linux in a VM. It was all good, until the point when I was not able to run wireless pentesting tools from VM.

kvmnet_580

This is because VM does not get direct access to the host’s wifi card. The way it works VMs get connected to a bridge setup by your hypervisor via ethernet interface. So VM never deals with how the host is connected to outside world, be it wired or wireless connection.

The VM can get a wireless interface using USB connected wifi device. But then you need to have one to utilize it. To get around this problem, and use your host machine’s interface, we can use containers. Containers give you isolation similar to VM(not exactly) and since container is again a process mapped onto your operating system it has access to everything on your machine(if run in privileged mode) and container can also see the host’s network stack if run with specific flag(--net="host").

So lets get started

Install docker for your system:

Engine

Create Dockerfile which looks like this:

$ cat Dockerfile

FROM kalilinux/kali-linux-docker

RUN apt-get -y update && \
apt-get -y upgrade && \
apt-get install -y aircrack-ng pciutils

Here we are using official kali-linux docker image, then installing tools required.

Create a docker image using above Dockerfile

$ docker build -t mykali .

Now that you have all the bits required to get started, spin up the container:

$ docker run -it --net="host" --privileged --name aircrack mykali bash
root@user:/#

Once inside the container, identify your wireless interface:

# ip a
[SNIP]
3: wlp9s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 40:f0:2f:57:3d:37 brd ff:ff:ff:ff:ff:ff
inet 10.9.68.109/23 brd 10.9.69.255 scope global dynamic wlp9s0
valid_lft 1373sec preferred_lft 1373sec
inet6 fe80::bf7e:dc5d:337:131c/64 scope link
valid_lft forever preferred_lft forever
[SNIP]


On my machine it is wlp9s0.
Enable monitor mode on that wireless interface.

# airmon-ng start wlp9s0
Your kernel supports rfkill but you don't have rfkill installed.
To ensure devices are unblocked you must install rfkill.
PHY Interface Driver Chipset

phy0 wlp9s0 ?????? Qualcomm Atheros AR9485 Wireless Network Adapter (rev 01)

(mac80211 monitor mode vif enabled for [phy0]wlp9s0 on [phy0]wlp9s0mon)
(mac80211 station mode vif disabled for [phy0]wlp9s0)

Observe the new interface created wlp9s0mon

# ip a
[SNIP]
9: wlp9s0mon: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN group default qlen 1000
link/ieee802.11/radiotap 40:f0:2f:57:3d:37 brd ff:ff:ff:ff:ff:ff

Start capturing raw 802.11 frames on the newly created interface running on monitor mode:

# airodump-ng wlp9s0mon

Let this process continue to run here.

Start another terminal window, we need another bash instance in container

$ docker exec -it aircrack bash
root@dhcp35-70:/#

Now that you have everything setup, start doing stuff here, in this terminal window. If you wanted more softwares in the container, edit Dockerfile above and create image accordingly.

To stop the monitoring mode:

# airmon-ng stop wlp9s0mon
Your kernel supports rfkill but you don't have rfkill installed.
To ensure devices are unblocked you must install rfkill.

PHY Interface Driver Chipset

phy0 wlp9s0mon ?????? Qualcomm Atheros AR9485 Wireless Network Adapter (rev 01)

(mac80211 station mode vif enabled on [phy0]wlp9s0)

(mac80211 monitor mode vif disabled for [phy0]wlp9s0mon)

And, finally, since wireless interface was put to monitoring mode we should stop monitoring before we exit continer. Doing this is important because the Guest OS will not get access to wireless card unless monitoring process by Docker container is not stopped. Now the interface wlp9s0 has appeared back, because airmon-ng was stopped.

# ip a
[SNIP]
8: wlp9s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 40:f0:2f:57:3d:37 brd ff:ff:ff:ff:ff:ff
inet 10.9.68.109/23 brd 10.9.69.255 scope global dynamic wlp9s0
valid_lft 3581sec preferred_lft 3581sec
inet6 fe80::bf7e:dc5d:337:131c/64 scope link
valid_lft forever preferred_lft forever

Please comment if any doubts.

Ref:


by surajssd009005 at July 20, 2016 06:02 PM

July 07, 2016

Praveen Kumar

Vagrant DNS with Landrush and Virtualbox and dnsmasq

Landrush is pretty neat vagrant plugin if you need a DNS server which is visible to host and guest. For Mac OS it work out of the box but to make it work in Linux we have to make some configuration changes to dnsmasq.

I assume that you are using latest vagrant and Virtualbox for this experiment. If you are using libvirt than please refer to Josef blogpost.

Landrush DNS server runs on port 10053 (localhost) instead of 53 so we have to make entry to redirect requested domain name to our Landrush. Follow below steps and lets configure it.

Install dnsmasq if not present
$ sudo dnf install dnsmasq

Add following to /etc/dnsmasq.conf
listen-address=127.0.0.1

Will create below file which redirect our .vm traffic to Landrush
$ cat /etc/dnsmasq.d/vagrant-landrush
server=/.vm/127.0.0.1#10053

Will start/restart dnsmasq service and check status (should be active)
$ sudo systemctl start dnsmasq.service
$ sudo systemctl status dnsmasq.service
● dnsmasq.service - DNS caching server.
Loaded: loaded (/usr/lib/systemd/system/dnsmasq.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2015-12-24 11:57:47 IST; 2s ago
Main PID: 19969 (dnsmasq)
CGroup: /system.slice/dnsmasq.service
└─19969 /usr/sbin/dnsmasq -k
Dec 24 11:57:47 dhcp193-61.pnq.redhat.com systemd[1]: Started DNS caching server..
Dec 24 11:57:47 dhcp193-61.pnq.redhat.com systemd[1]: Starting DNS caching server....
Dec 24 11:57:47 dhcp193-61.pnq.redhat.com dnsmasq[19969]: started, version 2.75 cachesize 150
Dec 24 11:57:47 dhcp193-61.pnq.redhat.com dnsmasq[19969]: compile time options: IPv6 GNU-getopt DBus no-i18n IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth DNSSEC ...ct inotify
Dec 24 11:57:47 dhcp193-61.pnq.redhat.com dnsmasq[19969]: using nameserver 127.0.0.1#10053 for domain vm
Dec 24 11:57:47 dhcp193-61.pnq.redhat.com dnsmasq[19969]: reading /etc/resolv.conf
Dec 24 11:57:47 dhcp193-61.pnq.redhat.com dnsmasq[19969]: using nameserver 127.0.0.1#10053 for domain vm
Dec 24 11:57:47 dhcp193-61.pnq.redhat.com dnsmasq[19969]: using nameserver 10.75.5.25#53
Dec 24 11:57:47 dhcp193-61.pnq.redhat.com dnsmasq[19969]: using nameserver 10.68.5.26#53
Dec 24 11:57:47 dhcp193-61.pnq.redhat.com dnsmasq[19969]: read /etc/hosts - 2 addresses
Hint: Some lines were ellipsized, use -l to show in full.


Make sure you put '127.0.0.1' as nameserver to /etc/resolve.conf at first place.
$ cat /etc/resolv.conf
nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 4.4.4.4

Make following change to your vagrant file
$cat Vagrantfile
PUBLIC_ADDRESS=10.1.2.2
PUBLIC_HOST= "your_host.vm"
config.vm.network "private_network", ip: "#{PUBLIC_ADDRESS}"
config.vm.hostname = "#{PUBLIC_HOST}"
config.landrush.enabled = true
config.landrush.host_ip_address = "#{PUBLIC_ADDRESS}"
config.landrush.tld = ".vm"
confg.landrush.guest_redirect_dns = false

$ vagrant landrush ls
your_host.vm 10.1.2.2
2.2.1.10.in-addr.arpa your_host.vm

$ sudo netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:17500 0.0.0.0:* LISTEN 2946/dropbox
tcp 0 0 10.65.193.61:44319 0.0.0.0:* LISTEN 14810/weechat-curse
tcp 0 0 127.0.0.1:17600 0.0.0.0:* LISTEN 2946/dropbox
tcp 0 0 127.0.0.1:45186 0.0.0.0:* LISTEN 433/GoogleTalkPlugi
tcp 0 0 127.0.0.1:39715 0.0.0.0:* LISTEN 433/GoogleTalkPlugi
tcp 0 0 127.0.0.1:17603 0.0.0.0:* LISTEN 2946/dropbox
tcp 0 0 0.0.0.0:10053 0.0.0.0:* LISTEN 14966/ruby-mri
tcp 0 0 127.0.0.1:2222 0.0.0.0:* LISTEN 15200/VBoxHeadless
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 16871/dnsmasq
tcp 0 0 192.168.121.1:53 0.0.0.0:* LISTEN 16817/dnsmasq
tcp 0 0 192.168.124.1:53 0.0.0.0:* LISTEN 16810/dnsmasq
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2647/cupsd
tcp6 0 0 ::1:631 :::* LISTEN 2647/cupsd

$ ping your_host.vm
PING your_host.vm (10.1.2.2) 56(84) bytes of data.
64 bytes from 10.1.2.2: icmp_seq=1 ttl=64 time=0.332 ms
64 bytes from 10.1.2.2: icmp_seq=2 ttl=64 time=0.238 ms


by Praveen Kumar (noreply@blogger.com) at July 07, 2016 12:10 PM