Mercurial > vanilla
comparison core/rc/rc.init @ 566:ddb052f876cd
core/rc: move etc services to rc, closes #1666
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 05 Jul 2019 20:58:54 +0200 |
parents | core/etc/rc.init@15992f10ced3 |
children | 290ca0287e5d |
comparison
equal
deleted
inserted
replaced
565:15992f10ced3 | 566:ddb052f876cd |
---|---|
1 #!/bin/sh | |
2 # | |
3 # /etc/rc.init: system initialization script | |
4 # | |
5 # Copyright (c) 2019 David Demelier <markand@malikania.fr> | |
6 # | |
7 # Permission to use, copy, modify, and/or distribute this software for any | |
8 # purpose with or without fee is hereby granted, provided that the above | |
9 # copyright notice and this permission notice appear in all copies. | |
10 # | |
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
18 # | |
19 | |
20 if [ -f /etc/rc.conf ]; then | |
21 . /etc/rc.conf | |
22 fi | |
23 | |
24 if [ "${BANNER:-yes}" = "yes" ]; then | |
25 printf "\nWelcome to \033[33;1mVanilla Linux\033[0m\n\n" | |
26 fi | |
27 | |
28 if [ -n "$HOSTNAME" ] && [ -x /bin/hostname ]; then | |
29 echo "Setting hostname: $HOSTNAME" | |
30 /bin/hostname "$HOSTNAME" | |
31 fi | |
32 | |
33 if [ -x /bin/sysctl ]; then | |
34 echo "Setting kernel parameters." | |
35 /bin/sysctl -p >/dev/null 2>&1 | |
36 fi | |
37 | |
38 if [ -x /bin/mountpoint ]; then | |
39 echo -n "Mounting filesystems: " | |
40 | |
41 if ! /bin/mountpoint /dev >/dev/null 2>&1; then | |
42 /bin/mount -t devtmpfs devtmpfs /dev >/dev/null 2>&1 | |
43 echo -n "/dev " | |
44 fi | |
45 | |
46 if ! /bin/mountpoint /proc >/dev/null 2>&1; then | |
47 /bin/mount -t proc proc /proc >/dev/null 2>&1 | |
48 echo -n "/proc " | |
49 fi | |
50 | |
51 if ! /bin/mountpoint /sys >/dev/null 2>&1; then | |
52 /bin/mount -t sysfs sysfs /sys >/dev/null 2>&1 | |
53 echo -n "/sys " | |
54 fi | |
55 | |
56 if ! /bin/mountpoint /run >/dev/null 2>&1; then | |
57 /bin/mount -t tmpfs tmpfs /run >/dev/null 2>&1 | |
58 echo -n "/run " | |
59 fi | |
60 | |
61 echo "done." | |
62 fi | |
63 | |
64 # Clean pid files before starting any services. | |
65 find /var/run -type f -name "*.pid" -delete | |
66 | |
67 # | |
68 # Start a device service. Both eudev and busybox's mdev are supported but only | |
69 # one at a time must be enabled. | |
70 # | |
71 if [ -x /etc/rc.d/udevd ] && [ -x /etc/rc.d/busybox.mdev ]; then | |
72 echo "Warning: both /etc/rc.d/udevd and /etc/rc.d/busybox.mdev are enabled" 1>&2 | |
73 echo "Warning: using udevd instead" 1>&2 | |
74 fi | |
75 | |
76 if [ -x /etc/rc.d/udevd ]; then | |
77 /etc/rc.d/udevd start | |
78 elif [ -x /etc/rc.d/busybox.mdev ]; then | |
79 /etc/rc.d/busybox.mdev start | |
80 fi | |
81 | |
82 if [ -x /bin/fsck ]; then | |
83 # Make sure / is ro in case of initrd. | |
84 /bin/mount -o remount,ro / | |
85 | |
86 # If /etc/forcefsck is there, force check. | |
87 if [ -f /etc/forcefsck ]; then | |
88 force="-f" | |
89 fi | |
90 | |
91 /bin/fsck $force -A -T -C -a >/dev/null 2>&1 | |
92 | |
93 if [ "$?" -gt 1 ]; then | |
94 echo "* Filesystem check failed" | |
95 /bin/sulogin -p | |
96 fi | |
97 fi | |
98 | |
99 # Remount / and enable swap as the system is ready. | |
100 /bin/mount -o remount,rw / | |
101 /bin/swapon -a | |
102 | |
103 # Update shared library caches. | |
104 if [ -x /bin/ldconfig ]; then | |
105 /bin/ldconfig | |
106 fi | |
107 | |
108 if [ -n "$TIMEZONE" ]; then | |
109 echo -n "Setting timezone: " | |
110 | |
111 if [ -f /share/zoneinfo/$TIMEZONE ]; then | |
112 /bin/ln -sf /share/zoneinfo/$TIMEZONE /etc/localtime | |
113 echo "$TIMEZONE." | |
114 else | |
115 echo "$TIMEZONE not found." | |
116 fi | |
117 fi | |
118 | |
119 # Console font and keymap. | |
120 if [ -n "$FONT" ] && [ -x /bin/setfont ]; then | |
121 echo "Setting font: $FONT" | |
122 /bin/setfont $FONT | |
123 fi | |
124 | |
125 if [ -n "$KEYMAP" ] && [ -x /bin/loadkeys ]; then | |
126 echo "Setting keymap: $KEYMAP" | |
127 /bin/loadkeys $KEYMAP | |
128 fi | |
129 | |
130 # Cleanup some files. | |
131 rm -f /etc/forcefsck |