Refactored syntax highlighting shortcodes into markdown
This commit is contained in:
parent
9e6bb1a3e5
commit
ea435049b3
71 changed files with 297 additions and 297 deletions
|
@ -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 <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 >}}
|
||||
```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 >}}
|
||||
```
|
||||
|
|
|
@ -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 >}}
|
||||
```
|
||||
|
|
|
@ -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 >}}
|
||||
```
|
||||
|
|
|
@ -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 >}}
|
||||
```
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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 >}}
|
||||
```
|
||||
|
|
|
@ -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 >}}
|
||||
```
|
||||
|
|
|
@ -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 >}}
|
||||
```
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
<osm-script>
|
||||
<query type="node">
|
||||
<has-kv k="amenity" v="recycling"/>
|
||||
|
@ -22,6 +22,6 @@ Go to http://overpass-turbo.eu/ and enter a filter script similar to the followi
|
|||
<!-- print results -->
|
||||
<print mode="body"/>
|
||||
</osm-script>
|
||||
{{< /highlight >}}
|
||||
```
|
||||
|
||||
This example will highlight the recycling points near a target location. From there you can build almost any filter you can think of!
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 >}}
|
||||
```
|
||||
|
|
|
@ -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 >}}
|
||||
```
|
||||
|
|
|
@ -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 >}}
|
||||
```
|
||||
|
|
|
@ -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 >}}
|
||||
```
|
||||
|
|
|
@ -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 >}}
|
||||
```
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 <EMAIL> XXXXXX
|
||||
boinccmd --host localhost --passwd graou --project_attach http://setiathome.berkeley.edu <ACCOUNT_KEY>
|
||||
{{< /highlight >}}
|
||||
```
|
||||
|
|
|
@ -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 >}}
|
||||
```
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue