From 912eeb478bb5f3d178f3c8dc8fd78387b523b3e3 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Sat, 16 Sep 2023 18:10:04 +0200 Subject: [PATCH 1/5] place posix shell warnings --- system/bash_tricks.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/system/bash_tricks.md b/system/bash_tricks.md index 67226ef..c1e05b7 100644 --- a/system/bash_tricks.md +++ b/system/bash_tricks.md @@ -1,6 +1,6 @@ --- -title: "Terminal Tips" -tags: [ "Documentation", "System" ] +title: "bash tips" +tags: [ "Documentation", "Shell", "POSIX" ] --- ## Track Live Changes @@ -67,6 +67,18 @@ Add number to variables with: `((n--))` works identically. +### POSIX WARNING + +The number commands above work in `bash`, but not in bare-ass POSIX shells, such as `dash`. + +Instead, you might do: + +```sh +x=2 +x=$(( x +1 )) +x=$(( x*x )) +``` + ## Finding Duplicate Files ```bash @@ -97,3 +109,8 @@ That gives you a random directory to mess about in. cd $dir ``` +### POSIX WARNING + +These smart-brackets are a bash feature. +If you try to use `{A..Z}` in dash, it will think of this as a single item. + From 6557ec6ebe8cf72f9830d2a49d33fe7d53369197 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Mon, 18 Sep 2023 23:44:29 +0200 Subject: [PATCH 2/5] remove dead link --- vision/imagemagick.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vision/imagemagick.md b/vision/imagemagick.md index 75c76b8..7f480e3 100644 --- a/vision/imagemagick.md +++ b/vision/imagemagick.md @@ -2,7 +2,7 @@ title: "imagemagick" tags: [ "Documentation", "Vision" ] --- -[Source](http://lxlinux.com/imagemagick.html) +[Source](https://lxlinux.com/imagemagick.html) Convert jpg to png. From ff3a3d2556a41156566febcec02c69ac2944819b Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Mon, 18 Sep 2023 23:44:39 +0200 Subject: [PATCH 3/5] spelling --- vision/imagemagick.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vision/imagemagick.md b/vision/imagemagick.md index 7f480e3..1456ea4 100644 --- a/vision/imagemagick.md +++ b/vision/imagemagick.md @@ -2,7 +2,6 @@ title: "imagemagick" tags: [ "Documentation", "Vision" ] --- -[Source](https://lxlinux.com/imagemagick.html) Convert jpg to png. @@ -41,13 +40,13 @@ convert image.jpg -resize 25% output.jpg # Trim images to border -This is generally used for transparrent images. +This is generally used for transparent images. ```bash convert -trim image.png output.png ``` -Make the white of an image transparrent. +Make the white of an image transparent. ```bash convert -transparent white -fuzz 10% input.png output.png @@ -101,7 +100,7 @@ See your installed fonts: convert -list font ``` -Make na image showing day of the week: +Make an image showing day of the week: ```bash convert -fill blue -font Sauce-Code-Pro-Semibold-Nerd-Font-Complete-Mono -gravity center -pointsize 79 label:$(date +%A) day.png From 0fc1f58d24cbc5c85d96f6056268fe3bbb872ad2 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Thu, 21 Sep 2023 01:52:54 +0200 Subject: [PATCH 4/5] add calcurse holidays --- data/calcurse.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 data/calcurse.md diff --git a/data/calcurse.md b/data/calcurse.md new file mode 100644 index 0000000..afebbfc --- /dev/null +++ b/data/calcurse.md @@ -0,0 +1,9 @@ +--- +title: "calcurse" +tags: [ "data", "calendar", "daylight savings" ] +--- + +## Setup + +The UK government keeps an ics file with clock, [here](https://www.gov.uk/when-do-the-clocks-change/united-kingdom.ics). + From b24a330f7a02f4d2d0144666c871dec6464f283f Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Thu, 21 Sep 2023 02:01:24 +0200 Subject: [PATCH 5/5] add radicale with nginx --- data/radicale.md | 126 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 data/radicale.md diff --git a/data/radicale.md b/data/radicale.md new file mode 100644 index 0000000..d6586ed --- /dev/null +++ b/data/radicale.md @@ -0,0 +1,126 @@ +--- +title: "radicale and nginx" +tags: [ "data", "calendar" ] +--- + +Check before you start: + +- you have a normally running site on nginx already. +- your server has the directory `/etc/nginx/sites-enabled/` enabled in the nginx config. + +## Installation and Service + +Install `radicale` through your package manager (not `pip`). +The standard `radicale` package should come with a nice `systemd` service file. + +If the service comes already-started, stop it immediately: + +```bash +sudo systemctl stop radicale +``` + +## Set up Passwords + +Edit `/etc/radicale/config`, changing the `[auth]` section from this: + +``` +#type = none +``` + +...to this: +``` +#type = htpasswd +``` + +If the service is started, restart it to make sure nobody can sign in without a password. + + +Next, find the `htpasswd` program. +You might get it in the `apache` package or similar. + +`htpasswd` allows you to generate passwords for users, and place them in `/etc/radicale/users`. + +```bash +PASS="$(xkcdpass) +htpasswd -nb $USER "$PASS" | sudo tee -a /etc/radicale/users +echo "Your username is $USER" +echo "Your password is $PASS" +``` +Right now, you can't sign into the server except through the localhost, which is pointless. +So now we add a subdomain to `nginx`. + +```nginx + +echo ' + server { + if ($host = cal.DOMAIN) { + return 301 https://$host$request_uri; + } # managed by Certbot + + + listen 80; + server_name cal.DOMAIN; + + location / { + proxy_pass http://localhost:5232; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + return 301 https://$server_name$request_uri; + + +} + + server { + listen 443 ssl; + server_name cal.DOMAIN; + ssl_certificate /etc/letsencrypt/live/cal.DOMAIN/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/cal.DOMAIN/privkey.pem; # managed by Certbot + + location / { + proxy_pass http://localhost:5232; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + +} +' > /etc/nginx/sites-available/radicale +sudo ln -s /etc/nginx/sites-available/radicale /etc/nginx/sites-enables/ +``` + +Finally, replace the example `DOMAIN` with your actual domain name. + +```bash +DOMAIN=whatever.com +sudo sed -i "s/DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/radicale + +``` + +(optional: replace that `cal.` prefix with anything else) + +Check nginx is happy: + + +```bash +sudo nginx -t +``` +You will almost certainly need a new SSL certificate for the site: + +```bash +sudo certbod -d cal.$DOMAIN +``` + +Start or restart both services: + + +```bash +sudo systemctl start radicale +sudo systemctl restart nginx +``` + +You should now be able to log into your calendar, and add it to a phone. + +NB: you don't need the port number.