Documentation/crux-wiki/Handbook3-7-Configuration

249 lines
10 KiB
Plaintext

! Configuration
!! Initialization Scripts
!!! Runlevels
The following runlevels are used in CRUX (defined in %fn%/etc/inittab%%).
||cellpadding="3" rules="all" frame="box"
||! Runlevel ||! Description
||0 ||Halt
||1 (S) ||Single-user Mode
||2 ||Multi-user Mode
||3-5 ||(Not used)
||6 ||Reboot
!!! Layout
The initialization scripts used in CRUX follow the BSD-style (as opposed to the SysV-style) and have the following layout.
||cellpadding="3" rules="all" frame="box"
||! File ||! Description
||%fn%/etc/rc%% ||System boot script
||%fn%/etc/rc.single%% ||Single-user startup script
||%fn%/etc/rc.modules%% ||Module initialization script
||%fn%/etc/rc.multi%% ||Multi-user startup script
||%fn%/etc/rc.local%% ||Local multi-user startup script (empty by default)
||%fn%/etc/rc.shutdown%% ||System shutdown script
||%fn%/etc/rc.conf%% ||System configuration
||%fn%/etc/rc.d/%% ||Service start/stop script directory
Modify %fn%/etc/rc.modules%%, %fn%/etc/rc.local%% and %fn%/etc/rc.conf%% according to your needs.
!!! [[#ConfigurationVariables]] Configuration Variables in /etc/rc.conf
The following configuration variables are found in %fn%/etc/rc.conf%%.
(:table cellpadding="3" rules="all" frame="box":)
(:cell align=center:)'''Variable'''
(:cell align=center:)'''Description'''
(:cellnr valign=center:)FONT
(:cell:)
Specifies which console font to load at system startup. The contents of this variable will be passed as argument to '''setfont(1)'''. The available fonts are located in %fn%/usr/share/kbd/consolefonts/%%.
[-Example:-] @@FONT=default@@
(:cellnr valign=center:)KEYMAP
(:cell:)
Specifies which console keyboard map to load at system startup. The contents of this variable will be passed as argument to '''loadkeys(1)'''. The available keyboard maps are located in %fn%/usr/share/kbd/keymaps/%%.
[-Example:-] @@KEYMAP=sv-latin1@@
(:cellnr valign=center:)TIMEZONE
(:cell:)
Specifies the timezone used by the system. The available zone description files are located in %fn%/usr/share/zoneinfo/%%.
[-Example:-] @@TIMEZONE=Europe/Stockholm@@
(:cellnr valign=center:)HOSTNAME
(:cell:)
Specifies the hostname.
[-Example:-] @@HOSTNAME=pluto@@
(:cellnr valign=center:)SYSLOG
(:cell:)
Specifies the system logging daemon(s) to run at startup.
[-Example:-] @@SYSLOG=sysklogd@@
(:cellnr valign=center:)SERVICES
(:cell:)
Specifies which services to start at system startup. The services specified in this array must have a matching start/stop script in %fn%/etc/rc.d/%%. When entering multi-user mode the specified scripts will be called in the specified order with the argument '''start'''. At system shutdown or when entering single-user mode these scripts will be called in the reverse order with the argument '''stop'''.
[-Example:-] @@SERVICES=(crond lo net sshd)@@
(:tableend:)
!!! [[#LocaleGeneration]] Generating locales
Starting with CRUX 2.5, glibc does not contain all possible locales anymore, thus you'll have to generate the locales you
need/use. To ensure proper operation of %fn%pkgmk%%, the locale C.UTF-8 is generated as part of the CRUX installation. Any
other desired locales must be created by the administrator. A typical setup for swedish users would use the following
commands, so replace @@sv_SE*@@ with the locale you want:
# localedef -i sv_SE -f ISO-8859-1 sv_SE
# localedef -i sv_SE -f ISO-8859-1 sv_SE.ISO-8859-1
# localedef -i sv_SE -f UTF-8 sv_SE.UTF-8
!!! Network Configuration
The network configuration is found in the service script %fn%/etc/rc.d/net%%. To enable this service you need to add net to the SERVICES array in %fn%/etc/rc.conf%%. By default this service script configures a dynamic IP address. Example:
[@
#!/bin/sh
#
# /etc/rc.d/net: start/stop network interface
#
# Connection type: "DHCP" or "static"
TYPE="DHCP"
# For "static" connections, specify your settings here:
# To see your available devices run "ip link".
DEV=enp11s0
ADDR=192.168.1.100
MASK=24
GW=192.168.1.1
# Optional settings:
DHCPOPTS="-h `/bin/hostname` -t 10"
case $1 in
start)
if [ "${TYPE}" = "DHCP" ]; then
/sbin/dhcpcd ${DHCPOPTS}
else
/sbin/ip addr add ${ADDR}/${MASK} dev ${DEV} broadcast +
/sbin/ip link set ${DEV} up
/sbin/ip route add default via ${GW}
fi
;;
stop)
if [ "${TYPE}" = "DHCP" ]; then
/sbin/dhcpcd -x
else
/sbin/ip route del default
/sbin/ip link set ${DEV} down
/sbin/ip addr del ${ADDR}/${MASK} dev ${DEV}
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 [start|stop|restart]"
;;
esac
# End of file
@]
If you want to configure your system to use a static IP address, specify TYPE=static and the correct interface. You will also need to configure DNS settings in /etc/resolv.conf. Example:
[@
#!/bin/sh
#
# /etc/rc.d/net: start/stop network interface
#
# Connection type: "DHCP" or "static"
TYPE="static"
# For "static" connections, specify your settings here:
# To see your available devices run "ip link".
DEV=enp11s0
ADDR=192.168.1.100
MASK=24
GW=192.168.1.1
# Optional settings:
DHCPOPTS="-h `/bin/hostname` -t 10"
case $1 in
start)
if [ "${TYPE}" == "DHCP" ]; then
/sbin/dhcpcd ${DHCPOPTS}
else
/sbin/ip addr add ${ADDR}/${MASK} dev ${DEV} broadcast +
/sbin/ip link set ${DEV} up
/sbin/ip route add default via ${GW}
fi
;;
stop)
if [ "${TYPE}" == "DHCP" ]; then
/sbin/dhcpcd -x
else
/sbin/ip route del default
/sbin/ip link set ${DEV} down
/sbin/ip addr del ${ADDR}/${MASK} dev ${DEV}
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 [start|stop|restart]"
;;
esac
# End of file
@]
[@
#
# /etc/resolv.conf: resolver configuration file
#
search your internal domain>
nameserver your DNS server>
# End of file
@]
To associate with a password-protected wireless network, you should first create a configuration file for
%fn%wpa_supplicant%% to use, then launch wpa_supplicant on that interface.
$ wpa-passphrase MYNETWORK MYPASSWORD > /etc/wpa_supplicant-wlan0.conf
$ wpa_supplicant -i wlan0 -c /etc/wpa_supplicant-wlan0.conf
-> Replace '''wlan0''' with the name of your actual network interface. Run %fn%ip link%% to see the list of all available
interfaces.
If the %fn%wpa_supplicant%% output indicates a successful authentication, you can background the process and run
%fn%dhcpcd wlan0%% to request an address from the DHCP server.
The '''wpa_supplicant''' package provides two startup scripts in %fn%/etc/rc.d%%. You might choose to put '''wlan''' in the
SERVICES array of %fn%/etc/rc.conf%% (replacing '''net'''), which will let %fn%wpa_supplicant%% manage all your
network interfaces. Another option is to let the '''net''' startup script call %fn%wpa_supplicant%% as needed, by copying
into %fn%/lib/dhcpcd/dhcpcd-hooks/%% the example file %fn%/usr/share/dhcpcd/hooks/10-wpa_supplicant%%.
!! Passwords and User Environment
CRUX uses SHA512 passwords by default. To change the password encryption method set the ENCRYPT_METHOD variable in %fn%/etc/login.defs%% to DES, MD5 or SHA256.
Furthermore, when compiling programs that use the @@crypt(3)@@ function to authenticate users you should make sure that these programs are linked against the %fn%libcrypt%% library (i.e. use '''-lcrypt''' when linking) which contains the SHA512 version of the crypt function (this version is backwards compatible and understands DES passwords as well).
Also configurable in %fn%/etc/login.defs%% are the settings that govern how @@useradd(8)@@ behaves when you create a new
non-root user, such as CREATE_HOME and USERGROUPS_ENAB. First-time CRUX administrators might be surprised to learn that
creating a new user via %fn%useradd -m%% will not automatically populate the home directory with a basic shell
startup file, as happens on other Linux distributions whose %fn%/etc/skel/%% contains their idea of an initial home
directory. No such decisions are imposed on CRUX administrators, who get to work with the upstream tools in their
unmodified state.
The core packages '''linux-pam''' and '''dumb_runtime_dir''' provide a number of modules that can be loaded upon
successful login. The files in %fn%/etc/pam.d%% govern the association between the type of login (eg., tty, SSH, su, X
Display Manager) and the modules that get loaded (eg., pam_env, pam_exec, pam_limits). Read the manpage for any PAM module
of interest, to learn how it might be configured for your needs. Some typical situations that can be solved with PAM
modules are listed in the table below.
||cellpadding="3" rules="all" frame="box"
||! file in /etc/pam.d ||! Typical usage
||%fn%pam_env.so%% || export some mandatory environment variables, no matter what login shell the user has chosen
||%fn%pam_limits.so%% || increase the allowed number of opened files, to ensure proper operation of some games
||%fn%pam_xauth.so%% || grant another user access to the X display of the logged-in user, so that programs invoked with ''su'' can work properly
||%fn%pam_mount.so%% || automatically mount a LUKS-encrypted home partition
||%fn%pam_dumb_runtime_dir.so%% || create an XDG_RUNTIME_DIR for applications that conform to the freedesktop.org specification
!! Upgrading the Kernel
The kernel source, which is found in %fn%/usr/src/linux-5.15.x/%% is not installed using '''pkgadd'''. If you decide to
upgrade your kernel you can safely do so by manually replacing the kernel source with a newer version (or place it
somewhere else). This will not make the package database inconsistent (since it's not installed with '''pkgadd''') nor
will it affect the kernel headers found in %fn%/usr/include/linux%% and %fn%/usr/include/asm%% since these are not
symlinks to the kernel source, but instead contain copies of the headers.