Merge pull request 'add small tutorial how to compile and install babeld' (#32) from mark22k/docs:babeld_compile into master
Reviewed-on: https://codeberg.org/CRXN/docs/pulls/32
This commit is contained in:
commit
6474db556d
|
@ -0,0 +1,204 @@
|
|||
|
||||
# Compile and install babeld
|
||||
|
||||
It may happen that the babeld from the operating system package sources is outdated or no longer current. In this case it is recommended to compile and install babeld yourself.
|
||||
|
||||
## Preparation
|
||||
|
||||
For this you need a C compiler, git and the program make. These can be installed on Debian with the following command:
|
||||
```
|
||||
sudo apt install build-essential make git
|
||||
```
|
||||
|
||||
After that you can clone the babeld Git repo and initialize the submodules. GitHub requires an IPv4 clearnet connection.
|
||||
```
|
||||
https://github.com/jech/babeld.git
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
## Compilation
|
||||
|
||||
After that you can compile and install babeld with make. With `-j4` you can specify the number of concurrent tasks. Here it is recommended to take the number of CPU cores. In this example there are four.
|
||||
```
|
||||
make -j4
|
||||
sudo make install
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
After that you can install various configuration files. This tutorial assumes a Debian-based operating system with systemd. The instructions are based on the configuration files of the Debian package.
|
||||
|
||||
File `/etc/default/babeld`:
|
||||
```
|
||||
# List of interfaces on which the protocol should operate
|
||||
INTERFACES=""
|
||||
|
||||
# Additional arguments
|
||||
DAEMON_ARGS="-S /var/lib/babeld/state"
|
||||
```
|
||||
|
||||
File `/etc/init.d/babeld`:
|
||||
```
|
||||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: babeld
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Initscript for babeld
|
||||
# Description: Babel routing daemon
|
||||
### END INIT INFO
|
||||
|
||||
# Author: Stéphane Glondu <glondu@debian.org>
|
||||
|
||||
# Based on /etc/init.d/skeleton from initscripts_2.87dsf-10 and an
|
||||
# initscript provided by Juliusz Chroboczek.
|
||||
|
||||
# Do NOT "set -e"
|
||||
|
||||
# PATH should only include /usr/* if it runs after the mountnfs.sh script
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="Babel routing daemon"
|
||||
NAME=babeld
|
||||
DAEMON=/usr/local/bin/$NAME
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x "$DAEMON" ] || exit 0
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||
|
||||
# Exit if there is no interfaces
|
||||
if [ -z "$INTERFACES" ]; then
|
||||
if [ ! -f /etc/babeld.conf ] || [ $(grep -v '^#' /etc/babeld.conf| wc -l) -eq 0 ]; then
|
||||
echo "$DESC: no interfaces to operate on"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
do_start()
|
||||
{
|
||||
# Return
|
||||
# 0 if daemon has been started
|
||||
# 1 if daemon was already running
|
||||
# 2 if daemon could not be started
|
||||
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|
||||
|| return 1
|
||||
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
|
||||
-D -I $PIDFILE $DAEMON_ARGS $INTERFACES \
|
||||
|| return 2
|
||||
# Wait for the daemon to be ready
|
||||
sleep 1
|
||||
[ -e $PIDFILE ] || sleep 4
|
||||
[ -e $PIDFILE ] || return 2
|
||||
}
|
||||
|
||||
do_stop()
|
||||
{
|
||||
# Return
|
||||
# 0 if daemon has been stopped
|
||||
# 1 if daemon was already stopped
|
||||
# 2 if daemon could not be stopped
|
||||
# other if a failure occurred
|
||||
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
status)
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
restart|force-reload)
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
do_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
1) log_end_msg 1 ;; # Old process is still running
|
||||
*) log_end_msg 1 ;; # Failed to start
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Failed to stop
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
||||
```
|
||||
|
||||
File `/etc/logrotate.d/babeld`:
|
||||
```
|
||||
/var/log/babeld.log {
|
||||
weekly
|
||||
rotate 8
|
||||
compress
|
||||
missingok
|
||||
notifempty
|
||||
postrotate
|
||||
[ -r /var/run/babeld.pid ] && kill -USR2 $(cat /var/run/babeld.pid)
|
||||
endscript
|
||||
}
|
||||
```
|
||||
|
||||
File `/etc/systemd/system/babeld.service`:
|
||||
```
|
||||
[Unit]
|
||||
Documentation=man:systemd-sysv-generator(8)
|
||||
SourcePath=/etc/init.d/babeld
|
||||
Description=LSB: Initscript for babeld
|
||||
Before=multi-user.target
|
||||
Before=graphical.target
|
||||
After=remote-fs.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
Restart=on-failure
|
||||
TimeoutSec=5min
|
||||
IgnoreSIGPIPE=no
|
||||
KillMode=process
|
||||
GuessMainPID=no
|
||||
SuccessExitStatus= 5 6
|
||||
ExecStart=/etc/init.d/babeld start
|
||||
ExecStop=/etc/init.d/babeld stop
|
||||
```
|
||||
|
||||
After that you can make the init script executable, load the new Systemd unit and create an empty babeld configuration file:
|
||||
```
|
||||
chmod +x /etc/init.d/babeld
|
||||
systemctl daemon-reload
|
||||
touch /etc/babeld.conf
|
||||
```
|
|
@ -10,5 +10,6 @@
|
|||
|
||||
## babeld
|
||||
- [Setting up Babeld](babeld/babeld)
|
||||
- [Compile and install babeld](babeld/compile-install)
|
||||
- [max-len filter in babeld](babeld/maxlen-filter)
|
||||
- [babelweb2](babeld/babelweb2)
|
||||
|
|
Loading…
Reference in New Issue