-
Notifications
You must be signed in to change notification settings - Fork 1
/
initrc.c
37 lines (34 loc) · 1.11 KB
/
initrc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include <linux/reboot.h>
int main() {
int selfpid=getpid();
if (selfpid != 1) {
printf("Not running as PID 1, dying...\n");
return 1;
} else {
printf("InitRC v0.3.1 -- Booting up!\n");
printf("Mounting filesystems... ");
system("/usr/bin/mount -t procfs proc /proc");
system("/usr/bin/mount -t devtmpfs dev /dev");
system("/usr/bin/mount -t sysfs sys /sys");
system("/usr/bin/mount -t tmpfs tmp /tmp");
printf("done!\n");
printf("Running mainrc... ");
system("/usr/bin/sh -c /etc/initrc/rc");
printf("Running networkrc... ");
system("/usr/bin/sh -c /etc/initrc/networkrc");
printf("Running user scripts... ");
system("/usr/bin/sh -c /etc/initrc/user");
printf("done!\n");
printf("TTY1 killed, shutting down...\n");
system("/usr/bin/sh -c /etc/initrc/shutdown");
sync();
reboot(LINUX_REBOOT_MAGIC1,
LINUX_REBOOT_MAGIC2,
LINUX_REBOOT_CMD_POWER_OFF, 0);
}
}