summaryrefslogtreecommitdiff
path: root/core/startup/index.html
blob: 50f65acb4a842f36ba7d64f380fec1b152f9bada (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>mangoos</title>
    <style>
        * {
            font-family: "Inter", sans-serif;
            pointer-events: none;
            user-select: none;
            user-focus: none;
            cursor: none;
            outline: none;
        }

        html, body {
            background-color: cornflowerblue;
            color: black;
            margin: 0;
        }
    </style>
</head>
<body>
    <div style="display: flex; align-items: center; justify-content: center; position: fixed; inset: 0;">
        <div style="background: rgba(255, 255, 255, .75); backdrop-filter: blur(10px); padding: 50px; width: 512px; height: 256px; border-radius: 10px;">
            <div style="height: calc(100% - 48px + 50px); display: flex; align-items: center; justify-content: center;">
                <div>
                    <img src="../../logo.svg" style="width: 96px; display: block; margin-left: auto; margin-right: auto;">
                    <h2 style="text-align: center;">Welcome to mangoOS</h2>
                </div>
            </div>
            <div style="background: rgba(0, 0, 0, .1); height: 48px; margin: 0 -50px -50px;border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; border-top: 1px solid rgba(0, 0, 0, .1);">
                <div style="display: flex; align-items: center; height: 100%; padding: 0 10px;">
                    <img src="loader.svg" style="width: 42px; opacity: .5;">
                    <span id="loading-message">Hold down Shift to disable loading system extensions</span>
                </div>
            </div>
        </div>
    </div>

    <script>
        const steps = [
            {
                title: "Loading kernel extensions...",
                command: "systemctl start kmod.service"
            },
            {
                title: "Applying kernel variables...",
                command: "systemctl start systemd-sysctl.service"
            },
            {
                title: "Starting scheduled jobs manager...",
                command: "systemctl start cron.service"
            },
            {
                title: "Starting desktop manager...",
                command: "systemctl start dbus.service"
            },
            {
                title: "Starting OpenSSH server...",
                command: "systemctl start ssh.service"
            },
            {
                title: "Starting NTP client...",
                command: "systemctl start systemd-timesyncd.service"
            },
            {
                title: "Starting device manager...",
                command: "systemctl start systemd-udevd.service"
            },
            {
                title: "Initialising network core...",
                command: "systemctl start networking.service"
            },
            {
                title: "Initialising network frontend...",
                command: "systemctl start NetworkManager.service"
            },
            {
                title: "Initialising WLAN manager...",
                command: "systemctl start wpa_supplicant.service"
            },
            {
                title: "Starting UNIX policy manager...",
                command: "systemctl start polkit.service"
            },
            {
                title: "Configuring encryption...",
                command: "modprobe ecryptfs && /mango/core/startup/encryption.sh"
            }
        ];

        const cp = require('child_process');

        function sleep(ms) {
            return new Promise((res) => {
                setTimeout(res, ms);
            });
        }

        function exec(cmd) {
            return new Promise((res, rej) => {
                let p = cp.exec(cmd);

                p.on('close', (code, signal) => {
                    if (!code || code === 0) {
                        res(code, signal);
                    } else {
                        rej(code, signal);
                    }
                })
            });
        }

        setTimeout(async () => {
            for (let step of steps) {
                document.getElementById("loading-message").innerText = step.title;
                await sleep(100);

                try {
                    await exec(step.command);
                    await sleep(100);
                } catch (e) {
                    console.error(e);
                }
            }

            document.getElementById("loading-message").innerText = "Initialising login screen...";
            document.body.style.opacity = "0";
            document.body.style.pointerEvents = "none";
            location.href = "../login/index.html";
        }, 3000);
    </script>
</body>
</html>