Advertisement
yithar7153_2

/etc/runit/1

Jul 11th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.42 KB | None | 0 0
  1. #!/bin/sh
  2. # vim: set ts=4 sw=4 et:
  3.  
  4. PATH=/usr/bin:/usr/sbin
  5.  
  6. msg() {
  7.     # bold
  8.     printf "\033[1m=> $@\033[m\n"
  9. }
  10.  
  11. emergency_shell() {
  12.     echo
  13.     echo "Cannot continue due to errors above, starting emergency shell."
  14.     echo "When ready type exit to continue booting."
  15.     /bin/sh -l
  16. }
  17.  
  18. msg "Welcome to Void!"
  19.  
  20. msg "Mounting pseudo-filesystems..."
  21. mountpoint -q /proc || mount -o nosuid,noexec,nodev -t proc proc /proc
  22. mountpoint -q /sys || mount -o nosuid,noexec,nodev -t sysfs sys /sys
  23. mountpoint -q /run || mount -o mode=0755,nosuid,nodev,size=10% -t tmpfs run /run
  24. mountpoint -q /dev || mount -o mode=0755,nosuid -t devtmpfs dev
  25. mkdir -p -m0755 /run/runit /run/lvm /run/user /dev/pts /dev/shm
  26. mountpoint -q /dev/pts || mount -o mode=0620,gid=5,nosuid,noexec -n -t devpts devpts /dev/pts
  27. mountpoint -q /dev/shm || mount -o mode=1777,nosuid,nodev -n -t tmpfs shm /dev/shm
  28.  
  29. msg "Starting udev and waiting for devices to settle..."
  30. udevd --daemon
  31. udevadm trigger --action=add --type=subsystems
  32. udevadm trigger --action=add --type=devices
  33. udevadm settle
  34.  
  35. msg "Setting up keymap..."
  36. loadkeys -q -u /etc/mykeymap.map
  37.  
  38. msg "Remounting rootfs read-only..."
  39. mount -o remount,ro / || emergency_shell
  40.  
  41. msg "Checking filesystems:"
  42. fsck -A -T -a -t noopts=_netdev
  43.  
  44. msg "Mounting rootfs read-write..."
  45. mount -o remount,rw / || emergency_shell
  46.  
  47. msg "Mounting all non-network filesystems..."
  48. mount -a -t "nosysfs,nonfs,nonfs4,nosmbfs,nocifs" -O no_netdev || emergency_shell
  49.  
  50. msg "Initializing swap..."
  51. swapon -a || emergency_shell
  52.  
  53. msg "Initializing random seed..."
  54. cp /var/lib/random-seed /dev/urandom >/dev/null 2>&1 || true
  55. ( umask 077; bytes=$(cat /proc/sys/kernel/random/poolsize) || bytes=512; dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=$bytes >/dev/null 2>&1 )
  56.  
  57. msg "Setting up loopback interface..."
  58. ip link set up dev lo
  59.  
  60. msg "Setting up hostname..."
  61. cat /etc/hostname > /proc/sys/kernel/hostname
  62.  
  63. msg "Setting up timezone to America/New_York..."
  64. ln -sf "/usr/share/zoneinfo/America/New_York" /etc/localtime
  65.  
  66. install -m0664 -o root -g utmp /dev/null /run/utmp
  67. install -m0664 -o root -g utmp /dev/null /var/log/wtmp
  68. install -m0600 -o root -g utmp /dev/null /var/log/btmp
  69. install -dm1777 /tmp/.X11-unix /tmp/.ICE-unix
  70.  
  71. dmesg >/var/log/dmesg.log
  72. chmod 0644 /var/log/dmesg.log
  73.  
  74. mkdir -p /run/runit
  75. install -m100 /dev/null /run/runit/stopit
  76.  
  77. msg "Initialization complete, running stage 2..."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement