#===============================================
#Configuration for BusyBox '/sbin/init'
#(BusyBox doesn't support runlevels like original SysVinit)
#===============================================

#Perform initializations at startup:
#----------------------------
# Mount virtual kernel filesystem 'proc' (important)
::sysinit:/bin/mount -t proc proc /proc
# Mount to '/dev' (kernel probably does it automatically for 'devtmpfs')
#::sysinit:/bin/mount -t devtmpfs devtmpfs /dev
# If no 'devtmpfs' in kernel, and no udev/mtdev, populate /dev manually:
#::sysinit:/bin/mount -t tmpfs tmpfs /dev
#::sysinit:/bin/mknod -m 0666 /dev/null 1 3
#::sysinit:/bin/mknod -m 0622 /dev/console c 5 1
#::sysinit:/bin/mknod -m 0666 /dev/ptmx 5 2
#::sysinit:/bin/mknod -m 0666 /dev/tty c 5 0
#::sysinit:/bin/mknod -m 0666 /dev/tty0 c 4 0
#::sysinit:/bin/mknod -m 0666 /dev/tty1 c 4 1
#::sysinit:/bin/mknod -m 0666 /dev/tty2 c 4 2
#::sysinit:/bin/mkond -m 0666 /dev/tty3 c 4 3
#::sysinit:/bin/mknod -m 0666 /dev/tty4 c 4 4
#::sysinit:/bin/chown root:tty {console,ptmx,tty}
#::sysinit:/bin/mknod -m 0666 /dev/fb0 c 29 0
#::sysinit:/bin/mknod -m 0666 /dev/psaux c 10 1
#::sysinit:/bin/mknod -m 0666 /dev/dsp c 14 3
#more devices here if required (major and minor numbers at the end,get'em with:
#'ls -la /dev/<devname>' on working system, or linux Documentation/devices.txt

#if devtmpfs is present, create some basic symlinks as a starting point
::sysinit:/bin/ln -s /dev/psaux /dev/mouse
::sysinit:/bin/ln -s /dev/sr0 /dev/cdrom
::sysinit:/bin/ln -s /dev/sr0 /dev/dvd
::sysinit:/bin/ln -s /dev/sr0 /dev/cdwriter
::sysinit:/bin/ln -s /dev/ttyUSB0 /dev/modem
::sysinit:/bin/ln -s /proc/kcore /dev/core
::sysinit:/bin/ln -s /dev/ram0 /dev/ramdisk
::sysinit:/bin/ln -s /dev/rtc0 /dev/rtc
::sysinit:/bin/ln -s /dev/sg0 /dev/scanner
::sysinit:/bin/ln -s /proc/self/fd /dev/fd
::sysinit:/bin/ln -s /dev/fd/1 /dev/stdout
::sysinit:/bin/ln -s /dev/fd/0 /dev/stdin
::sysinit:/bin/ln -s /dev/fd/2 /dev/stderr

# And/Or Enable mdev as hotplug-daemon if needed (usercfg: /etc/mdev.conf)
# (otherwise kernel mounts /dev automatically and handles hw)
::sysinit:/bin/mount -t sysfs sysfs /sys
#::sysinit:echo /sbin/mdev > /proc/sys/kernel/hotplug
#::sysinit:/sbin/mdev -s
#::sysinit:/bin/mount -t tmpfs mdev /dev
# Mount /dev/pts virtual filesystem for pseudo-terminals (e.g. xterm)
::sysinit:/bin/mkdir /dev/pts
::sysinit:/bin/mount -t devpts devpts /dev/pts
#::sysinit:/bin/chmod 0755 /dev
::sysinit:/bin/chmod 620 /dev/pts
# Create and mount temporary shared-memory filesystem to speed up
::sysinit:/bin/mkdir /dev/shm
::sysinit:/bin/mount -t tmpfs tmpfs /dev/shm
::sysinit:/bin/chmod a+rwx /dev/shm

# Mount 'tmp' as temporary filesystem (becomes volatile, but no disk-use)
::sysinit:/bin/mount -t tmpfs tmpfs /tmp
# (A /run or /var/run directory can be tmpfs too for udev/systemd/etc.)
::sysinit:/bin/mount -t tmpfs tmpfs /var/run
#('/var/lock' and '/var/log' libraries symlinks to /var/run subfolders)
::sysinit:/bin/mkdir /var/run/lock
::sysinit:/bin/mkdir /var/run/log
::sysinit:/bin/chmod a+rwx /var/run/lock
::sysinit:/bin/chmod a+rwx /var/run/log

# Herminux's simple way of mounting - mnt is temporary filesystem,
# and '/usr/bin/mnt' script makes mountpoints and mounts device (& umnt)
::sysinit:/bin/mount -t tmpfs tmpfs /mnt

# Remount rootfs rw. (not necessary, maybe after initramfs/initrd)
# ::sysinit:/bin/mount -o remount,rw /
# Mount other else here if needed...

# Load keymap for virtual-terminal
::sysinit:loadkmap < /usr/share/kmap/dvorak.kmap

# Optional custom init-script, or else...
# ::sysinit:/etc/init.d/rcS)

# PATH env.variable can be set in /etc/profile (or user: ~/.profile)

# X-Window graphic UI is started from /etc/profile with 'startx'



#'Respawn' operations (restarts whenever it terminates):
#-------------------------------------------------------
# Auto-login as root on tty1 terminal:
::once:echo "Welcome to Herminux!"
tty1::respawn:-/bin/login -f root 

# Login normally on other tty terminals with getty:
#tty1::respawn:/sbin/getty 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2
tty3::respawn:/sbin/getty 38400 tty3
tty4::respawn:/sbin/getty 38400 tty4



#Logout/Reboot/Shutdown-related tasks:
#----------------------------------
::ctrlaltdel:/sbin/reboot
::restart:/sbin/init

# Optional custom shutdown-script or else:
::shutdown:/usr/bin/clear
# ::shutdown:/etc/init.d/rc.shutdown

# Sync all filesystems: (actually write out remaining data)
::shutdown:echo "Syncing all filesystems..."
::shutdown:/bin/sync

# Kill all processes except important like session,kernel,etc.:
::shutdown:echo "Terminating all processes. (SIGTERM:15)"
::shutdown:/usr/sbin/killall5 
# ::shutdown:sleep 1
::shutdown:echo "Killing all processes. (SIGKILL:9)"
::shutdown:/usr/sbin/killall5 -9


# Release swap:  ('if ! grep -q "noswap" /proc/cmdline; then')
::shutdown:/usr/bin/clear
::shutdown:echo "${NORMAL}Disabling swap space."
::shutdown:/sbin/swapoff -a

# Umount filesystems:
::shutdown:echo "Unmounting all filesystems. "
::shutdown:/bin/umount -arf 2>&1

#The rest is kernel's task...
::shutdown:echo "Shutdown in progress."
::shutdown:echo ""

