{"id":562,"date":"2023-08-20T20:59:12","date_gmt":"2023-08-20T20:59:12","guid":{"rendered":"https:\/\/blogs.gentoo.org\/gsoc\/?p=562"},"modified":"2023-08-20T20:59:12","modified_gmt":"2023-08-20T20:59:12","slug":"week-1112-report-automated-gentoo-system-updater","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/gsoc\/2023\/08\/20\/week-1112-report-automated-gentoo-system-updater\/","title":{"rendered":"Week 11+12 Report, Automated Gentoo System Updater"},"content":{"rendered":"<p>This article is a summary of all the changes made on\u00a0<a href=\"https:\/\/wiki.gentoo.org\/wiki\/Google_Summer_of_Code\/2023\/Ideas\/Automated_Gentoo_system_updater\">Automated Gentoo System Updater<\/a>\u00a0project during\u00a0<strong>weeks 11 and 12<\/strong>\u00a0of GSoC.<\/p>\n<p>Project is hosted on GitHub (\u00a0<a href=\"https:\/\/github.com\/Lab-Brat\/gentoo_update\">gentoo_update<\/a>\u00a0and\u00a0<a href=\"https:\/\/github.com\/Lab-Brat\/gentoo_update_flutter\">mobile app<\/a>).<\/p>\n<h3 id=\"progress-on-weeks-11-and-12\">Progress on Weeks 11 and 12<\/h3>\n<p>During last 2 weeks I\u2019ve completed app UI and Firebase backend. Most of the work is done!<\/p>\n<p>I\u2019m not entirely pleased with how the backend works. In Firebase, I ended up using:<\/p>\n<ul>\n<li>Firestore (security rules defined\u00a0<a href=\"https:\/\/github.com\/Lab-Brat\/gentoo_update_flutter\/blob\/main\/firestore.rules\">here<\/a>)<\/li>\n<li>Cloud Functions (defined\u00a0<a href=\"https:\/\/github.com\/Lab-Brat\/gentoo_update_flutter\/tree\/main\/functions\">here<\/a>)<\/li>\n<li>Cloud Messaging (FCM).<\/li>\n<\/ul>\n<p>After a user authenticates using anonymous login, a token is automatically registered in Firestore. This token is later used by\u00a0<code>gentoo_update<\/code>\u00a0to send reports. Cloud Functions manage the token\u2019s creation. In fact, all database write operations are handled by Cloud Functions, with users having read-only access to the data they\u2019ve created. Here is how to send the report via token:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-bash hljs\" data-lang=\"bash\"><span class=\"hljs-built_in\">export<\/span> GU_TOKEN=<span class=\"hljs-string\">\"&lt;token ID&gt;\"<\/span>\r\ngentoo-update --send-report mobile\r\n<\/code><\/pre>\n<\/div>\n<p>Internally, gentoo-update talks to a Cloud Function. This function checks the token, then saves the report in Firestore for the user to access.<\/p>\n<p>This differs from the original idea, where I didn\u2019t intend to save reports in Firestore. The initial plan was to have the client side listen and let Firebase route report content from the Gentoo system to the app. But this method often missed reports or stored them incorrectly, causing them to vanish from the app. To solve this, I chose to save the reports and tokens, but with encryption.<\/p>\n<p>I\u2019ve came up with a solution to create a custom backend for the app, which users will be to self-host, more about in the\u00a0<a href=\"https:\/\/labbrat.net\/blog\/gsoc2023\/week11_12\/#Challenges\">Challenges<\/a>\u00a0section.<\/p>\n<p>Apart from the web app, I\u2019ve fixed some minor issues in\u00a0<code>gentoo-update<\/code>\u00a0and pushed the latest ebuild version to GURU repository (<a href=\"https:\/\/github.com\/gentoo\/guru\/commit\/62522296f838eec2ca2d1324cb9a436b64f4b877\">commit link<\/a>).<\/p>\n<h3 id=\"challenges\">Challenges<\/h3>\n<p>While Firebase offers a quick way to set up a backend, it has its drawbacks:<\/p>\n<ul>\n<li>Not all its best features are free.<\/li>\n<li>Some of its operations aren\u2019t transparent.<\/li>\n<li>It doesn\u2019t offer self-hosting.<\/li>\n<li>Its rate-limiting and security features aren\u2019t as strong as needed. To tackle these concerns, I\u2019m considering a custom backend using this tech stack: Linux + Docker + Python\/Django + MongoDB + Nginx.<\/li>\n<\/ul>\n<p>Here\u2019s a breakdown:<\/p>\n<ul>\n<li>Django will serve as the backend, handling tasks similar to Cloud Functions.<\/li>\n<li>MongoDB, a document database, will take Firestore\u2019s place.<\/li>\n<li>Nginx adds extra capabilities for rate-limiting, load balancing, and security checks.<\/li>\n<\/ul>\n<p>If necessary, MongoDB can be swapped out for a relational database because the backend will heavily utilize ORM. The same flexibility applies to Nginx.<\/p>\n<p>A highlight of this approach is that everything can be defined in a Docker Compose file, simplifying self-hosting for users.<\/p>\n<h3 id=\"plans-for-week-13-final-week-\">Plans for Week 13 (final week \ud83c\udf89)<\/h3>\n<p>Here is my plan for the final week of GSoC&#8217;2023:<\/p>\n<ol>\n<li>Add encryption to the Firestore. I don\u2019t want any user data to be stored in plain text.<\/li>\n<li>Improve some UI elements and add a pop-up with commands to copy\/paste.<\/li>\n<li>Publish mobile app to Playstore.<\/li>\n<li>Write a detailed blog post on how to use the whole thing.<\/li>\n<li>Writa a post on forums.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This article is a summary of all the changes made on\u00a0Automated Gentoo System Updater\u00a0project during\u00a0weeks 11 and 12\u00a0of GSoC. Project is hosted on GitHub (\u00a0gentoo_update\u00a0and\u00a0mobile app). Progress on Weeks 11 and 12 During last 2 weeks I\u2019ve completed app UI &hellip; <a href=\"https:\/\/blogs.gentoo.org\/gsoc\/2023\/08\/20\/week-1112-report-automated-gentoo-system-updater\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":182,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,18],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts\/562"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/users\/182"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/comments?post=562"}],"version-history":[{"count":1,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts\/562\/revisions"}],"predecessor-version":[{"id":563,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts\/562\/revisions\/563"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/media?parent=562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/categories?post=562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/tags?post=562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}