diff options
author | Vincent Douillet <vincent@vdouillet.fr> | 2021-10-11 23:03:07 +0200 |
---|---|---|
committer | Vincent Douillet <vincent@vdouillet.fr> | 2021-10-11 23:03:07 +0200 |
commit | 6ee862efd612832e88b154105afe4715fd1cc78b (patch) | |
tree | f3e4d2be1615d9e37a9a120b18bee6aa3bbadf6a |
first commit
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | 20210911-openbsd-simple-git-server.md | 94 | ||||
-rw-r--r-- | 20210919-raspberry-pi-white-noise-machine.md | 56 | ||||
-rw-r--r-- | 20211011-browsing-gems.md | 20 | ||||
-rw-r--r-- | Makefile | 28 | ||||
-rw-r--r-- | about.md | 3 | ||||
-rw-r--r-- | template/back.html | 1 | ||||
-rw-r--r-- | template/footer.html | 4 | ||||
-rw-r--r-- | template/header.html | 26 | ||||
-rw-r--r-- | template/index.html | 8 |
10 files changed, 243 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9418501 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.swp +*.bak +output/* diff --git a/20210911-openbsd-simple-git-server.md b/20210911-openbsd-simple-git-server.md new file mode 100644 index 0000000..d27fdb6 --- /dev/null +++ b/20210911-openbsd-simple-git-server.md @@ -0,0 +1,94 @@ +# Simple git server on OpenBSD + +September 11, 2021 + +Nowadays solutions like Github or Gitlab are popular to host online git repositories. I think that these tools can be quite bloated with features that I likely won't need for my small projects. So I decided to setup a self-hosted simple git server on OpenBSD. Here is how I configured it. + +## Creating the repository + +Of course, you first need to install git. I personally chose to install the package: + + # pkg_add git + +Next you need to add a git user, which will be used to push code to the repositories: + + # adduser + Enter username []: git + Enter full name []: git + Enter shell csh git-shell ksh nologin sh [ksh]: + Uid [1001]: + Login group git [git]: + Invite git into other groups: guest no [no]: + Login class authpf bgpd daemon default pbuild staff unbound xenodm [default]: + Enter password []: xxx + Enter password again []: xxx + +Now you can import the public keys of the developers, by adding them to the file `/home/git/.ssh/authorized_keys` (one key per line). This process can be simplified with the command `ssh-copy-id` that is available on Linux systems. + +Initialise a repository, in folder `/var/www/git-repos`: + + # mkdir -p /var/www/git-repos/pelican-minimal.git + # chown -R git:www /var/www/git-repos + $ cd /var/www/git-repos/pelican-minimal.git/ + $ git init --bare + +The folder choice can seem strange but it will allow us to easily publish the repository through a website a bit later. If you want developers to be able to push code with a URL like `git@git.vdouillet.fr/git/pelican-minimal`, a link does the job: + + # ln -s /var/www/git-repos /git + +The repository is ready, developers can push code like so: + + $ git remote add origin git@git.vdouillet.fr:/git/pelican-minimal + $ git push origin master + +Though security is not optimal: developers can open a shell on the server with the git account by using their SSH key. To prevent this, we are going to change the shell of the git account to the `git-shell`. This shell refuses interactive connections: + + # chpass -s git-shell git + +It’s better, but developers can still use port forwarding. This can be disabled by prefixing each key in the `authorized_keys` file you edited earlier with the following text: + + no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty + +## Public access + +To make the repository publicly available, I’ve chosen to use [cgit](https://git.zx2c4.com/cgit/). It’s a CGI script for a web interface that also allows to clone the repository through HTTP. Let’s first install cgit: + + # pkg_add cgit + +As noted by the README after installation, you need to create a configuration file `/var/www/conf/cgitrc` for cgit. See cgitrc(5) for the complete list of parameters, here is a basic file that exposes only one repository: + + repo.url=pelican-minimal + repo.path=/git-repos/pelican-minimal + repo.clone-url=http://git.vdouillet.fr/pelican-minimal + repo.desc=minimal pelican theme + +The httpd web server still needs to be configured, the sample configuration from cgit’s README works just fine, so I copied it into `/etc/httpd.conf`: + + server "git.vdouillet.fr" { + listen on egress port 80 + + # don't serve static files from cgit CGI: cgit.css and cgit.png + location "/cgit.*" { + root "/cgit" + no fastcgi + } + root "/cgi-bin/cgit.cgi" + fastcgi socket "/run/slowcgi.sock" + } + +Finally, launch the two required daemons httpd and slowcgi: + + # rcctl enable slowcgi + # rcctl start slowcgi + # rcctl enable httpd + # rcctl start httpd + +The repository is now available via [git.vdouillet.fr](//git.vdouillet.fr). + +Constructive feedback is welcome on [Twitter](https://twitter.com/vdouillet12/status/1443303913017516037?s=20). + +## Sources + +* [Git online book](https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server) +* cgitrc(5) +* OpenBSD cgit package README diff --git a/20210919-raspberry-pi-white-noise-machine.md b/20210919-raspberry-pi-white-noise-machine.md new file mode 100644 index 0000000..666157e --- /dev/null +++ b/20210919-raspberry-pi-white-noise-machine.md @@ -0,0 +1,56 @@ +# Raspberry Pi white noise machine + +September 19, 2021 + +A white noise machine can help find sleep or mask ambient noise or even tinnitus. It can also be used to muffle conversation from potential eavesdroppers. I wanted to experiment with a white noise machine for sleep purposes so I decided to build one with a Raspberry Pi I had lying around. + +For this you will need: + +* A Raspberry Pi equipped with a jack port and an OS installed (I used a Pi 3B with Raspbian OS) +* Speakers connected to the Pi + +Actually a Pi 3 is a bit overkill for this. I have a Pi Zero lying around that could fit the bill except it needs a USB dongle to connect speakers and I don't have such a dongle. + +## Preparing the white noise + +First you need to find a white noise sample, preferably a long one. I chose to extract the sound from a 3 hour long YouTube video of a waterfall. Of course, choose what suits you. If you want to extract the sound from a YouTube video, you could use one of the many online tools but I won't recommend that to you. Instead, you can use [youtube-dl](https://github.com/ytdl-org/youtube-dl): + + $ youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=dQw4w9WgXcQ + +Some explanations for the options used: + +* `-x` asks youtube-dl to extract the audio from the video. As stated in youtube-dl's help, ffmpeg or avconv is required for this +* `--audio-format` should be self-explanatory + +## Creating a white noise service + +Next we are going to create a service to play the white noise automatically at system startup. My Raspberry Pi is running raspbian so systemd is used to manage services. Create a `/etc/systemd/system/whitenoise.service` file with the following contents: + + [Unit] + Description=White noise machine + StartLimitIntervalSec=0 + + [Service] + Type=simple + Restart=never + User=pi + ExecStart=mpg123 --loop /home/pi/whitenoise.mp3 + + [Install] + WantedBy=multi-user.target + +You should adjust your username and path to the file. I used [mpg123](https://mpg123.org/) because it's the simplest and lightest audio player I could find. Its loop option is handy to keep playing infinitely. It needs to be installed: + + # apt install mpg123 + +## Auto start, auto stop + +To start automatically the service on system startup, you just need to enable the service on startup: + + # systemctl enable whitenoise + +To stop it, you can use a cron job set at the time you want it to stop: + + 55 6 * * * sudo systemctl stop whitenoise + +This will stop the white noise at 6:55am. And that's it! Enjoy your homemade white noise machine! diff --git a/20211011-browsing-gems.md b/20211011-browsing-gems.md new file mode 100644 index 0000000..ca01d59 --- /dev/null +++ b/20211011-browsing-gems.md @@ -0,0 +1,20 @@ +# Browsing gems + +October 11, 2021 + +Lately, I've been browsing small articles that I decided to call "gems" for the purpose of this article's title. And in my opinion they are actually gems. It all stems from my recent discovery of [Gemini](https://gemini.circumlunar.space/), which is a new internet protocol. According to the project page, it "is heavier than gopher, lighter than the web, will not replace either". Basically it's like a text-based web experience. It's mostly static and clutter-free, a gemini document looks like a traditional web page after you've activated the "reading mode" of your browser, except with Gemini it's *native*. Sounds good doesn't it? Among other things I love about geminispace are the absence of ads, or annoying cookie banners, or auto-play videos, or pages that make your laptop scream while loading... I could keep listing things I don't like about the modern web, but I'm sure you've got the gist of it. + +By now you may be thinking "sounds good, how do I hop on?". All you need is a Gemini browser really. I use [Lagrange](https://gmi.skyjake.fi/lagrange/) on my computer and [Elaho](https://github.com/pitr/gemini-ios) on my phone. The [Gemini software](https://gemini.circumlunar.space/software/) page lists some clients you can choose from. What I found on Gemini (those links require a Gemini browser): + +* I found [Korean children songs](gemini://7irb.tk/dongyo/index.gmi) translated to English and explained +* I found that [SimplyNews](gemini://simplynews.metalune.xyz) allows to read the news without being suggested a thousand more articles +* I found a [Wikipedia proxy](gemini://vault.transjovian.org) +* I found a good amount of [cooking recipes](gemini://gmi.noulin.net/cooking) +* I generally found people talking about things that interested me, or sparked new thoughts + +If you've got a bit of time on your hands, I highly recommend wandering a bit in geminispace. Within a few hours you'll most likely have found some capsules (what would be sites in traditional HTTP realm) discussing topics of particular interest to you. You can start with these resources which I found great to discover content: + +* [Gedit](gemini://geddit.glv.one) is a kind of Reddit clone +* [geminispace.info](gemini://geminispace.info/search) is a search engine + +You may have also noticed a new blog layout here, which is honestly inspired by the way gemini documents are rendered in the two previously mentioned browsers. I was having issues with Pelican, which I used previously, so I decided to develop my own static generator. It's all achieved with a Makefile that you can find on my git page. As it is, it's quite bare and I may improve it a bit in the future... Who knows, maybe I'll add some Gemini capsule magic to it ;) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e3e185d --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +MD=markdown +articles=20211011-browsing-gems.html 20210919-raspberry-pi-white-noise-machine.html 20210911-openbsd-simple-git-server.html +static=about.html + +site : index $(articles) $(static) + +index : + cat template/header.html > output/index.html + echo '<body>' >> output/index.html + cat template/index.html >> output/index.html + echo '</body>' >> output/index.html + cat template/footer.html >> output/index.html + +# compile each article +%.html : %.md + cat template/header.html > tmp.html + echo '<article>' >> tmp.html + $(MD) $< >> tmp.html + cat template/back.html >> tmp.html + cat template/footer.html >> tmp.html + echo '</article>' >> tmp.html + mv tmp.html output/`echo $@ | cut -d'-' -f2- -` + +clean : + rm -rf output/* + +upload : + rsync -avc --delete output/ vincent@blog.vdouillet.fr:/var/www/htdocs/blog/ diff --git a/about.md b/about.md new file mode 100644 index 0000000..13c94bc --- /dev/null +++ b/about.md @@ -0,0 +1,3 @@ +My name is Vincent, I live in France. I like simple things, (old) computers, nature and music. Here I mostly talk about IT stuff but I may sometimes digress. We can get in touch on [Twitter](https://twitter.com/vdouillet12). + +In order to stay in line with the "simple" value stated above, this blog is completely static. It is generated using [a custom Makefile](//git.vdouillet.fr/blog) and is proudly hosted on [OpenBSD Amsterdam](https://openbsd.amsterdam). On here you will find no JavaScript, no cookies, no trackers. The CSS style sheet is very simple because content formatting relies mostly on HTML tags. This enables this blog to auto-magically adapt to your device size and to be compatible with CLI web browsers. diff --git a/template/back.html b/template/back.html new file mode 100644 index 0000000..bb16a7a --- /dev/null +++ b/template/back.html @@ -0,0 +1 @@ +<p class="noprint"><a href="/">< back to homepage</a></p> diff --git a/template/footer.html b/template/footer.html new file mode 100644 index 0000000..332550f --- /dev/null +++ b/template/footer.html @@ -0,0 +1,4 @@ + <hr/> + <footer> + <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a> <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/80x15.png" /></a> + </footer> diff --git a/template/header.html b/template/header.html new file mode 100644 index 0000000..33d468b --- /dev/null +++ b/template/header.html @@ -0,0 +1,26 @@ +<!DOCTYPE html> +<html lang="en"> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<title>blog.vdouillet.fr</title> +<style> + @media (prefers-color-scheme: dark){ + body {color:#fff;background:#000} + a:link {color:#9cf} + a:hover, a:visited:hover {color:#cef} + a:visited {color:#c9f} + } + body{ + margin:1em auto; + max-width:40em; + padding:0 .62em; + font:1.2em/1.62 sans-serif; + } + h1,h2,h3{line-height:1.2} + footer{text-align:center} + pre{overflow-x:auto} + @media print{ + body{max-width:none;font-size:1em} + .noprint{display:none} + } +</style> diff --git a/template/index.html b/template/index.html new file mode 100644 index 0000000..a5f7fc7 --- /dev/null +++ b/template/index.html @@ -0,0 +1,8 @@ +<header> + <p>Hello and welcome, my name is Vincent and you've landed on the small space where I ramble mainly about IT and occasionally other topics. You can check my articles below, my <a href="//git.vdouillet.fr" title="git.vdouillet.fr">git repos</a> or the <a href="/about.html" title="about">about</a> page.</p> +</header> +<ul> + <li><a href="/browsing-gems.html" title="Browsing gems">10-11-2021 Browsing gems</a></li> + <li><a href="/raspberry-pi-white-noise-machine.html" title="Raspberry Pi white noise machine">09-29-2021 Raspberry Pi white noise machine</a></li> + <li><a href="/openbsd-simple-git-server.html" title="Simple git server on OpenBSD">09-11-2021 Simple git server on OpenBSD</a></li> +</ul> |