From ea435049b3a3f5057b3a894040df3cf4f3256d9e Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 23 Apr 2023 22:33:49 +0200 Subject: Refactored syntax highlighting shortcodes into markdown --- content/blog/miscellaneous/bacula-bareos.md | 16 ++++++------- content/blog/miscellaneous/bash-tcp-client.md | 4 ++-- content/blog/miscellaneous/boot-from-initramfs.md | 4 ++-- content/blog/miscellaneous/etc-update-alpine.md | 4 ++-- content/blog/miscellaneous/i3dropdown.md | 8 +++---- content/blog/miscellaneous/link-deleted-inode.md | 4 ++-- content/blog/miscellaneous/mencoder.md | 8 +++---- content/blog/miscellaneous/mirroring-to-github.md | 4 ++-- content/blog/miscellaneous/mssql-centos-7.md | 4 ++-- .../my-postgresql-role-cannot-login.md | 4 ++-- content/blog/miscellaneous/nginx-ldap.md | 4 ++-- .../blog/miscellaneous/nginx-rewrite-break-last.md | 16 ++++++------- content/blog/miscellaneous/osm-overlay-example.md | 4 ++-- content/blog/miscellaneous/pleroma.md | 28 +++++++++++----------- content/blog/miscellaneous/postgresql-read-only.md | 4 ++-- content/blog/miscellaneous/postgresql-reassign.md | 8 +++---- .../purge-postfix-queue-based-content.md | 4 ++-- .../blog/miscellaneous/reusing-ssh-connections.md | 4 ++-- content/blog/miscellaneous/rocketchat.md | 4 ++-- .../miscellaneous/screen-cannot-open-terminal.md | 8 +++---- content/blog/miscellaneous/seti-at-home.md | 4 ++-- content/blog/miscellaneous/sqlite-pretty-print.md | 4 ++-- content/blog/miscellaneous/tc.md | 4 ++-- 23 files changed, 78 insertions(+), 78 deletions(-) (limited to 'content/blog/miscellaneous') diff --git a/content/blog/miscellaneous/bacula-bareos.md b/content/blog/miscellaneous/bacula-bareos.md index 19111c3..6fdf648 100644 --- a/content/blog/miscellaneous/bacula-bareos.md +++ b/content/blog/miscellaneous/bacula-bareos.md @@ -13,28 +13,28 @@ Bacula is a backup software, bareos is a fork of it. Here are some tips and solu ## Adjust an existing volume for pool configuration changes In bconsole, run the following commands and follow the prompts : -{{< highlight sh >}} +```sh update pool from resource update all volumes in pool -{{< /highlight >}} +``` ## Using bextract On the sd you need to have a valid device name with the path to your tape, then run : -{{< highlight sh >}} +```sh bextract -V -{{< /highlight >}} +``` ## Integer out of range sql error If you get an sql error `integer out of range` for an insert query in the catalog, check the id sequence for the table which had the error. For example with the basefiles table : -{{< highlight sql >}} +```sql select nextval('basefiles_baseid_seq'); -{{< /highlight >}} +``` You can then fix it with : -{{< highlight sql >}} +```sql alter table BaseFiles alter column baseid set data type bigint; -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/bash-tcp-client.md b/content/blog/miscellaneous/bash-tcp-client.md index 2f31d14..e3246ef 100644 --- a/content/blog/miscellaneous/bash-tcp-client.md +++ b/content/blog/miscellaneous/bash-tcp-client.md @@ -10,8 +10,8 @@ tags: There are some fun toys in bash. I would not rely on it for a production script, but here is one such things : -{{< highlight sh >}} +```sh exec 5<>/dev/tcp/10.1.0.254/8080 bash$ echo -e "GET / HTTP/1.0\n" >&5 bash$ cat <&5 -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/boot-from-initramfs.md b/content/blog/miscellaneous/boot-from-initramfs.md index df740b6..759219f 100644 --- a/content/blog/miscellaneous/boot-from-initramfs.md +++ b/content/blog/miscellaneous/boot-from-initramfs.md @@ -14,9 +14,9 @@ Sometimes, your linux machine can get stuck while booting and drop you into an i All initramfs are potentially different, but almost always feature busybox and common mechanisms. Recently I had to finish booting from an initramfs shell, here is how I used `switch_root` to do so : -{{< highlight sh >}} +```sh lvm vgscan lvm vgchange -ay vg mount -t ext4 /dev/mapper/vg-root /root exec switch_root -c /dev/console /root /sbin/init -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/etc-update-alpine.md b/content/blog/miscellaneous/etc-update-alpine.md index 20461d9..86fdcae 100644 --- a/content/blog/miscellaneous/etc-update-alpine.md +++ b/content/blog/miscellaneous/etc-update-alpine.md @@ -10,7 +10,7 @@ tags: ## The script Alpine linux doesn't seem to have a tool to merge pending configuration changes, so I wrote one : -{{< highlight sh >}} +```sh #!/bin/sh set -eu @@ -37,4 +37,4 @@ for new_file in $(find /etc -iname '*.apk-new'); do esac done done -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/i3dropdown.md b/content/blog/miscellaneous/i3dropdown.md index fa10db4..31c0a52 100644 --- a/content/blog/miscellaneous/i3dropdown.md +++ b/content/blog/miscellaneous/i3dropdown.md @@ -14,21 +14,21 @@ i3dropdown is a tool to make any X application drop down from the top of the scr ## Compilation First of all, you have get i3dropdown and compile it. It does not have any dependencies so it is really easy : -{{< highlight sh >}} +```sh git clone https://gitlab.com/exrok/i3dropdown cd i3dropdown make cp build/i3dropdown ~/bin/ -{{< /highlight >}} +``` ## i3 configuration Here is a working example of the pavucontrol app, a volume mixer I use : -{{< highlight conf >}} +```cfg exec --no-startup-id i3 --get-socketpath > /tmp/i3wm-socket-path for_window [instance="^pavucontrol"] floating enable bindsym Mod4+shift+p exec /home/julien/bin/i3dropdown -W 90 -H 50 pavucontrol pavucontrol-qt -{{< /highlight >}} +``` To work properly, i3dropdown needs to have the path to the i3 socket. Because the command to get the socketpath from i3 is a little slow, it is best to cache it somewhere. By default i3dropdown recognises `/tmp/i3wm-socket-path`. Then each window managed by i3dropdown needs to be floating. The last line bind a key to invoke or mask the app. diff --git a/content/blog/miscellaneous/link-deleted-inode.md b/content/blog/miscellaneous/link-deleted-inode.md index c16ea78..171986f 100644 --- a/content/blog/miscellaneous/link-deleted-inode.md +++ b/content/blog/miscellaneous/link-deleted-inode.md @@ -15,8 +15,8 @@ Sometimes a file gets deleted by mistake, but thankfully it is still opened by s Get the inode number from `lsof` (or from `fstat` if you are on a modern system), then run something like the following : -{{< highlight sh >}} +```sh debugfs -w /dev/mapper/vg-home -R 'link <16008> /some/path' -{{< /highlight >}} +``` In this example 16008 is the inode number you want to link to (the < > are important, they tell debugfs you are manipulating an inode). Beware that **the path is relative to the root of the block device** you are restoring onto. diff --git a/content/blog/miscellaneous/mencoder.md b/content/blog/miscellaneous/mencoder.md index 4eeb5a9..7487e69 100644 --- a/content/blog/miscellaneous/mencoder.md +++ b/content/blog/miscellaneous/mencoder.md @@ -9,14 +9,14 @@ tags: ## Aggregate png images into a video Example command : -{{< highlight sh >}} +```sh mencoder mf://*.png -mf w=1400:h=700:fps=1:type=png -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi -{{< /highlight >}} +``` You should use the following to specify a list of files instead of `*.png`: -{{< highlight sh >}} +```sh mf://@list.txt -{{< /highlight >}} +``` ## References diff --git a/content/blog/miscellaneous/mirroring-to-github.md b/content/blog/miscellaneous/mirroring-to-github.md index ab42914..78615d0 100644 --- a/content/blog/miscellaneous/mirroring-to-github.md +++ b/content/blog/miscellaneous/mirroring-to-github.md @@ -16,13 +16,13 @@ It turns out it is quite simple. First you will need to generate a [github acces Then you create a git hook with a script that looks like the following : -{{< highlight sh >}} +```sh #!/usr/bin/env bash set -eu git push --mirror --quiet https://adyxax:TOKEN@github.com/adyxax/www.git &> /dev/null echo 'github updated' -{{< /highlight >}} +``` Just put your token there, adjust your username and the repository path then it will work. I am using this in `post-receive` hooks on my git server on several repositories without any issue. diff --git a/content/blog/miscellaneous/mssql-centos-7.md b/content/blog/miscellaneous/mssql-centos-7.md index 8ba44e6..cf87a87 100644 --- a/content/blog/miscellaneous/mssql-centos-7.md +++ b/content/blog/miscellaneous/mssql-centos-7.md @@ -15,7 +15,7 @@ I had to do this in order to help a friend, I do not think I would ever willingl ## Procedure Here is how to setup mssql on a fresh centos 7 -{{< highlight sh >}} +```sh vi /etc/sysconfig/network-scripts/ifcfg-eth0 vi /etc/resolv.conf curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo @@ -34,4 +34,4 @@ passwd rm -f /etc/localtime ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -p -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/my-postgresql-role-cannot-login.md b/content/blog/miscellaneous/my-postgresql-role-cannot-login.md index d85f3bf..0b4460e 100644 --- a/content/blog/miscellaneous/my-postgresql-role-cannot-login.md +++ b/content/blog/miscellaneous/my-postgresql-role-cannot-login.md @@ -13,6 +13,6 @@ Login is a permission on postgresql, that sometimes is not obvious it can cause ## The solution Simply log in as postgres or another administrator account and run : -{{< highlight sh >}} +```sh ALTER ROLE "user" LOGIN; -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/nginx-ldap.md b/content/blog/miscellaneous/nginx-ldap.md index deea4a4..932a87a 100644 --- a/content/blog/miscellaneous/nginx-ldap.md +++ b/content/blog/miscellaneous/nginx-ldap.md @@ -8,7 +8,7 @@ tags: ## How to -{{< highlight nginx >}} +```nginx ldap_server ldap { auth_ldap_cache_enabled on; auth_ldap_cache_expiration_time 10000; @@ -23,4 +23,4 @@ ldap_server ldap { require valid_user; #require group "cn=admins,ou=groups,dc=adyxax,dc=org"; } -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/nginx-rewrite-break-last.md b/content/blog/miscellaneous/nginx-rewrite-break-last.md index 7cb854e..6cc435e 100644 --- a/content/blog/miscellaneous/nginx-rewrite-break-last.md +++ b/content/blog/miscellaneous/nginx-rewrite-break-last.md @@ -13,7 +13,7 @@ Today I was called in escalation to debug why a set of rewrites was suddenly mis ## Outside a location block When used outside a location block, these keywords stop the rules evaluation and then evaluate to a location. Consider the following example : -{{< highlight nginx >}} +```nginx server { [...] location / { @@ -28,11 +28,11 @@ server { rewrite ([^/]+\.txt)$ /texts/$1 last; rewrite ([^/]+\.cfg)$ /configs/$1 break; } -{{< /highlight >}} +``` If you run several curls you can see the behaviour illustrated : -{{< highlight sh >}} +```sh curl http://localhost/test root # we hit the root handler without any redirect matching @@ -41,14 +41,14 @@ texts # we hit the rewrite to /texts/test.txt, which is then reevaluated and hi curl http://localhost/test.cfg configs # we hit the rewrite to /configs/test.cfg, which is then reevaluated and hits the configs location -{{< /highlight >}} +``` ## Inside a location block When used inside a location block a rewrite rule flagged last will eventually trigger a location change (it is reevaluated based on the new url) but this does not happen when break is used. Consider the following example : -{{< highlight nginx >}} +```nginx server { [...] location / { @@ -63,11 +63,11 @@ server { return 200 'configs'; } } -{{< /highlight >}} +``` If you run several curls you can see the behaviour illustrated : -{{< highlight sh >}} +```sh curl http://localhost/test root # we hit the root handler without any redirect matching @@ -76,7 +76,7 @@ texts # we hit the rewrite to /texts/test.txt, which is then reevaluated and hi curl http://localhost/test.cfg 404 NOT FOUND # or maybe a file if you had a test.cfg file in your root directory! -{{< /highlight >}} +``` Can you see what happened for the last test? The break statement in a location stops all evaluation, and do not reevaluate the resulting path in any location. Nginx therefore tries to serve a file from the root directory specified for the server. That is the reason we do not get either `root` or `configs` as outputs. diff --git a/content/blog/miscellaneous/osm-overlay-example.md b/content/blog/miscellaneous/osm-overlay-example.md index de31d95..bff86b5 100644 --- a/content/blog/miscellaneous/osm-overlay-example.md +++ b/content/blog/miscellaneous/osm-overlay-example.md @@ -13,7 +13,7 @@ OpenStreetMap is a great resource and there is a lot more information stored the ## The solution Go to http://overpass-turbo.eu/ and enter a filter script similar to the following : -{{< highlight html >}} +```html @@ -22,6 +22,6 @@ Go to http://overpass-turbo.eu/ and enter a filter script similar to the followi -{{< /highlight >}} +``` This example will highlight the recycling points near a target location. From there you can build almost any filter you can think of! diff --git a/content/blog/miscellaneous/pleroma.md b/content/blog/miscellaneous/pleroma.md index 725541a..15f7298 100644 --- a/content/blog/miscellaneous/pleroma.md +++ b/content/blog/miscellaneous/pleroma.md @@ -12,7 +12,7 @@ This article is about my installation of pleroma in a standard alpine linux lxd ## Installation notes -{{< highlight sh >}} +```sh apk add elixir nginx postgresql postgresql-contrib git sudo erlang-ssl erlang-xmerl erlang-parsetools \ erlang-runtime-tools make gcc build-base vim vimdiff htop curl /etc/init.d/postgresql start @@ -24,10 +24,10 @@ mix deps.get mix generate_config cp config/generated_config.exs config/prod.secret.exs cat config/setup_db.psql -{{< /highlight >}} +``` At this stage you are supposed to execute these setup_db commands in your postgres. Instead of chmoding and stuff detailed in the official documentation I execute it manually from psql shell : -{{< highlight sh >}} +```sh su - postgres psql CREATE USER pleroma WITH ENCRYPTED PASSWORD 'XXXXXXXXXXXXXXXXXXX'; @@ -35,21 +35,21 @@ CREATE DATABASE pleroma_dev OWNER pleroma; \c pleroma_dev; CREATE EXTENSION IF NOT EXISTS citext; CREATE EXTENSION IF NOT EXISTS pg_trgm; -{{< /highlight >}} +``` Now back to pleroma : -{{< highlight sh >}} +```sh MIX_ENV=prod mix ecto.migrate MIX_ENV=prod mix phx.server -{{< /highlight >}} +``` If this last command runs without error your pleroma will be available and you can test it with : -{{< highlight sh >}} +```sh curl http://localhost:4000/api/v1/instance -{{< /highlight >}} +``` If this works, you can shut it down with two C-c and we can configure nginx. This article doesn't really cover my setup since my nginx doesn't run there, and I am using letsencrypt wildcard certificates fetched somewhere else unrelated, so to simplify I only paste the vhost part of the configuration : -{{< highlight sh >}} +```sh ### in nginx.conf inside the container ### # {{{ pleroma proxy_cache_path /tmp/pleroma-media-cache levels=1:2 keys_zone=pleroma_media_cache:10m max_size=500m @@ -96,10 +96,10 @@ location /proxy { } client_max_body_size 20M; -{{< /highlight >}} +``` Now add the phx.server on boot. I run pleroma has plemora user to completely limit the permissions of the server software. The official documentation has all files belong to the user running the server, I prefer that only the uploads directory does. Since I don't run nginx from this container I also edit this out : -{{< highlight sh >}} +```sh adduser -s /sbin/nologin -D -h /srv/pleroma pleroma cp -a /root/.hex/ /srv/pleroma/. cp -a /root/.mix /srv/pleroma/. @@ -110,12 +110,12 @@ sed -i /etc/init.d/pleroma -e '/^command_user=/s/=.*/=nobody:nobody/' sed -i /etc/init.d/pleroma -e 's/nginx //' rc-update add pleroma default rc-update add pleroma start -{{< /highlight >}} +``` You should be good to go and access your instance from any web browser. After creating your account in a web browser come back to the cli and set yourself as moderator : -{{< highlight sh >}} +```sh mix set_moderator adyxax -{{< /highlight >}} +``` ## References diff --git a/content/blog/miscellaneous/postgresql-read-only.md b/content/blog/miscellaneous/postgresql-read-only.md index 48ef392..1449da3 100644 --- a/content/blog/miscellaneous/postgresql-read-only.md +++ b/content/blog/miscellaneous/postgresql-read-only.md @@ -9,10 +9,10 @@ tags: ## The solution Here is the bare minimum a user need in order to have complete read only access on a postgresql database : -{{< highlight sh >}} +```sh GRANT CONNECT ON DATABASE "db" TO "user"; \c db GRANT USAGE ON SCHEMA public TO "user"; GRANT SELECT ON ALL TABLES IN SCHEMA public TO "user"; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO "user"; -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/postgresql-reassign.md b/content/blog/miscellaneous/postgresql-reassign.md index 75644aa..999b2af 100644 --- a/content/blog/miscellaneous/postgresql-reassign.md +++ b/content/blog/miscellaneous/postgresql-reassign.md @@ -9,13 +9,13 @@ tags: ## The solution Here is the sequence of commande that will change the owner of all objects in a database from a user named "support" to another named "test-support": -{{< highlight sh >}} +```sql ALTER DATABASE name OWNER TO new_owner for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" YOUR_DB` ; do psql -c "alter table $tbl owner to NEW_OWNER" YOUR_DB ; done for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" YOUR_DB` ; do psql -c "alter table $tbl owner to NEW_OWNER" YOUR_DB ; done for tbl in `psql -qAt -c "select table_name from information_schema.views where table_schema = 'public';" YOUR_DB` ; do psql -c "alter table $tbl owner to NEW_OWNER" YOUR_DB ; done -{{< /highlight >}} +``` -{{< highlight sh >}} +```sql reassign owned by "support" to "test-support"; -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/purge-postfix-queue-based-content.md b/content/blog/miscellaneous/purge-postfix-queue-based-content.md index d131af2..3800b07 100644 --- a/content/blog/miscellaneous/purge-postfix-queue-based-content.md +++ b/content/blog/miscellaneous/purge-postfix-queue-based-content.md @@ -13,6 +13,6 @@ Sometimes a lot of spam can acacumulate in a postfix queue. ## The solution Here is a command that can search through queued emails for a certain character string (here XXX as an example) and delete the ones that contain it : -{{< highlight sh >}} +```sh find /var/spool/postfix/deferred/ -type f -exec grep -li 'XXX' '{}' \; | xargs -n1 basename | xargs -n1 postsuper -d -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/reusing-ssh-connections.md b/content/blog/miscellaneous/reusing-ssh-connections.md index 496f456..e7d949a 100644 --- a/content/blog/miscellaneous/reusing-ssh-connections.md +++ b/content/blog/miscellaneous/reusing-ssh-connections.md @@ -13,7 +13,7 @@ It is possible to share multiple sessions over a single connection. One of the a ## How to You need a directory to store the sockets for the opened sessions, I use the `~/.ssh/tmp` directory for it. Whatever you choose, make sure it exists by running `mkdir` now. Then add these two lines at the start of your `~/.ssh/config` : -{{< highlight sh >}} +```cfg ControlMaster auto ControlPath ~/.ssh/tmp/%h_%p_%r -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/rocketchat.md b/content/blog/miscellaneous/rocketchat.md index d0cc370..8cf0dbc 100644 --- a/content/blog/miscellaneous/rocketchat.md +++ b/content/blog/miscellaneous/rocketchat.md @@ -14,11 +14,11 @@ I needed to test some scripts that interact with a rocketchat instance at work. ## The commands Docker simple install : -{{< highlight sh >}} +```sh docker run --name db -d mongo --smallfiles --replSet hurricane docker exec -ti db mongo > rs.initiate() docker run -p 3000:3000 --name rocketchat --env ROOT_URL=http://hurricane --env MONGO_OPLOG_URL=mongodb://db:27017/local?replSet=hurricane --link db -d rocket.chat -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/screen-cannot-open-terminal.md b/content/blog/miscellaneous/screen-cannot-open-terminal.md index 0e2de99..f687b66 100644 --- a/content/blog/miscellaneous/screen-cannot-open-terminal.md +++ b/content/blog/miscellaneous/screen-cannot-open-terminal.md @@ -11,15 +11,15 @@ tags: ## The problem At my current workplace there are die hard screen fanatics that refuse to upgrade to tmux. Sometimes I get the following error : -{{< highlight sh >}} +```sh Cannot open your terminal '/dev/pts/0' - please check. -{{< /highlight >}} +``` ## The solution This error means that you did not open the shell with the user you logged in with. You can make screen happy by running : -{{< highlight sh >}} +```sh script /dev/null -{{< /highlight >}} +``` In this new environment your screen commands will work normally. diff --git a/content/blog/miscellaneous/seti-at-home.md b/content/blog/miscellaneous/seti-at-home.md index 681b2c8..bc8fa8b 100644 --- a/content/blog/miscellaneous/seti-at-home.md +++ b/content/blog/miscellaneous/seti-at-home.md @@ -13,7 +13,7 @@ Me and some friends were feeling nostalgics of running Seti@Home as a screensave ## The commands -{{< highlight sh >}} +```sh apt install boinc echo "graou" > /var/lib/boinc-client/gui_rpc_auth.cfg systemctl restart boinc-client @@ -21,4 +21,4 @@ boinccmd --host localhost --passwd graou --get_messages 0 boinccmd --host localhost --passwd graou --get_state|less boinccmd --host localhost --passwd graou --lookup_account http://setiathome.berkeley.edu XXXXXX boinccmd --host localhost --passwd graou --project_attach http://setiathome.berkeley.edu -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/sqlite-pretty-print.md b/content/blog/miscellaneous/sqlite-pretty-print.md index 4a4112e..1289824 100644 --- a/content/blog/miscellaneous/sqlite-pretty-print.md +++ b/content/blog/miscellaneous/sqlite-pretty-print.md @@ -8,9 +8,9 @@ tags: ## The solution In `~/.sqliterc` add the following : -{{< highlight sh >}} +```cfg .mode column .headers on .separator ROW "\n" .nullvalue NULL -{{< /highlight >}} +``` diff --git a/content/blog/miscellaneous/tc.md b/content/blog/miscellaneous/tc.md index 58268a6..1aef7e8 100644 --- a/content/blog/miscellaneous/tc.md +++ b/content/blog/miscellaneous/tc.md @@ -8,14 +8,14 @@ tags: ## How to -{{< highlight sh >}} +```sh tc qdisc show dev eth0 tc qdisc add dev eth0 root netem delay 200ms tc qdisc show dev eth0 tc qdisc delete dev eth0 root netem delay 200ms tc qdisc show dev eth0 -{{< /highlight >}} +``` ## References -- cgit v1.2.3