Rewrote the whole website to get rid on a heavy theme

This commit is contained in:
Julien Dessaux 2021-03-11 18:53:14 +01:00
parent 3ea54810ad
commit 60d3abc6ec
122 changed files with 346 additions and 2558 deletions

View file

@ -0,0 +1,5 @@
---
title: "Miscellaneous"
linkTitle: "Miscellaneous"
weight: 40
---

View file

@ -0,0 +1,38 @@
---
title: "Some bacula/bareos commands"
linkTitle: "Some bacula/bareos commands"
date: 2018-01-10
description: >
Some bacula/bareos commands
---
Bacula is a backup software, bareos is a fork of it. Here are some tips and solutions to specific problems.
## Adjust an existing volume for pool configuration changes
In bconsole, run the following commands and follow the prompts :
{{< highlight 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 >}}
bextract -V <volume names separated by |> <device-name>
<directory-to-store-files>
{{< /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 >}}
select nextval('basefiles_baseid_seq');
{{< /highlight >}}
You can then fix it with :
{{< highlight sql >}}
alter table BaseFiles alter column baseid set data type bigint;
{{< /highlight >}}

View file

@ -0,0 +1,15 @@
---
title: "Bash tcp client"
linkTitle: "Bash tcp client"
date: 2018-03-21
description: >
Bash tcp client
---
There are somea fun toys in bash. I would not rely on it for a production script, but here is one such things :
{{< highlight sh >}}
exec 5<>/dev/tcp/10.1.0.254/8080
bash$ echo -e "GET / HTTP/1.0\n" >&5
bash$ cat <&5
{{< /highlight >}}

View file

@ -0,0 +1,16 @@
---
title: "Boot from initramfs shell"
linkTitle: "Boot from initramfs shell"
date: 2014-01-24
description: >
Boot from initramfs shell
---
I had to finish booting from an initramfs shell, here is how I used `switch_root` to do so :
{{< highlight 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 >}}

View file

@ -0,0 +1,29 @@
---
title: "Building rpm packages"
linkTitle: "Building rpm packages"
date: 2016-02-22
description: >
Building rpm packages
---
Here is how to build locally an rpm package. Tested at the time on a centos 7.
## Setup your environment
First of all, you have to use a non-root account.
- Create the necessary directories : `mkdir -p ~/rpmbuild/{BUILD,RPMS,S{OURCE,PEC,RPM}S}`
- Tell rpmbuild where to build by adding the following in your `.rpmmacros` file : `echo -e “%_topdir\t$HOME/rpmbuild” » ~/.rpmmacros`
## Building package
There are several ways to build a rpm, depending on what kind of stuff you have to deal with.
### Building from a tar.gz archive containing a .spec file
Run the following on you .tar.gz archive : `rpmbuild -tb memcached-1.4.0.tar.gz`. When the building process ends, you will find your package in a `$HOME/rpmbuild/RPMS/x86_64/` like directory, depending on your architecture.
### Building from a spec file
- `rpmbuild -v -bb ./contrib/redhat/collectd.spec`
- If you are missing some dependencies : `rpmbuild -v -bb ./contrib/redhat/collectd.spec 2>&1 |awk '/is needed/ {print $1;}'|xargs yum install -y`

View file

@ -0,0 +1,11 @@
---
title: "Clean old centos kernels"
linkTitle: "Clean old centos kernels"
date: 2016-02-03
description: >
Clean old centos kernels
---
There is a setting in `/etc/yum.conf` that does exactly that : `installonly_limit=`. The value of this setting is the number of older kernels that are kept when a new kernel is installed by yum. If the number of installed kernels becomes greater than this, the oldest one gets removed at the same time a new one is installed.
This cleaning can also be done manually with a command that belongs to the yum-utils package : `package-cleanup oldkernels count=2`

View file

@ -0,0 +1,14 @@
---
title: "Investigate postgresql disk usage"
linkTitle: "Investigate postgresql disk usage"
date: 2015-11-24
description: >
Investigate postgresql disk usage
---
## How to debug disk occupation in postgresql
- get a database oid number from `ncdu` in `/var/lib/postgresql`
- reconcile oid number and db name with : `select oid,datname from pg_database where oid=18595;`
- Then in database : `select table_name,pg_relation_size(quote_ident(table_name)) from information_schema.tables where table_schema = 'public' order by 2;`

View file

@ -0,0 +1,38 @@
---
title: "etc-update script for alpine linux"
linkTitle: "etc-update script for alpine linux"
date: 2019-04-02
description: >
etc-update script for alpine linux
---
Alpine linux doesn't seem to have a tool to merge pending configuration changes, so I wrote one :
{{< highlight sh >}}
#!/bin/sh
set -eu
for new_file in $(find /etc -iname '*.apk-new'); do
current_file=${new_file%.apk-new}
echo "===== New config file version for $current_file ====="
diff ${current_file} ${new_file} || true
while true; do
echo "===== (r)eplace file with update? (d)iscard update? (m)erge files? (i)gnore ====="
PS2="k/d/m/i? "
read choice
case ${choice} in
r)
mv ${new_file} ${current_file}
break;;
d)
rm -f ${new_file}
break;;
m)
vimdiff ${new_file} ${current_file}
break;;
i)
break;;
esac
done
done
{{< /highlight >}}

View file

@ -0,0 +1,9 @@
---
title: "Use spaces in fstab"
linkTitle: "Use spaces in fstab"
date: 2011-09-29
description: >
How to use spaces in a folder name in fstab
---
Here is how to use spaces in a folder name in fstab : you put `\040` where you want a space.

View file

@ -0,0 +1,32 @@
---
title: "i3dropdown"
linkTitle: "i3dropdown"
date: 2020-01-23
description: >
i3dropdown
---
i3dropdown is a tool to make any X application drop down from the top of the screen, in the famous quake console style back in the day.
## Compilation
First of all, you have get i3dropdown and compile it. It does not have any dependencies so it is really easy :
{{< highlight 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 >}}
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.

View file

@ -0,0 +1,9 @@
---
title: "Removing libreoffice write protection"
linkTitle: "Removing libreoffice write protection"
date: 2018-03-05
description: >
Removing libreoffice write protection
---
You can choose to ignore write-protection by setting `Tools > Options > libreOffice Writer > Formatting Aids > Protected Areas > Ignore protection`.

View file

@ -0,0 +1,10 @@
---
title: "Link to a deleted inode"
linkTitle: "Link to a deleted inode"
date: 2018-03-05
description: >
Link to a deleted inode
---
Get the inode number from `lsof`, then run `debugfs -w /dev/mapper/vg-home -R 'link <16008> /some/path'` where 16008 is the inode number (the < > are important, they tell debugfs you manipulate an inode). The path is relative to the root of the block device you are restoring onto.

View file

@ -0,0 +1,10 @@
---
title: "Understanding make"
linkTitle: "Understanding make"
date: 2018-01-30
description: >
Understanding make
---
http://gromnitsky.users.sourceforge.net/articles/notes-for-new-make-users/

View file

@ -0,0 +1,21 @@
---
title: "Aggregate images into a video with mencoder"
linkTitle: "Aggregate images into a video with mencoder"
date: 2018-04-30
description: >
Aggregate images into a video withmencoder
---
## Aggregate png images into a video
{{< highlight 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 >}}
mf://@list.txt
{{< /highlight >}}
## References
- http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-enc-images.html

View file

@ -0,0 +1,29 @@
---
title: "Installing mssql on centos 7"
linkTitle: "Installing mssql on centos 7"
date: 2019-07-09
description: >
Installing mssql on centos 7
---
{{< highlight 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
curl -o /etc/yum.repos.d/mssql-prod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
yum update
yum install -y mssql-server mssql-tools
yum install -y sudo
localectl set-locale LANG=en_US.utf8
echo "export LANG=en_US.UTF-8" >> /etc/profile.d/locale.sh
echo "export LANGUAGE=en_US.UTF-8" >> /etc/profile.d/locale.sh
yum install -y openssh-server
systemctl enable sshd
systemctl start sshd
passwd
/opt/mssql/bin/mssql-conf setup
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -p
{{< /highlight >}}

View file

@ -0,0 +1,12 @@
---
title: "Cannot login role into postgresql"
linkTitle: "Cannot login role into postgresql"
date: 2015-11-24
description: >
Cannot login role into postgresql
---
{{< highlight sh >}}
ALTER ROLE "user" LOGIN;
{{< /highlight >}}

View file

@ -0,0 +1,25 @@
---
title: "LDAP auth with nginx"
linkTitle: "LDAP auth with nginx"
date: 2018-03-05
description: >
LDAP auth with nginx
---
{{< highlight sh >}}
ldap_server ldap {
auth_ldap_cache_enabled on;
auth_ldap_cache_expiration_time 10000;
auth_ldap_cache_size 1000;
url "ldaps://ldapslave.adyxax.org/ou=Users,dc=adyxax,dc=org?uid?sub?(objectClass=posixAccount)";
binddn "cn=admin,dc=adyxax,dc=org";
binddn_passwd secret;
group_attribute memberUid;
group_attribute_is_dn off;
satisfy any;
require valid_user;
#require group "cn=admins,ou=groups,dc=adyxax,dc=org";
}
{{< /highlight >}}

View file

@ -0,0 +1,19 @@
---
title: "OpenStreetMap overlay example"
linkTitle: "OpenStreetMap overlay example"
date: 2020-05-19
description: >
An example of how to query things visually on OpenStreetMap
---
http://overpass-turbo.eu/
{{< highlight html >}}
<osm-script>
<query type="node">
<has-kv k="amenity" v="recycling"/>
<bbox-query {{bbox}}/>
</query>
<!-- print results -->
<print mode="body"/>
</osm-script>
{{< /highlight >}}

View file

@ -0,0 +1,117 @@
---
title: "Pleroma installation notes"
linkTitle: "Pleroma installation notes"
date: 2018-11-16
description: >
Pleroma installation notes
---
This article is about my installation of pleroma in a standard alpine linux lxd container.
## Installation notes
{{< highlight 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
rc-update add postgresql default
cd /srv
git clone https://git.pleroma.social/pleroma/pleroma
cd pleroma/
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 >}}
su - postgres
psql
CREATE USER pleroma WITH ENCRYPTED PASSWORD 'XXXXXXXXXXXXXXXXXXX';
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 >}}
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 >}}
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 >}}
### 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 inactive=200m use_temp_path=off;
ssl_session_cache shared:ssl_session_cache:10m;
server {
listen 80;
listen [::]:80;
server_name social.adyxax.org;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name social.adyxax.org;
root /usr/share/nginx/html;
include /etc/nginx/vhost.d/social.conf;
ssl_certificate /etc/nginx/fullchain;
ssl_certificate_key /etc/nginx/privkey;
}
# }}}
### in a vhost.d/social.conf ###
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://172.16.1.8:4000/;
add_header 'Access-Control-Allow-Origin' '*';
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
allow all;
}
location /proxy {
proxy_cache pleroma_media_cache;
proxy_cache_lock on;
proxy_pass http://172.16.1.8:4000$request_uri;
}
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 >}}
adduser -s /sbin/nologin -D -h /srv/pleroma pleroma
cp -a /root/.hex/ /srv/pleroma/.
cp -a /root/.mix /srv/pleroma/.
chown -R pleroma:pleroma /srv/pleroma/uploads
cp installation/init.d/pleroma /etc/init.d
sed -i /etc/init.d/pleroma -e '/^directory=/s/=.*/=\/srv\/pleroma/'
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 >}}
mix set_moderator adyxax
{{< /highlight >}}
## References
- https://git.pleroma.social/pleroma/pleroma

View file

@ -0,0 +1,17 @@
---
title: "Grant postgresql read only access"
linkTitle: "Grant postgresql read only access"
date: 2015-11-24
description: >
Grant postgresql read only access
---
{{< highlight 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 >}}

View file

@ -0,0 +1,18 @@
---
title: "Change owner on a postgresql database and all tables"
linkTitle: "Change owner on a postgresql database and all tables"
date: 2012-04-20
description: >
Change owner on a postgresql database and all tables
---
{{< highlight sh >}}
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 >}}
reassign owned by "support" to "test-support";
{{< /highlight >}}

View file

@ -0,0 +1,11 @@
---
title: "Pulseaudio"
linkTitle: "Pulseaudio"
date: 2018-09-25
description: >
Pulseaudio
---
- List outputs : `pacmd list-sinks | grep -e 'name:' -e 'index'`
- Select a new one : `pacmd set-default-sink alsa_output.usb-C-Media_Electronics_Inc._USB_PnP_Sound_Device-00.analog-stereo`

View file

@ -0,0 +1,13 @@
---
title: "Purge postfix queue based on email contents"
linkTitle: "Purge postfix queue based on email contents"
date: 2009-04-27
description: >
Purge postfix queue based on email contents
---
{{< highlight sh >}}
find /var/spool/postfix/deferred/ -type f -exec grep -li 'XXX' '{}' \; | xargs -n1 basename | xargs -n1 postsuper -d
{{< /highlight >}}

View file

@ -0,0 +1,21 @@
---
title: "Qmail"
linkTitle: "Qmail"
date: 2018-03-05
description: >
Qmail
---
## Commands
- Get statistics : `qmail-qstat`
- list queued mails : `qmail-qread`
- Read an email in the queue (NNNN is the #id from qmail-qread) : `find /var/qmail/queue -name NNNN| xargs cat | less`
- Change queue lifetime for qmail in seconds (example here for 15 days) : `echo 1296000 > /var/qmail/control/queuelifetime`
## References
- http://www.lifewithqmail.org/lwq.html
- http://www.fileformat.info/tip/linux/qmailnow.htm
- https://www.hivelocity.net/kb/how-to-change-queue-lifetime-for-qmail/

View file

@ -0,0 +1,18 @@
---
title: "RocketChat"
linkTitle: "RocketChat"
date: 2019-08-06
description: >
RocketChat
---
Docker simple install :
{{< highlight 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 >}}

View file

@ -0,0 +1,17 @@
---
title: "Screen cannot open terminal error"
linkTitle: "Screen cannot open terminal error"
date: 2018-07-03
description: >
Screen cannot open terminal error
---
If you encounter :
{{< highlight sh >}}
Cannot open your terminal '/dev/pts/0' - please check.
{{< /highlight >}}
Then you did not open the shell with the user you logged in with. You can make screen happy by running :
{{< highlight sh >}}
script /dev/null
{{< /highlight >}}

View file

@ -0,0 +1,18 @@
---
title: "Seti@Home"
linkTitle: "Seti@Home"
date: 2018-03-05
description: >
Seti@Home
---
{{< highlight sh >}}
apt install boinc
echo "graou" > /var/lib/boinc-client/gui_rpc_auth.cfg
systemctl restart boinc-client
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 <EMAIL> XXXXXX
boinccmd --host localhost --passwd graou --project_attach http://setiathome.berkeley.edu <ACCOUNT_KEY>
{{< /highlight >}}

View file

@ -0,0 +1,16 @@
---
title: "Sqlite pretty print"
linkTitle: "Sqlite pretty print"
date: 2019-06-19
description: >
Sqlite pretty print
---
- In ~/.sqliterc :
{{< highlight sh >}}
.mode column
.headers on
.separator ROW "\n"
.nullvalue NULL
{{< /highlight >}}

View file

@ -0,0 +1,58 @@
---
title: "Switching to Hugo"
linkTitle: "Switching to Hugo"
date: 2019-12-19
description: >
I switched my personal wiki from dokuwiki to Hugo
---
This is the website you are currently reading. It is a static website built using hugo. This article details how I installed hugo, how I initialised this website and how I manage it. I often refer to it as wiki.adyxax.org because I hosted a unique dokuwiki for a long time as my main website (and a pmwiki before that), but with hugo it has become more than that. It is now a mix of wiki, blog and showcase of my work and interests.
## Installing hugo
{{< highlight sh >}}
go get github.com/gohugoio/hugo
{{< / highlight >}}
You probably won't encounter this issue but this command failed at the time I installed hugo because the master branch in one of the dependencies was
tainted. I fixed it with by using a stable tag for this project and continue installing hugo from there:
{{< highlight sh >}}
cd go/src/github.com/tdewolff/minify/
tig --all
git checkout v2.6.1
go get github.com/gohugoio/hugo
{{< / highlight >}}
This did not build me the extended version of hugo that I need for the [docsy](https://github.com/google/docsy) theme I chose, so I had to get it by doing :
{{< highlight sh >}}
cd ~/go/src/github.com/gohugoio/hugo/
go get --tags extended
go install --tags extended
{{< / highlight >}}
## Bootstraping this site
{{< highlight sh >}}
hugo new site www
cd www
git init
git submodule add https://github.com/google/docsy themes/docsy
{{< / highlight >}}
The docsy theme requires two nodejs programs to run :
{{< highlight sh >}}
npm install -D --save autoprefixer
npm install -D --save postcss-cli
{{< / highlight >}}
## hugo commands
To spin up the live server for automatic rebuilding the website when writing articles :
{{< highlight sh >}}
hugo server --bind 0.0.0.0 --minify --disableFastRender
{{< / highlight >}}
To publish the website in the `public` folder :
{{< highlight sh >}}
hugo --minify
{{< / highlight >}}