Updated every file, added a few more.

- zsh is used instead of bash.
	- passwd, shadow and group are added, as users are required as
	  some point.
	- mdev.conf added to populate /dev.
	- sysctl.conf added… it’s empty, but at least there’s a
	  skeleton.
This commit is contained in:
Luka Vandervelden 2019-08-19 19:55:50 +02:00
parent 64869c410f
commit 50357fe1f9
12 changed files with 210 additions and 51 deletions

27
group Normal file
View File

@ -0,0 +1,27 @@
root::0:root
bin::1:root,bin,daemon
daemon::2:root,bin,daemon
sys::3:root,bin
adm::4:root,daemon
tty::5:
disk::6:root
lp::7:daemon
mem::8:
kmem::9:
wheel::10:root
ftp::11:
mail::12:
mlocate::13:
dialout::14:
www::15:
audio::16:
video::17:
floppy::18:
tape::19:
scanner::20:
cdrom::21:
input::22:
kvm::23:
nobody::99:
messagebus::81:
users::100:

118
mdev.conf Normal file
View File

@ -0,0 +1,118 @@
# mdev-like-a-boss
# Syntax:
# [-]devicename_regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
# [-]$ENVVAR=regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
# [-]@maj,min[-min2] user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
#
# [-]: do not stop on this match, continue reading mdev.conf
# =: move, >: move and create a symlink
# !: do not create device node
# @|$|*: run cmd if $ACTION=remove, @cmd if $ACTION=add, *cmd in all cases
# support module loading on hotplug
$MODALIAS=.* root:root 660 @modprobe -b "$MODALIAS"
# null may already exist; therefore ownership has to be changed with command
null root:root 666 @chmod 666 $MDEV
zero root:root 666
full root:root 666
random root:root 444
urandom root:root 444
hwrandom root:root 444
grsec root:root 660
# Kernel-based Virtual Machine.
kvm root:kvm 660
# vhost-net, to be used with kvm.
vhost-net root:kvm 660
kmem root:root 640
mem root:root 640
port root:root 640
# console may already exist; therefore ownership has to be changed with command
console root:tty 600 @chmod 600 $MDEV
ptmx root:tty 666
pty.* root:tty 660
# Typical devices
tty root:tty 666
tty[0-9]* root:tty 660
vcsa*[0-9]* root:tty 660
ttyS[0-9]* root:tty 660
# block devices
ram([0-9]*) root:disk 660 >rd/%1
loop([0-9]+) root:disk 660 >loop/%1
sd[a-z].* root:disk 660 */opt/mdev/helpers/storage-device
vd[a-z].* root:disk 660 */opt/mdev/helpers/storage-device
hd[a-z].* root:disk 660 */opt/mdev/helpers/storage-device
md[0-9]* root:disk 660 */opt/mdev/helpers/storage-device
dm-[0-9]* root:disk 660 */opt/mdev/helpers/storage-device
bcache[0-9]* root:disk 660 */opt/mdev/helpers/storage-device
mmcblk[0-9].* root:disk 660 */opt/mdev/helpers/storage-device
sr[0-9]* root:cdrom 660 @ln -sf $MDEV cdrom
fd[0-9]* root:floppy 660
# Run settle-nics every time new NIC appear.
# If you don't want to auto-populate /etc/mactab with NICs, run 'settle-nis' without '--write-mactab' param.
-SUBSYSTEM=net;DEVPATH=.*/net/.*;.* root:root 600 @/opt/mdev/helpers/settle-nics --write-mactab
net/tun[0-9]* root:kvm 660
net/tap[0-9]* root:root 600
# alsa sound devices and audio stuff
SUBSYSTEM=sound;.* root:audio 660 @/opt/mdev/helpers/sound-control
adsp root:audio 660 >sound/
audio root:audio 660 >sound/
dsp root:audio 660 >sound/
mixer root:audio 660 >sound/
sequencer.* root:audio 660 >sound/
# raid controllers
cciss!(.*) root:disk 660 =cciss/%1
ida!(.*) root:disk 660 =ida/%1
rd!(.*) root:disk 660 =rd/%1
fuse root:root 666
card[0-9] root:video 660 =dri/
agpgart root:root 660 >misc/
psaux root:root 660 >misc/
rtc root:root 664 >misc/
# input stuff
SUBSYSTEM=input;.* root:input 660
# v4l stuff
vbi[0-9] root:video 660 >v4l/
video[0-9] root:video 660 >v4l/
# dvb stuff
dvb.* root:video 660
# drm etc
dri/.* root:video 660
# Don't create old usbdev* devices.
usbdev[0-9].[0-9]* root:root 660 !
# Stop creating x:x:x:x which looks like /dev/dm-*
[0-9]+\:[0-9]+\:[0-9]+\:[0-9]+ root:root 660 !
# /dev/cpu support.
microcode root:root 600 =cpu/
cpu([0-9]+) root:root 600 =cpu/%1/cpuid
msr([0-9]+) root:root 600 =cpu/%1/msr
# Populate /dev/bus/usb.
SUBSYSTEM=usb;DEVTYPE=usb_device;.* root:root 660 */opt/mdev/helpers/dev-bus-usb
# Catch-all other devices, Right now useful only for debuging.
#.* root:root 660 */opt/mdev/helpers/catch-all

8
passwd Normal file
View File

@ -0,0 +1,8 @@
root:x:0:0:root:/root:/usr/bin/zsh
bin:x:1:1:bin:/bin:
daemon:x:2:2:daemon:/sbin:
mail:x:8:12:mail:/var/spool/mail:
ftp:x:14:11:ftp:/var/ftp:
www:x:15:15:www:/var/www:/bin/false
messagebus:x:81:81::/var/empty:/bin/false
nobody:x:99:99:nobody:/:

50
rc
View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/zsh
#
# /etc/rc: system boot script
#
@ -8,21 +8,16 @@ echo "The system is coming up. Please wait."
# Load configuration
. /etc/rc.conf
/bin/mount -t proc none /proc
/bin/mount -t sysfs none /sys
/bin/mount -t devtmpfs none /dev
# Start udev
/sbin/mdev -s
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
# Those two seem to be already mounted at this point on Alpine.
# FIXME: I have no idea why. Who does that? kernel config? kernel parameters?
#/bin/mount -t proc none /proc
#/bin/mount -t sysfs none /sys
# FIXME: Should probably be replaced by mdev or something... right?
#/sbin/start_udev
# FIXME: this loads kernel drivers. Not sure it should be here, but... may it should?
# FIXME: this also makes the system rely on /usr/bin to be bootable. blergh
/usr/bin/find /sys -name modalias -type f -print0 | xargs -0 sort -u \
| /usr/bin/xargs modprobe -b -a 2> /dev/null
if [ -e /proc/sys/kernel/hotplug ]; then
echo "hotplug: mdev"
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
fi
# Create device-mapper device nodes and scan for LVM volume groups
if [ -x /sbin/lvm ]; then
@ -51,7 +46,7 @@ if [ $? -gt 1 ]; then
echo "* *"
echo "************************************************************"
echo
/sbin/sulogin -p
/sbin/sulogin
echo "Automatic reboot in progress..."
/bin/umount -a -r
/bin/mount -o remount,ro /
@ -77,9 +72,6 @@ fi
# Set kernel variables
/sbin/sysctl -p > /dev/null
# Update shared library links
/sbin/ldconfig
# Configure host name
if [ "$HOSTNAME" ]; then
echo "hostname: $HOSTNAME"
@ -96,17 +88,23 @@ fi
/sbin/hwclock --hctosys
# Load console font
# FIXME: Disabled because no font?
#if [ "$FONT" ]; then
# echo "font: $FONT"
# /usr/sbin/setfont $FONT
#fi
if [ "$FONT" ]; then
echo "font: $FONT"
/usr/sbin/setfont $FONT
fi
# Load console keymap
if [ "$KEYMAP" ]; then
echo "keyboard: $KEYMAP (DISABLED BECAUSE LOADKEYS UNAVAILABLE)"
#/usr/bin/loadkeys -q $KEYMAP
# zcat "$KEYMAP" | loadkmap
echo "keyboard: $KEYMAP"
local KEYMAP_FILE
if [ -f "$KEYMAP" ]; then
KEYMAP_FILE="$KEYMAP"
else
KEYMAP_FILE=/usr/share/kbd/keymaps/$KEYMAP.map.gz
fi
zcat $KEYMAP_FILE | loadkmap
fi
# Screen blanks after 15 minutes idle time

View File

@ -2,11 +2,11 @@
# /etc/rc.conf: system configuration
#
FONT=default
KEYMAP=us
TIMEZONE=UTC
#FONT=default
#KEYMAP=us
#TIMEZONE=UTC
HOSTNAME=host
SYSLOG=sysklogd
SERVICES=(lo crond)
SERVICES=()
# End of file

2
rc.fix
View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/zsh
#
# /etc/rc.fix: adjustements startup file (multi-user)
#

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# /etc/rc.local: local multi-user startup script
# /etc/rc.local: local startup script
#
# End of file

View File

@ -1,8 +1,12 @@
#!/bin/bash
#!/bin/zsh
#
# /etc/rc.modules: module initialization script
#
/sbin/depmod -a
# FIXME: Is this even necessary? Is this even *desirable*?
/bin/busybox find /sys -name modalias -type f -print0 | xargs -0 sort -u \
| /bin/bin/busybox xargs modprobe -b -a 2> /dev/null
# End of file

View File

@ -1,8 +1,9 @@
#!/bin/bash
#!/bin/zsh
#
# /etc/rc.multi: multi-user startup script
# /etc/rc.multi: startup script
#
# Load configuration
. /etc/rc.conf

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/zsh
#
# /etc/rc.shutdown: system shutdown script
#
@ -11,24 +11,22 @@
echo "The system is coming down. Please wait."
if [ "$PREVLEVEL" = "2" ]; then
# Shutdown services
if [ "${SERVICES[*]}" ]; then
for service in "${SERVICES[@]}"; do
R_SERVICES=($service ${R_SERVICES[@]})
done
for service in "${R_SERVICES[@]}"; do
/etc/rc.d/$service stop &> /tmp/rc.$$
/usr/bin/logger -t $service < /tmp/rc.$$
/bin/rm -f /tmp/rc.$$
done
fi
# Shutdown services
if [ "${SERVICES[*]}" ]; then
for service in "${SERVICES[@]}"; do
R_SERVICES=($service ${R_SERVICES[@]})
done
for service in "${R_SERVICES[@]}"; do
/etc/rc.d/$service stop &> /tmp/rc.$$
/usr/bin/logger -t $service < /tmp/rc.$$
/bin/rm -f /tmp/rc.$$
done
fi
# Terminate all processes
/sbin/killall5 -15
/usr/sbin/killall5 -15
/bin/sleep 5
/sbin/killall5 -9
/usr/sbin/killall5 -9
# Save random seed
/bin/dd if=/dev/urandom of=/var/lib/urandom/seed count=1 2> /dev/null

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/zsh
#
# /etc/rc.single: single-user startup script
#

5
sysctl.conf Normal file
View File

@ -0,0 +1,5 @@
#
# /etc/sysctl.conf: configuration for system variables, see sysctl.conf(5)
#
# End of file