<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Alex Tomkins - ubuntu</title>
    <link>https://www.alextomkins.com/tag/ubuntu/</link>
    <atom:link href="https://www.alextomkins.com/tag/ubuntu/feed.xml" rel="self" type="application/rss+xml" />
    <description>Posts tagged with ubuntu</description>
    <language>en</language>
    
    
    <item>
      <title>RUNLEVEL=1 apt-get install package alternative</title>
      <link>https://www.alextomkins.com/2018/03/runlevel-apt-get-install-package-alternative/</link>
      <guid>https://www.alextomkins.com/2018/03/runlevel-apt-get-install-package-alternative/</guid>
      <pubDate>Sat, 31 Mar 2018 17:25:00 +0000</pubDate>
      <description><![CDATA[<p>An old documented way of preventing services from starting immediately after installation in
Debian/Ubuntu is using the <code>RUNLEVEL</code> environment variable to trick the runlevel helper into
returning a response that the system isn't fully running, such as:</p>
<pre><code># RUNLEVEL=1 apt-get install nginx</code></pre>
<p>Sadly this doesn't work in newer versions of Debian/Ubuntu, the official way is to use the policy
helper script <code>/usr/sbin/policy-rc.d</code> and return a 101 exit code. This is a a bit more
inconvenient - having to temporarily create this file only to remove it after installing the
package.</p>
<p>Fortunately there is an alternative - <code>policyrcd-script-zg2</code>. Install the package:</p>
<pre><code>$ sudo apt-get install policyrcd-script-zg2</code></pre>
<p>Create a new script which returns a 101 exit code, I've created it as
<code>/usr/local/sbin/policy-donotstart</code>:</p>
<pre><code>#!/bin/sh
exit 101</code></pre>
<p>Then make it executable:</p>
<pre><code>$ sudo chmod 755 /usr/local/sbin/policy-donotstart</code></pre>
<p>When installing packages where you don't want the service to immediately start, use the <code>POLICYRCD</code>
environment variable:</p>
<pre><code># POLICYRCD=/usr/local/sbin/policy-donotstart apt-get install nginx</code></pre>
<p>The service will install, but you'll a message similar to:</p>
<pre><code>invoke-rc.d: policy-rc.d denied execution of start.</code></pre>
<p>For Ansible, you can add environment variables to any task:</p>
<pre><code>- name: Install nsd
  apt: pkg=nsd install_recommends=no
  environment:
    POLICYRCD: /usr/local/sbin/policy-donotstart</code></pre>
<p>Now you can safely install a package, configure it, and then start it once you've got all the
correct files in place - all with a convenient environment variable.</p>
]]></description>
    </item>
    
    
    
    
    
    <item>
      <title>Modern Django with Ubuntu Trusty</title>
      <link>https://www.alextomkins.com/2016/10/modern-django-with-ubuntu-trusty/</link>
      <guid>https://www.alextomkins.com/2016/10/modern-django-with-ubuntu-trusty/</guid>
      <pubDate>Sun, 02 Oct 2016 22:57:00 +0000</pubDate>
      <description><![CDATA[<p>At this point Ubuntu 14.04 Trusty Tahr is nearly 2.5 years old, with another 2.5 years support left
until it reaches end of life for support. However for those of us still working with Trusty, it's
often desirable to try and get a few backported modern packages to make development and hosting of
Django apps a bit easier to work with.</p>
<p>These days you could use containers to deploy bleeding edge applications with all the new stuff
bundled inside, maybe with either <a href="https://www.docker.com/">Docker</a> or
<a href="https://coreos.com/rkt/">rkt</a>. However in this post we'll be going through a couple of available
APT repositories to help modernise a slightly older distribution.</p>
<h1>Python</h1>
<p>As of October 2016, Python 3.5 is the latest stable version of Python. It's supported in Django 1.8
to 1.10, and for anyone wanting to develop an app for the long term - going for Python 2.7 at this
point in time is a dead end. Ubuntu Trusty only has Python 2.7 and 3.4, although 3.4 is well
supported - we want to try and go for the latest possible Python version.</p>
<h2>Deadsnakes</h2>
<p>The <a href="https://launchpad.net/~fkrull/+archive/ubuntu/deadsnakes">Old and New Python Versions</a>
repository (or deadsnakes) provides multiple Python versions which aren't included in a particular
version of Ubuntu. Consider the support of this repository carefully, as it isn't an official repo
(stick with Python 3.4 if this bothers you).</p>
<p>Installation is quick and easy:</p>
<pre><code>$ sudo add-apt-repository ppa:fkrull/deadsnakes
$ sudo apt-get update
$ sudo apt-get install python3.5</code></pre>
<p>As deadsnakes provides even more versions - we could also install Python 3.3 as well, which could
help in testing code under multiple Python versions with <a href="https://tox.wiki/">tox</a>.</p>
<h1>PostgreSQL</h1>
<p>Ubuntu Trusty comes with PostgreSQL 9.3, which is missing JSONB support. So if we want the
JSONField which is new since Django 1.9 - we'll need a more modern version of Postgres. As of
October 2016 the latest release of Postgres is 9.6 - which is what we want to aim for.</p>
<h2>PostgreSQL Apt Repository</h2>
<p>Fortunately postgresql.org provides official packages of all the supported Postgres versions for
quite a few supported distributions. As this is provided by the official Postgres site, packages
are updated with every new release - so support is good.</p>
<p>To install:</p>
<pre><code>$ sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"
$ curl -sL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install postgresql-9.6</code></pre>
<p>Now we can use JSONField thanks to the updated Postgres.</p>
<h1>Conclusion</h1>
<p>Just because you're stuck on an older release of Ubuntu doesn't mean you're stuck with all the old
tools - go upgrade!</p>
]]></description>
    </item>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
  </channel>
</rss>
