{"id":695,"date":"2023-06-08T21:29:55","date_gmt":"2023-06-08T20:29:55","guid":{"rendered":"https:\/\/watchdiana.fail\/blog\/?p=695"},"modified":"2023-06-08T21:30:38","modified_gmt":"2023-06-08T20:30:38","slug":"upgrading-my-pi4","status":"publish","type":"post","link":"https:\/\/watchdiana.fail\/blog\/2023\/06\/08\/upgrading-my-pi4\/","title":{"rendered":"Upgrading my Pi4"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">&#8230; OK, in my defense it was PAST me who chose which the data drive was and there is no reason I should have remembered.  So let&#8217;s start that backup again.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We&#8217;re going to need to restart the two services we run here.  One is blinkbot, which reminds someone I know to take care of their eyes, and also does some other things.  One is a django web app.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I have no idea how blinkbot works, but I &#8230; I think it is a service?  So I need to work out where services go.  And apache2 runs the other one, and that&#8217;s an install and configure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Oh, hello backup of \/root.  It turns out you have a bash history.  I love you after all&#8230;  Because I don&#8217;t actually *do* much on this computer so that will probably all be very useful&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Oh my, I did a lot of fucking around.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And I&#8217;m frustrated and this is slow, and I think I&#8217;ve got everything, so let&#8217;s go re-install and then I&#8217;ll add a private key and stuff&#8230;<br><br>Wait.  I didn&#8217;t preserve permissions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So I need to ssh things to a known folder and preserve permissions.  I can&#8217;t preserve the users, though.  So screw it, can I just record the permissions here?  Maybe.  And I&#8217;m making bad decisions.  So let&#8217;s log in and do the thing.  I can literally rebuild this all anyhow.  We&#8217;ve got the home directory, and \/root, and \/etc.  The data in \/home is all we actually need, but everything else is very very useful.  \/etc in particular means we&#8217;ve already got the work done in Apache2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First of all, we have to work out which Python to use.  We&#8217;ve got 3.10.9 on our computer, and we&#8217;ve got some awesome people at Mythic Beasts who can tell us which OS to install, of a choice of Ubuntus and Rasbians.  I recommend these people.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We remove the old known_hosts entry, upload our root public key via their web-based UI, and when the network comes up, we&#8217;re in.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I need beer.  I should not start yet, but I need beer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code># apt-get update &amp;&amp; apt-get upgrade<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>#<\/code> <code>apt-get install git<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># <code>apt-get install dehydrated \/\/ certificate management and automation<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But this still gives us a failure, so&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># <code>apt-get install dehydrated<\/code>-apache2<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>adduser --disabled-password char_dev<\/code>[footnote]Ooooh, it&#8217;s nice to have that instead of useradd[\/footnote].  I can also use <code>passwd -d char_dev<\/code> if I want to not have a password, but created one by accident.  That way I can only use the ssh key.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Add our ssh key to \/home\/char_dev\/.ssh\/authorized keys.  Curse American spelling.[footnote]Still no beer.[\/footnote]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#8230; Did I delete something in this build-log?  Who cares.  I got beer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># <code>\/usr\/bin\/dehydrated --register --accept-terms<\/code> \/\/ This accepts the terms and conditions of the letsencrypt authority.  It generates an account key.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">upload our config and domains.txt to \/etc\/dehydrated\/<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">#<code> dehydrated -c<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">#<code> apt-get install python3-pip<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># <code>apt-get install apache2-dev \/\/<\/code> gets around missing apxs in an outdated wsgi otherwise provided<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Upload our old home folder.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code># chown -R char_dev:char_dev \/home\/char_dev<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As not-root,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ <code>pip3 install virtualenv &amp;&amp; python3 -m virtualenv<\/code> venv<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ <code>source venv\/bin\/activate<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>$<\/code> <code>pip3 install mod_wsgi<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>$ pip3 install django-nested_admin weasyprint django-simple_search \/\/ and so on.<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As root:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Edit <code>\/etc\/apache2\/apache2.conf<\/code> to put in the correct path in the venv to mod_wsgi[footnote]Around this point I generally install emacs.[\/footnote]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure there&#8217;s a secret key as defined in settings.py<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">test with python manage.py runserver from the non-root.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>chown -R :www-data \/home\/char_dev\/rqg_char_db\/char_db\/wsgi.py\/\/ to make sure that apache and co  are allowed to access wsgi.py<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>apt-get install libapache2-mod-wsgi-py3  \/\/ connect everything<\/code><br><br>a2enmod ssl \/\/ actually turn on ssl<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">make sure you have uploaded sites-enabled as well as all the other configs.  it turns out that&#8217;s pretty important.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From non-root $ <code>mod_wsgi-express<\/code> the one with the config.  Copy that into apache2.conf and you may also have to add <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>WSGIApplicationGroup %{GLOBAL}<\/code> \/\/ into apache2.conf as well<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">and collect static as non-root.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Oof.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are some choices behind the scenes about adding permissions to the db and the path to it, and where to put it.  It&#8217;s best out of the django app folder, where it can be in its own little open sandpit.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8230; OK, in my defense it was PAST me who chose which the data drive was and there is no reason I should have remembered. So let&#8217;s start that backup again. We&#8217;re going to need to restart the two services we run here. One is blinkbot, which reminds someone I know to take care of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-695","post","type-post","status-publish","format-standard","hentry","category-life","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts\/695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/comments?post=695"}],"version-history":[{"count":14,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts\/695\/revisions"}],"predecessor-version":[{"id":709,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/posts\/695\/revisions\/709"}],"wp:attachment":[{"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/media?parent=695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/categories?post=695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/watchdiana.fail\/blog\/wp-json\/wp\/v2\/tags?post=695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}