Miro Hrončok2023-09-04T13:28:33+00:00http://eng.hroncok.czMiro Hrončokmiro@hroncok.czIPython-like RPM Lua interactive console2020-05-14T00:00:00+00:00http://eng.hroncok.cz/2020/05/14/ilua-rpm-console
<p>Recently, I’ve found myself in a position of writing and debugging some Lua based RPM macros and generators:</p>
<ul>
<li><a href="https://github.com/rpm-software-management/rpm/pull/1153">speeding up python(abi) dependency generator by rewriting it from Bash to parametric Lua macro</a></li>
<li><a href="https://src.fedoraproject.org/rpms/python-rpm-generators/pull-request/7">adding automated provides to replace most of the manual %python_provide calls</a></li>
<li><a href="https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/52">reimplementing %python_provide from scratch as %py_provides</a></li>
</ul>
<p>The capabilities of the <a href="https://rpm.org/user_doc/lua.html">embedded Lua interpreter in RPM</a> are endless. My Lua skills are not. I need to test the code in small chunks to understand what am I doing.</p>
<p><img src="https://i.kym-cdn.com/entries/icons/original/000/008/342/ihave.jpg" alt="meme" /></p>
<p>When I need to do this in Python, I use the <a href="https://ipython.org/">IPython</a> console (my second favorite software in the Python ecosystem after <a href="https://docs.pytest.org/">pytest</a>).</p>
<p><img src="/assets/2020-05-14-ilua-rpm-console/ipython.png" alt="IPython console" /></p>
<p>For Lua, I’ve used the <code class="language-plaintext highlighter-rouge">lua</code> command for a while. It lets me test basic Lua concepts in an interactive console, but it’s not that powerful as the IPython console and it lacks the RPM provided Lua libraries.</p>
<p><img src="/assets/2020-05-14-ilua-rpm-console/lua.png" alt="Basic Lua console" /></p>
<p>I’ve asked Panu (my colleague and an RPM developer I work with when submitting changes to the RPM project) whether there is an interactive console for the Lua interpreter embedded in RPM <a href="https://github.com/rpm-software-management/rpm/pull/1153#discussion_r401514078">and the answer was yes</a>. I can use <code class="language-plaintext highlighter-rouge">rpm --eval "%{lua:rpm.interactive()}"</code>. But it has some quirks.</p>
<p><img src="/assets/2020-05-14-ilua-rpm-console/rpm-interactive.png" alt="Basic RPM Lua interactive shell" /></p>
<p>Mostly, there is no command history or even line editing, and <a href="https://github.com/rpm-software-management/rpm/issues/1215">the output is hard to get</a>.</p>
<h2 id="ilua">ILua</h2>
<p>Naturally, I’ve searched for an IPython like Lua console and I’ve found the <a href="https://github.com/jupyter/jupyter/wiki/Jupyter-kernels">list of Jupyter Kerneles</a> (IPython console is a frontend to <a href="https://jupyter.org/">Jupyter</a>). There are 3 Lua kernels there:</p>
<ul>
<li><a href="https://github.com/neomantra/lua_ipython_kernel">Lua Kernel</a> (discontinued)</li>
<li><a href="https://github.com/pakozm/IPyLua">IPyLua</a> (a fork of the above, not much active either)</li>
<li><a href="https://github.com/guysv/ilua">ILua</a></li>
</ul>
<p>ILua intrigued me mostly because it says right away: <em>“Lua-implementation agnostic, should work with any Lua interpreter out of the box.”</em> That’s exactly what I need. Maybe I can use it with <code class="language-plaintext highlighter-rouge">rpm --eval "%{lua:rpm.interactive()}"</code>.</p>
<p>Turns out I can, <a href="https://github.com/guysv/ilua/issues/10">but it’s not that simple</a>. The used Lua interpreter needs to respect the <code class="language-plaintext highlighter-rouge">$LUA_PATH</code> environment variable and execute the file given to it as a command-line argument. Naturally, the simplistic <code class="language-plaintext highlighter-rouge">rpm --eval "%{lua:rpm.interactive()}"</code> does neither.</p>
<p>So I’ve created a wrapper:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/usr/bin/bash</span>
<span class="nb">exec </span>rpm <span class="nt">--eval</span> <span class="s1">'%{lua:package.path = "'</span><span class="k">${</span><span class="nv">LUA_PATH</span><span class="k">}</span><span class="s1">';" .. package.path;'</span><span class="s2">"</span><span class="si">$(</span><span class="nb">cat</span> <span class="s2">"</span><span class="nv">$@</span><span class="s2">"</span><span class="si">)</span><span class="s2">"</span><span class="s1">';rpm.interactive()}'</span>
</code></pre></div></div>
<p>And it mostly worked. Except for the <a href="https://github.com/rpm-software-management/rpm/issues/1215">slight problem with missing print output</a>. (The executed ILua script does the interactivity, so I’ve removed the <code class="language-plaintext highlighter-rouge">rpm.interactive()</code> call at the end.)</p>
<p><img src="/assets/2020-05-14-ilua-rpm-console/bash-wrapper.png" alt="ILua using a Bash wrapper over RPM Lua" /></p>
<p>I’ve tried to figure out how to launch the RPM Lua interpreter, not in the RPM macro expansion mode (that thing eats all the print output until the end). I’ve done a little RPM symbols lookup and source reading and figured out there is an <code class="language-plaintext highlighter-rouge">rpmluaRunScript()</code> function in <code class="language-plaintext highlighter-rouge">librpmio</code>. So I’ve tried to use it:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">#!/usr/bin/python3
</span><span class="kn">from</span> <span class="nn">ctypes</span> <span class="kn">import</span> <span class="n">cdll</span><span class="p">,</span> <span class="n">c_char_p</span>
<span class="n">librpmio</span> <span class="o">=</span> <span class="n">cdll</span><span class="p">.</span><span class="n">LoadLibrary</span><span class="p">(</span><span class="s">"librpmio.so.9"</span><span class="p">)</span>
<span class="n">librpmio</span><span class="p">.</span><span class="n">rpmluaRunScript</span><span class="p">(</span><span class="bp">None</span><span class="p">,</span> <span class="n">c_char_p</span><span class="p">(</span><span class="sa">b</span><span class="s">"rpm.interactive()"</span><span class="p">),</span> <span class="bp">None</span><span class="p">)</span>
</code></pre></div></div>
<p>It works. A little tweaking to support ILua as well as other use cases:</p>
<script src="https://gist.github.com/63c36381e2daa12446cb70c1a30bef2e.js"> </script>
<p>Note by Panu: <em><code class="language-plaintext highlighter-rouge">rpmluaRunScript()</code> and <code class="language-plaintext highlighter-rouge">rpmluaRunScriptFile()</code> are not considered public API and are not available in the public headers on C side, although the symbols are accessible in the ABI. So they are subject to change without further notice, although the likelihood of that happening doesn’t seem that great, they’ve been exactly the way are since their inception 16 years ago.</em></p>
<p>To use this, put the script on your <code class="language-plaintext highlighter-rouge">$PATH</code> and invoke <code class="language-plaintext highlighter-rouge">ilua -i <name_of_the_script></code>.</p>
<p>And now I have an interactive IPython-like shell for RPM embedded Lua with command history, line editing, completion and more:</p>
<p><img src="/assets/2020-05-14-ilua-rpm-console/irpmlua.png" alt="ILua using a Python ctypes wrapper over RPM Lua" /></p>
<p>Enjoy! PS: ILua is on <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1834280">package review for Fedora</a>, but can be safely pip-installed in the meantime.</p>
<hr />
<h2 id="update-from-2022">Update from 2022</h2>
<p>On RPM 4.18, the script above does not work, but you can use this instead:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/usr/bin/sh -eu</span>
/usr/bin/rpmlua <span class="nt">-e</span> <span class="s1">'package.path = os.getenv("LUA_PATH") .. ";" .. package.path'</span> <span class="s2">"</span><span class="nv">$@</span><span class="s2">"</span>
</code></pre></div></div>
Python tests on virtual Mac OS X with Vagrant and py.test2016-03-28T00:00:00+00:00http://eng.hroncok.cz/2016/03/28/pytest-mac
<h2 id="why-to-run-tests-on-mac">Why to run tests on Mac?</h2>
<p>Although I am a proud Fedora user, I write my Python projects and I want them to run on multiple
operating systems including Mac OS X. While there are already options available to <a href="https://docs.travis-ci.com/user/multi-os/#Python-example-(unsupported-languages)">run the tests on
Mac OS X in Trvais CI</a>
or similar tool, I sometimes like to run my tests locally. If you like to do the same, read further.</p>
<h2 id="getting-mac-os-x">Getting Mac OS X</h2>
<p>In the past, I’ve managed to manually install some hacked version of Mac OS X Mavericks into
VirtualBox and SSH into it from my Fedora host. I’ve used that virtual machine a lot to test my projects.
However, the way of installing it was not very straight-forward. Recently
<a href="https://twitter.com/syky27">@Syky27</a> showed me that I can set up a virtual Mac OS X using Vagrant,
in an automated fashion.</p>
<p>First you’ll need <a href="https://www.vagrantup.com/">Vagrant</a>. On Fedora, you can use the one packaged in
the distribution and just do <code class="language-plaintext highlighter-rouge">dnf install vagrant</code>. I’ve used VirtualBox provider for it, because
I think that it won’t work with libvirt, the default Vagrant provider in Fedora. In fact I didn’t
even bother trying, so in case you’ll try it and it works, let me know. To get VirtualBox on Fedora,
I recommend the <a href="http://rpmfusion.org/">RPM Fusion repository</a>. You’ll also need the Oracle VM VirtualBox Extension Pack.
I will not go into details, as I’m
quite confident you are capable of installing VirtualBox yourselves :)</p>
<p>Once you have both Vagrant and VirtualBox, create an empty folder somewhere where you can find it.
In that folder, run the following:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>vagrant init jhcook/osx-elcapitan-10.11
</code></pre></div></div>
<p>This will simply fetch a <code class="language-plaintext highlighter-rouge">Vagrantfile</code>. It is quite fast. Once done, run:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>vagrant up --provider virtualbox
</code></pre></div></div>
<p>For the first time this will download the image of Mac OS X and boot it. For next time, it will
simply start the virtual machine. The download may take a few hours.</p>
<p>Once your machine is up and running, you can SSH into it with <code class="language-plaintext highlighter-rouge">vagrant ssh</code> (from the same folder).</p>
<h2 id="installing-python">Installing Python</h2>
<p>There might be multiple ways of installing recent Python version into your virtual Mac, but for me,
using Homebrew was the best shot. First, get <a href="http://brew.sh/">Homebrew</a>, that allows you to install
Python as easily as this:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew install python3
</code></pre></div></div>
<p>(Now you’ve noticed I use Python 3. If you want to use legacy Python, also install it from Homebrew,
don’t use the built-in one that it shipped with Mac OS X, it might not work.)</p>
<p>At this point, you should be able to use <code class="language-plaintext highlighter-rouge">python3</code>, <code class="language-plaintext highlighter-rouge">pip3</code> and <code class="language-plaintext highlighter-rouge">pyvenv</code> commands. In case you need
some dependencies, feel free to install them with <code class="language-plaintext highlighter-rouge">pip3 install --user foo</code>. In case you’ll use this
for multiple projects, it might be a good idea to put stuff into virtualenvs:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pyvenv myenv
. myenv/bin/activate
pip install foo
</code></pre></div></div>
<p><strong>Note:</strong> You don’t need py.test to be present on the Mac.</p>
<h2 id="running-your-tests-on-mac-from-your-linux-without-pain">Running your tests on Mac, from your Linux, without pain</h2>
<p>In order to be able to SSH to your virtual Mac from anywhere, we ask Vagrant for the SSH config (we are back on our main system now):</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>vagrant ssh-config | awk '{print " "$1" "$2}'
</code></pre></div></div>
<p>Put that into your <code class="language-plaintext highlighter-rouge">~/.ssh/config</code>, it will look similar to this:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Host mac
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile "/home/username/.vagrant.d/insecure_private_key"
IdentitiesOnly yes
LogLevel FATAL
</code></pre></div></div>
<p>Don’t forget the first line. You can test your connection by using <code class="language-plaintext highlighter-rouge">ssh mac</code> from any PWD.</p>
<p>Now you’ll need to grab an excellent plugin for py.test, <a href="https://pypi.python.org/pypi/pytest-xdist">pytest-xdist</a>
that lets you execute your tests remotely over SSH (among plenty other things).</p>
<p>From your project directory, execute your tests with py.test as you would normally do, with some extra options:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>py.test-3 -d --tx 'ssh=mac//python=/usr/local/bin/python3' --rsyncdir modname modname
</code></pre></div></div>
<p><em>modname</em> here is your main module directory you want to sync to Mac in order to run your tests.
In case your tests are not inside that directory, add them as well (as well as any other directories you need):</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>py.test-3 -d --tx 'ssh=mac//python=/usr/local/bin/python3' --rsyncdir modname modname --rsyncdir test test
</code></pre></div></div>
<p>In case you want to use your virtualenv, modify the command a bit:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>py.test-3 -d --tx 'ssh=mac//python=myenv/bin/python' ...
</code></pre></div></div>
<p>Now you should be able to see your testsuite running on Mac.</p>
<p>To stop the running virtual machine, execute either <code class="language-plaintext highlighter-rouge">vagrant suspend</code> or <code class="language-plaintext highlighter-rouge">vagrant halt</code> from the folder where you started it.</p>
<h2 id="next-steps">Next steps?</h2>
<p>This is very raw how-to of something I just managed to do. I might look into automating this somehow.
Also, it might be a great idea to combine this with another great py.test plugin, <a href="http://testmon.org/">testom</a>.</p>
PyCon CZ 2015 and Fedora booth2016-01-18T00:00:00+00:00http://eng.hroncok.cz/2016/01/18/pycon-cz-2015
<p>In November, we’ve been to <a href="https://cz.pycon.org/2015/">PyCon CZ 2015</a>. And when I say <em>we</em> I mean Fedora Python maint and friends team: Matěj Stuchlík, Robert Kuska, Slávek Kabrda, Michal Cyprian, Michal Srb and me.</p>
<p>PyCon CZ 2015 was the first PyCon in the Czech Republic. With Fedora being very Python friendly and with our “Python 3 as Default” feature, we thought we had to be there to represent Fedora. We actually did that in 2 ways:</p>
<h2 id="saturday-booth">Saturday: Booth</h2>
<p>We had a standard blue Fedora booth with stickers, DVDs, 3D printer and (which was a bit of an experiment) blue soft drinks.</p>
<p><img src="https://fedoraproject.org/w/uploads/7/79/PyConCZ_1.jpg" alt="Fedora booth at PyCon CZ 2015" /></p>
<p>The blue drinks were quite an attraction, but we had <em>a lot</em> of them and we were unsure whether people would drink them all, so we stepped up and started delivering the drinks to presentation rooms. We were distributing them during breaks and we were telling people that they’re a gift from Fedora community - the responses were great and it attracted even more people to our booth. We almost run out of the drinks on Saturday and only a few bottles remained for Sunday workshop sessions. See the cases behind Slávek, our “Python 3 terrorist”, as some call him:</p>
<p><img src="https://fedoraproject.org/w/uploads/4/46/PyConCZ_2.jpg" alt="Fedora booth at PyCon CZ 2015" /></p>
<p>If you observe the photo carefully, you might find some new Fedora Loves Python stickers we’ve designed for this event (we still have plenty more for upcoming events).</p>
<h2 id="sunday-python-3-porting-sprint">Sunday: Python 3 porting sprint</h2>
<p>On Sunday, the sprints took place at a different venue and there was no room for booth, so we changed our tactics and organized a sprint instead.
<a href="https://fedoraproject.org/wiki/FAD_Python_3_Porting_2015">Python 3 Porting FAD</a> was an international Fedora Activity Day focused on porting stuff to Python 3; on PyCon we were there to do our part and to help others join Python 3 porting - either upstream or downstream in Fedora. While the FAD itself was a huge success, we must admit that we expected more PyCon attendants to be interested in our sprint. Lots of poeple visited workshops happening in the same time slot or just chatted with each other (drinking the rest of blue soft drinks). Still, we had a nice chat with several developers interested in Python 3 porting and we managed to get our “Python 3 is <em>the</em> Python” message across to quite a few people. Reactions to that were pretty great, the Python community really does appreciate where Fedora is moving.</p>
<p><em>Written with Slávek’s help.</em></p>
FAD Rheinland 2014: New ideas for outreach2014-12-09T00:00:00+00:00http://eng.hroncok.cz/2014/12/09/fad-rheinland-2014
<p>Last weekend, I’ve attended <a href="https://fedoraproject.org/wiki/FAD_Rheinland_2014">FAD Rheinland 2014</a>, the annual event where Fedora Ambassadors from EMEA meet and discuss the budget for next year, swag ideas and most importantly (at least form my POV), what to do differently to bring more users to Fedora.</p>
<p>Apart form meeting old and new friends, having fun together and discovering a fantastic board/card game called <a href="http://en.wikipedia.org/wiki/The_Saboteur">The Saboteur</a> (go get it now!), there were some ideas I want to share with others.</p>
<p>(I’m writing this on a train from Brno to Prague, so expect a lot of typos.)</p>
<h2 id="focus-on-different-events-bring-non-ambassadors-from-fedora">Focus on different events, bring non-Ambassadors from Fedora</h2>
<p>For years, we’ve been attending events like FOSDEM, LinuxTag and other Linux and free software specific conferences and meet-ups. As Fedora we need to have a booth on such events and we’ll have to continue to be there, to show others Fedora is still here. However, I don’t think (and there were others with the same opinion), that we’ll get any new users to Fedora doing it. Most of the visitors there already have their favorite Linux distro and I don’t think that we can do much on the booth that would convince them change their minds.</p>
<p>Based on Fedora.NEXT target audience (have a look at Christoph’s slides (I’ll add link ASAP)), we’ve agreed that we have to visit other types of events as well. General developer conferences (focusing on some topic, such as Python, Perl, Android, …), maker events (promote 3D printing in Fedora, etc.), barcamps, gaming cons. However, for most of us, this is stepping out of our comfort zone. Most Ambassadors are not experts in those fields. You cannot expect a random Fedora Ambassador to go to a Python dev meet-up in his/hers area and speak about why Fedora is good for Pythonists (well, we have dome ambassadors who could, but not all of them).</p>
<p>So we would like to “reach in” for people who knows their stuff and bring them to events to promote Fedora. The idea is something like:</p>
<ol>
<li>Bob, the Fedora Ambassador, finds out there’s an event related to XYZ topic in his area and thinks we might promote Fedora there.</li>
<li>However, Bob knows nothing (or little) about XYZ, but finds out in Fedora, we have a working group or SIG that focuses on XYZ or related stuff, so Bob writes an e-mail to their mailing list informing about the event and saying he wants a booth personal or speaker. Bob can allocate money to pay for the trip, accommodation and entrance fee if necessary.</li>
<li>Anna is a Fedora contributor, who focuses mainly on XYZ and lives near the area. She would love to go, but she has no idea how to run a booth or how to get sponsored form Fedora. Luckily Bob can help her.</li>
<li>Both Anna and Bob go to the event. Anna can promote XYZ in Fedora, Bob can answer general questions about Fedora Anna might not know the answer.</li>
</ol>
<p>We think this might work well, because a lot of people form inside Fedora would love to go to such events, but does not have money to afford it and has no idea how would Fedora pey for them. The problem might be, how to find out what group form Fedora focuses on XYZ, but Bob can ask on the Ambassadors mailing list for help and some other Ambassadors might know.</p>
<p>Some of my ideas for events in the Czech Republic:</p>
<ul>
<li>3dexpo (3D printing event, we’ve been there, but Vojta on the booth is no expert in 3D printing)</li>
<li>barcamp Brno, Hradec Králové, Ostrava…</li>
<li>aDev Meetup (Android development, promote DevAssistant)</li>
<li>Pyvo (Python meetups, we have Fedorains there, but we don’t promote Fedora)</li>
<li>Model Hobby (a gigantic plastic modellers convention)</li>
</ul>
<h2 id="stop-producing-dvds-and-produce-flyers-instead">Stop producing DVDs and produce flyers instead</h2>
<p>DVDs, at least in Europe, are obsolete. I don’t have a DVD drive. You don’t have it. The users don’t have it. Or at least they won’t, soon. We should stop producing DVDs with Fedora. But we cannot just stop, we need a replacement.</p>
<p>There are visitors on events asking for DVDs. They collect them, or they take them and trash them later. If we say we have no DVDs (as sometimes, we just don’t, because there are no more), they are sad and go grab another DVD (with Ubuntu).</p>
<p>The idea was to produce Fedora USB sticks, but it much more expensive than DVDs. No way of producing so much sticks as we produce DVDs now. I’ve (together with others, including Jaroslav Řezník) had an idea to produce flyers that look like DVD sleeve - so we can put them on the boot and it looks like a DVD. If the cover is hard enough, the visitors might even think they are getting a DVD, unless they look inside. It should be a booklet shaped flyer with the following information:</p>
<ul>
<li>“Where is the DVD” section (describing DVDs are deprecated and are replaced with QR code)</li>
<li>“What is Fedora” section</li>
<li>Fedora products (Workstation, Server, Cloud) descriptions (and now we are not supposed to call this products anymore)</li>
<li>“What’s new in Fedora 22” (23, 24…)</li>
</ul>
<p>And alternatively have some flyers for specific events and have a page about XYZ. The flyers might also be localized.</p>
<p>The problems with flyers is, that they cannot look cheap. Otherwise the visitors might as well get the idea that we are doing this to save money. And we, the Ambassadors, cannot design them, we need the design team to do it. And as I’ve heard, there are open tickets in the design trac for flyers for years without a response :( Last propper flyer we had was Fedora Core 4 (or something like that). We had Fedora Cloud flyers in the recent past, but nobody seems to like them anyway.</p>
<p>I hope that the transfer <a href="https://fedorahosted.org/famsco/ticket/373">from FAmSCo to FOSCo</a> that covers Ambassadors, Design and Marketing will bring us easier cooperation.</p>
<h2 id="more">More…</h2>
<p>There has been more. You can see the <a href="https://titanpad.com/C13BPojw05">raw notes from the event</a> and there should be the meeting minutes, but i cannot find them. And don’t forget to get <a href="http://en.wikipedia.org/wiki/The_Saboteur">The Saboteur</a> :D</p>
State of Python 3 as default in Fedora2014-02-12T00:00:00+00:00http://eng.hroncok.cz/2014/02/12/python3-fedora-default
<p>First of all, if you don’t know anything about Python 3 in Fedora, go read <a href="https://fedoraproject.org/wiki/Changes/Python_3_as_Default">this</a> before you go any further.</p>
<p>OK, now when you have read it (you have, right?), let me try to explain what needs to be done first and what’s blocking us. There is <a href="https://fedoraproject.org/wiki/User:Churchyard/python3">this gigantic table of packages that need to be ported to Python 3</a> - that means ship both 2 and 3 subpackages for modules, or use Python 3 interpreter for apps. From that, you can see what packages need some love. But it doesn’t show what is important and what should be targeted first.</p>
<h2 id="cloud">Cloud</h2>
<p>You may be surprised that cloud is my first topic. The thing is, cloud images of Fedora need to be as small as possible. They simply cannot ship both Pythons. While in other use cases we might be able to ship Python 2 as well as Python 3 with the default installation, cloud is not that case. The most important thing within cloud is <a href="https://bugs.launchpad.net/cloud-init/+bug/1247132">cloud-init</a>. It has two major deps that need to be ported first: <a href="https://github.com/boto/boto/issues/677">boto</a> and templating system.</p>
<p>Boto is somehow ported to Python 3 in a <a href="https://github.com/kurin/boto/tree/py3kport">GitHub repo by one individual</a> and it doesn’t follow upstream releases. It also requires an old version of HTTPretty that somehow did work with Python 3 (probably by accident). However, <a href="https://github.com/gabrielfalcao/HTTPretty/pull/143">HTTPretty now gets Python 3 support in newer versions</a>. So in some time, this might be solved by upstream (if we ask them politely once in a while).</p>
<p>cloud-init templating system is the real problem. Cloud-init uses <a href="http://www.cheetahtemplate.org/">Cheetah</a> and that is very old and probably dead, latest release is from 2010 and the documentation talks about Python 2.3. Porting that thing to Python 3 is probably not an option (and if you don’t think so, look at the code). So for cloud-init to be ported to Python 3 and for other reasons, <a href="https://bugs.launchpad.net/cloud-init/+bug/1219223">changing the templating system was proposed</a>. However, upstream wants 100 % backward compatibility with Cheetah templates and that’s not gonna happen magically. So adding a compat layer between some other templating system, that has a similar syntax as Cheetah (such as <a href="http://docs.makotemplates.org/en/latest/usage.html#basic-usage">Mako</a>) would help a lot. Good starting point for you, if you want to push thing forward.</p>
<h2 id="yum-dnf-and-friends">Yum, DNF and friends</h2>
<p>Yum won’t be ported to Python 3. We’ll ship DNF instead (maybe renamed to Yum). DNF should run with Python 3 just fine, but we’ll have to wait until it’s suitable as default. We cannot drop Python 2 from default installation while having Yum in as a default installer. According to upstream, <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1014559#c3">PackageKit should be Python 3 compatible when it drops Yum backend</a>, but as we see it, there are still some <a href="https://bugs.freedesktop.org/show_bug.cgi?id=66992">things that need to be ported</a>.</p>
<h2 id="anaconda">Anaconda</h2>
<p>And I’d say this is the last big thing that needs to be ported before we can drop Python 2 from default installation. Anaconda has a long list of dependencies (most of them are part of Anaconda project) that need to be ported. Anaconda developers are slowly working towards Python 3, but they have lots of other tasks on their shoulders and helping them would be nice. <del>Porting <a href="https://bugzilla.redhat.com/show_bug.cgi?id=984907">authconfig</a> looks like a good place to start as it’s developer clearly stated that he has no time to do it.</del> (The last sentence is probably <a href="https://lists.fedoraproject.org/pipermail/devel/2014-February/195466.html">false</a>.)</p>
3D printing: Open source licenses2013-11-15T00:00:00+00:00http://eng.hroncok.cz/2013/11/15/3d-printing-open-source-licenses
<p><strong>Note:</strong> I’m not a lawyer. This post is mostly just about my thoughts and all of my interpretations of various software or content licenses might be completely wrong. Also, this text asks a lot’s of questions and brings no answer. You have been warned.</p>
<h2 id="models-for-3d-printing-and-free-software-licenses">Models for 3D printing and free software licenses</h2>
<p>I’m a big fan of hobby 3D printing and I’m a big fan of free software and content. When I code, I release my work under the terms of various free software licenses, mostly <a href="http://en.wikipedia.org/wiki/ISC_license">ISC</a> (similar to MIT) or GNU GPL. When I create stuff for 3D printing, I want to do the same thing: Make it free, as in freedom.</p>
<p>But applying software licenses to content is not a good idea. For that, we have free content licenses, such as favorite Creative Commons (<a href="https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#Bad_Licenses_3">without NC or ND restrictions</a>). First of all, most “easy” (a.k.a. short) licenses, such as ISC or MIT, speak about software only. I don’t know if I can even legally apply the text about software to something else:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Permission to use, copy, modify, and/or distribute this software...
</code></pre></div></div>
<p>On the other hand, GNU GPL thinks about other kind of stuff than software:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>This License applies to any program or other work...
</code></pre></div></div>
<p>But even though, the license speaks about source and binary form. Even if the source form is well defined as something that’s meant for easy editing (or something like that), we are still stuck in the world where we have just two forms: form for editing and form for running/using. I will return to that later and you’ll see that in 3D printing, this problem is much more complex.</p>
<h2 id="creative-commons-and-other-content-licenses">Creative Commons and other content licenses</h2>
<p>So for now on, I could say that Creative Commons is a much better option. An audio track, a photo, even a video or an icon, that’s all content. Therefore 3D model has to be content too. However, I code my models. Wait, huh? Yes, I code them, usually in <a href="http://openscad.org/">OpenSCAD</a>. As you might already know, <a href="http://creativecommons.org/software">using Creative Commons for source code is not recommended</a> (well, that page speaks about software, but you know what I mean). Let’s say I release my work under the terms of CC BY-SA. Do others have to distribute the code alongside with the 3D model? And do they need to keep it open source? No, they don’t. As long as you are fine with that, there is no trouble. But if you want to keep you work open source, as if you would use GNU GPL, you cannot use Creative Commons. It just doesn’t work.</p>
<h2 id="source-and-binary-form-of-a-3d-model">“Source and binary” form of a 3D model</h2>
<p>To explain the problem, I will return to software. When you code a program, it’s usually either compiled or interpreted. Unless it’s kind of both. If we stick with the compiled form, it is possible to distribute sources and/or executables (or binary libraries etc.). Various complex licenses define terms for distributing your app in different forms. For example GNU GPL says: if you distribute binary, you have to include the source.</p>
<p>But when I code my 3D models, it has got much more forms. It can exist in a form of source code. The source code can be compiled/rendered to meshes - either binary or ASCII, that’ts not the point here. But even the mesh is easily editable. You can import it into Blender and do crazy stuff with that. Later, the mesh can be compiled/sliced to G-code, that can be compared to binary form or your app for different architectures (while by architectures I mean different 3D printers). While you usually don’t distribute just G-code for the technical aspect, it’s certainly possible and if you know that other person has the very same printer as you, it’s even useful sometimes. But even the G-code can be somehow editable, but not in very delicious way. And last but not least, you have the printed real 3D object.</p>
<p>So let’s make it an real world example. I create a model in OpenSCAD. Let’s make it simple (and for now ignore the fact that you probably couldn’t license a common shape such as cube anyway):</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cube(1);
</code></pre></div></div>
<p>Then I create a mesh form that code in a form of STL file:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>solid OpenSCAD_Model
facet normal -1 0 0
outer loop
vertex 0 0 1
vertex 0 1 1
vertex 0 0 0
endloop
endfacet
facet normal -1 0 0
outer loop
vertex 0 0 0
vertex 0 1 1
vertex 0 1 0
endloop
endfacet
facet normal 0 0 1
outer loop
vertex 0 0 1
vertex 1 0 1
vertex 1 1 1
endloop
endfacet
facet normal 0 0 1
outer loop
vertex 0 1 1
vertex 0 0 1
vertex 1 1 1
endloop
endfacet
facet normal 0 -1 0
outer loop
vertex 0 0 0
vertex 1 0 0
vertex 1 0 1
endloop
endfacet
facet normal 0 -1 0
outer loop
vertex 0 0 1
vertex 0 0 0
vertex 1 0 1
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0 1 0
vertex 1 1 0
vertex 0 0 0
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 0 0 0
vertex 1 1 0
vertex 1 0 0
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 0 1 1
vertex 1 1 1
vertex 0 1 0
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 0 1 0
vertex 1 1 1
vertex 1 1 0
endloop
endfacet
facet normal 1 0 0
outer loop
vertex 1 0 0
vertex 1 1 0
vertex 1 1 1
endloop
endfacet
facet normal 1 0 0
outer loop
vertex 1 0 1
vertex 1 0 0
vertex 1 1 1
endloop
endfacet
endsolid OpenSCAD_Model
</code></pre></div></div>
<p>Then I create a G-code form that:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> G21 ; set units to millimeters
M107
M104 S200 ; set temperature
G28 ; home all axes
G1 Z5 F5000 ; lift nozzle
M109 S200 ; wait for temperature to be reached
G90 ; use absolute coordinates
G92 E0
M82 ; use absolute distances for extrusion
G1 F1800.000 E-1.00000
G92 E0
G1 Z0.350 F7800.000
G1 X94.790 Y94.790
G1 F1800.000 E1.00000
G1 X95.800 Y93.960 F600.000 E1.04253
G1 X96.950 Y93.350 E1.08489
G1 X98.200 Y92.970 E1.12739
G1 X99.500 Y92.840 E1.16990
G1 X100.500 Y92.840 E1.20243
G1 X101.800 Y92.970 E1.24494
G1 X103.050 Y93.350 E1.28745
G1 X104.200 Y93.960 E1.32980
G1 X105.210 Y94.790 E1.37233
G1 X106.040 Y95.800 E1.41487
G1 X106.650 Y96.950 E1.45722
G1 X107.030 Y98.200 E1.49973
G1 X107.160 Y99.500 E1.54223
G1 X107.160 Y100.500 E1.57477
G1 X107.030 Y101.800 E1.61728
G1 X106.650 Y103.050 E1.65978
G1 X106.040 Y104.200 E1.70214
G1 X105.210 Y105.210 E1.74467
G1 X104.200 Y106.040 E1.78720
G1 X103.050 Y106.650 E1.82956
G1 X101.800 Y107.030 E1.87206
G1 X100.500 Y107.160 E1.91457
G1 X99.500 Y107.160 E1.94710
G1 X98.200 Y107.030 E1.98961
G1 X96.950 Y106.650 E2.03212
G1 X95.800 Y106.040 E2.07447
G1 X94.790 Y105.210 E2.11700
G1 X93.960 Y104.200 E2.15954
G1 X93.350 Y103.050 E2.20189
G1 X92.970 Y101.800 E2.24440
G1 X92.840 Y100.500 E2.28690
G1 X92.840 Y99.500 E2.31944
G1 X92.970 Y98.200 E2.36195
G1 X93.350 Y96.950 E2.40445
G1 X93.960 Y95.800 E2.44681
G1 X94.727 Y94.866 E2.48613
G1 F1800.000 E1.48613
G92 E0
G1 X100.000 Y100.000 F7800.000
G1 F1800.000 E1.00000
G1 X100.000 Y100.000 F1800.000
G1 X100.000 Y100.000 F7800.000
G1 X100.000 Y100.000 F600.000 E1.00000
G1 X100.000 Y100.000 F7800.000
G1 X100.000 Y100.000 F1800.000
M106 S255
G1 F1800.000 E0.00000
G92 E0
G1 Z0.750 F7800.000
G1 X99.875 Y100.125
G1 F1800.000 E1.00000
G1 X100.000 Y100.000 F600.000 E1.00520
G1 X99.875 Y99.875 E1.01040
G1 X100.000 Y100.000 F7800.000
G1 X100.125 Y100.125 F600.000 E1.01559
G1 X100.000 Y100.000 F7800.000
G1 X100.125 Y99.875 F600.000 E1.02079
G1 F1800.000 E0.02079
G92 E0
G1 Z1.150 F7800.000
G1 X99.875 Y100.125
G1 F1800.000 E1.00000
G1 X100.000 Y100.000 F600.000 E1.00520
G1 X99.875 Y99.875 E1.01040
G1 X100.000 Y100.000 F7800.000
G1 X100.125 Y100.125 F600.000 E1.01559
G1 X100.000 Y100.000 F7800.000
G1 X100.125 Y99.875 F600.000 E1.02079
G1 F1800.000 E0.02079
G92 E0
M107
M104 S0 ; turn off temperature
G28 X0 ; home X axis
M84 ; disable motors
</code></pre></div></div>
<p>And I print the cube, finally.</p>
<p>Let’s say I’ve released the cube under a software license, such as GPL. Now what is the source and what is not? What if Bob prints it and sells it to Anne, does he need to give her the G-code as well? Or STL file? Or even the OpenSCAD source? Does Bob needs to 2D print GNU GPL’s text and distribute it together with the printed cube?</p>
<h2 id="theres-more">There’s more</h2>
<p>And that was simple. What if there’s a bunch of machine parts for a 3D printer released under GNU GPL and I take just <a href="https://github.com/josefprusa/PrusaMendel/blob/master/source/coupling.scad">one part of it</a> and I use it in my own printer’s design. Is it derivative work and do I need to release my own printer’s design as GNU GPL? Does that mean I have to distribute all source code of my printer design together with it? Does that mean STL, G-code or OpenSCAD source? What if I don’t use OpenSCAD?</p>
<p>That could be solved by LGPL. Or not. How do I dynamically link a 3D printed object to another one?</p>
<p>I had an idea, that maybe an Open Hardware license could be useful, but that usually speaks just about documentation and therefor is not usable.</p>
<h2 id="how-to-solve-that">How to solve that?</h2>
<p>When I create a 3D model for 3D printing I would like to have a license that satisfy my needs. For most of the cases, that’s CC BY-SA for me, as it works like MIT in software. However, I could imagine a situation, where I want to force keep the openness of the code. Of the very first OpenSCAD code. And once I put myself in that situation, I’ll be screwed.</p>
ownCloud with PostgreSQL on CentOS2013-06-12T00:00:00+00:00http://eng.hroncok.cz/2013/06/12/owncloud-with-postgresql-on-centos
<p><strong>Note:</strong> This post is kind of a hybrid between a how-to and a story, about how I have it done. You probably won’t need to do it all stop by step. If you are reading this, because you actually want to install ownCloud with PostgreSQL on CentOS, read the text first and try it after you’ve read it all.</p>
<h2 id="background">Background</h2>
<p><em>You can skip this part, if you just want the how-to.</em></p>
<p>At our <a href="http://3dprint.fit.cvut.cz/">3D printing lab at the university</a>, we share 3D models and <a href="https://en.wikipedia.org/wiki/G-code">G-codes</a> a lot. G-codes for 3D printing are usually to large for e-mail attachments, so it basically always ends up with USB stick. This drives me crazy, because we are the <a href="http://fit.cvut.cz/en">Faculty of Information Technology</a> and we are unable to bring a long term solution to a simple problem.</p>
<p>Once, we had a server with SSH (ant therefore SFTP) access - but it was a mess and we always got some problems with permissions. We can also use some ready-to-use solution, such as Dropbox, but I don’t like it - I can either synchronize the files, or use web interface. I would prefer a tool, that also allows me to simply connect the storage, let’s say via WebDAV.</p>
<p>That’s bring me to <a href="http://owncloud.org/">ownCloud</a>, that supports all this - syncing files, mounting the storage and web interface. And speaking about Dropbox, ownCloud should be able to connect Dropbox as an external storage. I’ve heard a lot about this tool and I want to give it a try for a long time.</p>
<p>In our lab, we have several old computers and at least one of them should serve as a server just fine. e also have a lot of hard drives that should serve as RAID pool. It has been ages since I installed a server for some service and in that times, I used Debian stable. Right now, when I am Fedorian and Red Hatter, I’ve decided for CentOS. I have never tried it yet but what the hell, it has <code class="language-plaintext highlighter-rouge">yum</code>. At least I can recall <a href="http://fedoraproject.org/wiki/Features/OwnCloud">ownCloud is a feature for Fedora 19</a> and the packages are available for EPEL (therefore for CentOS).</p>
<h2 id="virtualbox">VirtualBox</h2>
<p><em>Yes, you can skip this part too :)</em></p>
<p>I decided to try the thing first in the virtual machine in VirtualBox, so I don’t screw anything up. I use VirtualBox a lot for trying several desktops, but I never used it to virtualise a server. The only thing that is important is to set the network mode to <strong>Bridged networking</strong>, so you can get an real IP address that is available from your local network.</p>
<h2 id="getting-started-with-centos">Getting started with CentOS</h2>
<p><em>And finally, if your CentOS server already works, you can skip this too.</em></p>
<p>I’ve installed CentOS from the minimal installation media. The installation was really fast and I believe the only thing I got was kernel, networking and yum. First, you have to run <code class="language-plaintext highlighter-rouge">dhclient</code> to get an IP address. It is really a good idea to enable automatic connecting on boot, or you’ll need physical access to the machine after each reboot (not a big issue when running the server from VirtualBox, but in production). You’ll do that by enabling it in <code class="language-plaintext highlighter-rouge">/etc/sysconfig/network-scripts/ifcfg-eth0</code> (or similar) - set <code class="language-plaintext highlighter-rouge">ONBOOT</code> option to <code class="language-plaintext highlighter-rouge">yes</code>.</p>
<p>SSH server was already installed, I recommend to use only keys to log in, by using this config in <code class="language-plaintext highlighter-rouge">/etc/ssh/sshd_config</code>:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>PermitRootLogin no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
RSAAuthentication no
PasswordAuthentication no
UsePAM no
KerberosAuthentication no
GSSAPIAuthentication no
</code></pre></div></div>
<p>Be sure to create an user and to have key authorization working for him before you disable root access and password logins. Simple copying my public key to the server’s user’s <code class="language-plaintext highlighter-rouge">.ssh/authorized_keys</code> didn’t work, CentOS needs you to set permissions correctly:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
</code></pre></div></div>
<p>Also, I’ve run <code class="language-plaintext highlighter-rouge">yum update</code> to get the updates.</p>
<h3 id="adding-epel">Adding EPEL</h3>
<p>To install ownCloud form EPEL repository, you need to have EPEL installed and enabled in your system. Get the <a href="http://download.fedoraproject.org/pub/epel/6/i386/repoview/epel-release.html">link for the latest version of epel-release</a> and install it with <code class="language-plaintext highlighter-rouge">yum</code>.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>yum install http://.../pub/linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
</code></pre></div></div>
<p>I also recommend to install the package <code class="language-plaintext highlighter-rouge">bash-completion</code> from EPEL - otherwise the work with <code class="language-plaintext highlighter-rouge">yum</code> and other tools is pain.</p>
<h2 id="installing-owncloud">Installing ownCloud</h2>
<p><a href="http://fedoraproject.org/wiki/Features/OwnCloud">Fedora ownCloud feature page</a> says:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>No manual configuration should be required and if, make sure all steps are correctly described in a README.Fedora
</code></pre></div></div>
<p>So I’ve installed the <code class="language-plaintext highlighter-rouge">owncloud</code> package and looked in README.Fedora.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>yum install owncloud
cat /usr/share/doc/owncloud-4.5.11/README.fedora
...
</code></pre></div></div>
<p>This README says several things:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>After installation you should be able to access the login/configuration page
on following url:
http://localhost/owncloud/ or http://localhost/
</code></pre></div></div>
<p>And yes indeed (not sure but probably after starting the server with <code class="language-plaintext highlighter-rouge">service httpd start</code>) it servers something, but only from local connection:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>yum install lynx
lynx http://localhost/owncloud/
</code></pre></div></div>
<p>That works, but accessing ownCloud from my host didn’t work.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Currently ownCloud in Fedora supports following webserver: httpd and nginx.
You must install at least on webserver subpackage (owncloud-webserver). These
packages include additional configuration files for the webservers. Note that
these files are just samples. For production setup you should adjust them to
your needs. Also remote access is disabled by default.
</code></pre></div></div>
<p>Yes, exactly. I’ve observed, that <code class="language-plaintext highlighter-rouge">owncloud-httpd</code> package was installed with <code class="language-plaintext highlighter-rouge">owncloud</code>. As I have no experience with nginx configuration, I decided to keep it that way. I’ve looked to <code class="language-plaintext highlighter-rouge">/etc/httpd/conf.d/owncloud.conf</code> and changed this part:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> <IfModule mod_authz_core.c>
# Apache 2.4
Require local
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</code></pre></div></div>
<p>To:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> Order Allow,Deny
Allow from all
</code></pre></div></div>
<p>And restarted Apache with <code class="language-plaintext highlighter-rouge">service httpd restart</code>. To allow remote access. Sadly, it wan’t enough. Iptables are running be default on CentOS and I had to enable TCP traffic on ports 80 and 443.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT
service iptables save
</code></pre></div></div>
<p>After that, I was able to visit ownCloud page from remote computer (in this case, the virtualization host).</p>
<h2 id="configuring-postgresql">Configuring PostgreSQL</h2>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>You can choose between 3 databases: MySQL, Postgresql and SQLite.
For each of them exists a corresponding owncloud subpackage (owncloud-database).
You are required to install at least one of them.
For larger installs you should use MySQL or PostgreSQL.
If you choose MySQL or PostgreSQL, keep in mind that you must create a database and user
for owncloud manually, before you can finish the setup process.
For specific instructions, please refer to the documentation in the database subpackages.
</code></pre></div></div>
<p>Together with <code class="language-plaintext highlighter-rouge">owncloud-httpd</code> I’ve also got <code class="language-plaintext highlighter-rouge">owncloud-mysql</code>. But my personal preferences are for PostgreSQL, so I wanted <code class="language-plaintext highlighter-rouge">owncloud-postgresql</code> instead. I didn’t want anything from MySQL to be left behind, so I undid the installation of ownCloud with <code class="language-plaintext highlighter-rouge">yum history undo X</code> and installed again <code class="language-plaintext highlighter-rouge">yum install owncloud-postgresql</code>. After that, I’ve looked to the documentation in the database subpackage.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cat /usr/share/doc/owncloud-postgresql-4.5.11/README.postgresql
Configure PostgreSQL for ownCloud
=================================
Before you can use PostgreSQL as database backend, you need to follow a couple of steps:
1. make sure that your PostgreSQL service is configured and running properly
2. log in to PostgreSQL as system user to create the database and a dedicated user account for ownCloud:
su - -c "psql" postgres
CREATE USER username WITH PASSWORD 'password';
CREATE DATABASE owncloud TEMPLATE template0 ENCODING 'UNICODE';
ALTER DATABASE owncloud OWNER TO username;
GRANT ALL PRIVILEGES ON DATABASE owncloud TO username;
Choose identifier and password accordingly.
Now you can launch the ownCloud setup screen, select PostgreSQL in the advanced settings and fill in your credentials.
</code></pre></div></div>
<p>On CentOS, to configure and run PostgreSQL you have to do:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>service postgresql initdb # initialize
service postgresql start # start it now
chkconfig postgresql on # start it always
</code></pre></div></div>
<p>After that, you can run <code class="language-plaintext highlighter-rouge">su - -c "psql" postgres</code> and create the database and user with commands in <code class="language-plaintext highlighter-rouge">README.postgresql</code>. The only problem is, you won’t be able to connect to PostgreSQL form ownCloud, unless you enable password anesthetization in <code class="language-plaintext highlighter-rouge">/var/lib/pgsql/data/pg_hba.conf</code>:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all ident
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
</code></pre></div></div>
<p>Changed thing is in last column - for connection form localhost (both IPv4 and IPv6) it now uses md5 hashes of passwords to authenticate the user. After the change, restart PostgreSQL with <code class="language-plaintext highlighter-rouge">service postgresql restart</code>.</p>
<p>That should be it, but SELinux protects you and therefor you cannot connect to the PostgreSQL database from ownCloud. The following command should enable it:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>setsebool -P httpd_can_network_connect_db 1
</code></pre></div></div>
<p>Disabling SELinux enables it as well. To disable it now (until reboot), run <code class="language-plaintext highlighter-rouge">echo 0 >/selinux/enforce</code>, to disable it forever after next reboot, set <code class="language-plaintext highlighter-rouge">SELINUX</code> option to <code class="language-plaintext highlighter-rouge">disabled</code> in <code class="language-plaintext highlighter-rouge">/etc/selinux/config</code>. Disabling SELinux should be the last option (but it usually helps with a lot of things).</p>
<h2 id="custom-owncloud-data-directory">Custom ownCloud data directory</h2>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>The default data directory is '/var/lib/owncloud/data'. Every file that is uploaded
by your users to ownCloud gets saved into this folder. Consider doing a backup of this
directory, together with the database and the main configuration.
</code></pre></div></div>
<p>As I intend to keep user data in <code class="language-plaintext highlighter-rouge">/home</code>, I wanted to change this. It is not very difficult, you are asked for the directory on the ownCloud setup page.</p>
<p>First, you have to create the directory and set the permissions correctly:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[root@centos ~]# mkdir -p /home/owncloud/
[root@centos ~]# ls -ld /var/lib/owncloud/data/
drwxr-x---. 2 apache apache 4096 Jun 10 20:12 /var/lib/owncloud/data/
[root@centos ~]# chown apache:apache /home/owncloud/
[root@centos ~]# chmod 750 /home/owncloud/
[root@centos ~]# ls -ld /home/owncloud/
drwxr-x---. 3 apache apache 4096 Jun 10 20:57 /home/owncloud/
</code></pre></div></div>
<p>But, ownCloud would keep telling you it cannot writes to that directory. If you don’t know, what’s causing the problem, blame SELinux :) And again, it protects you and it doesn’t allow ownCloud to write anywhere it thinks it should. Sou you have to allow it (or disable SELinux).</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>chcon -t httpd_sys_rw_content_t /home/owncloud
</code></pre></div></div>
<p>After that, I was able to fill the setup page of ownCloud and it worked. Sadly, I was not able to make the Dropbox sync working (yet).</p>
<p>That’s it, as said before <em>No manual configuration should be required</em> :D</p>