The ccache software maintains a cache to store compilation artefacts, so the next time you compile the same source file, you can get the compiled code from the cache. That speeds up a lot recompilation. At Nasqueron, ccache is useful to speed up Poudriere builds to test FreeBSD ports. To be able to follow if […]
Read moreSwitch NetBox custom field type from Object to Multiple objects
Nasqueron uses NetBox as source of truth for its network. It’s mainly use for IPAM to store IP configuration, both for our private network and the public addresses. NetBox allows to create custom fields to store extra information in addition to the base model.We leveraged this to add default gateway, an information useful to configure […]
Read moreImplement /.well-known/change-password
The /.well-known/change-password is a new URL provided by Safari to allow to redirect the user on the location they can change their password.
Read moreFind TCL headers and libraries in Debian and FreeBSD
Problem. You want to compile a software against TCL. You run ./configure, but it can’t find it. You so need to locate where are the headers and the libraries. Solution. Start with the TCL version. On Debian: headers are in a subdirectory in /usr/include, named tcl followed by the version libraries are sorted by architecture, […]
Read moreFOSDEM PGP Key signing party FAQ
FOSDEM organizes each year one of the largest keysigning event for PGP keys. When we come back from a key signing party, what to do? Here a FAQ with some useful notes about how I sign the keys. Sign other keys Bad practice: don’t upload keys you’ve just signed to the PGP server At the […]
Read moreDeploy a darkbot or a simple generic service with SaltStack (part 2)
This is the part 2 of our service deployment walkthrough. See also: Part 1 — Service accounts, sudo capabilities In the first part, we’ve seen how to create an user account for the service, a group to put users with access to the service into, and sudo capabilities to allow full control on the service […]
Read moreDeploy a darkbot or a simple generic service with SaltStack (part 1)
SaltStack is one of the main configuration as code software. Written in Python, it uses Jinja templates. It can be easily used to deploy a service, like here a C application. In this post, we’ll walk through the different steps to deploy the service and allow it to be managed by relevant trusted users, without […]
Read moreDocker: nasqueron/nginx-php-fpm
Follow-up: a BASH script to split a MySQL dump by database
In this post, we’ve seen how to split a large MySQL dump by database. I’ve been asked a script to automate the process. Here you are. Note: On FreeBSD, replace AWK=awk by AWK=gawk and install lang/gawk port, so we can use GNU awk.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#!/usr/bin/env bash AWK=awk REGEX_NAME="Current Database: `(.*)`" # Checks argument and prints usage if needed if [ "$#" -lt "1" ] then echo "Usage: $0 <dump.sql>" exit 1 fi # Splits dump into temporary files $AWK '/Current Database\: .*/{g++} { print $0 > g".tmpsql" }' $1 # Renames files or appends to existing one (to handle views) for f in *.tmpsql do DATABASE_LINE=`head -n1 $f` [[ $DATABASE_LINE =~ $REGEX_NAME ]] TARGET_FILE="${BASH_REMATCH[1]}.sql" if [ -f $TARGET_FILE ]; then cat $f >> $TARGET_FILE rm $f else mv $f ${BASH_REMATCH[1]}.sql fi done |
Split a large SQL dump by database
You created a MySQL backup of a large server installation with dozens of databases and wish to get the schema and data for one of them. You now have to deal with a file of hundreds of MB in a text editor. How convenient. Split a dump into several files You can quickly split this […]
Read more