Browse Source

Base: Replace TTYServer with text mode Shell

Now that we have SystemServer that can (re)spawn the Shell, we don't need a
separate server just for that.

The two shells (on tty0 and tty1) are configured to only be started when booting
in text mode. This means you can now simply say boot_mode=text on the kernel
command line, and SystemServer will set up the system and spawn a comfy root
shell for you :^)
Sergey Bugaev 5 years ago
parent
commit
ae21b8ee56

+ 18 - 5
Base/etc/SystemServer.ini

@@ -1,8 +1,3 @@
-[TTYServer]
-# NOTE: We don't start anything on tty0 since that's the "active" TTY while WindowServer is up.
-Arguments=tty1
-StdIO=/dev/tty1
-
 [ProtocolServer]
 Socket=/tmp/portal/protocol
 SocketPermissions=660
@@ -10,6 +5,7 @@ Lazy=1
 Priority=low
 KeepAlive=1
 User=protocol
+BootModes=text,graphical
 
 [LookupServer]
 Socket=/tmp/portal/lookup
@@ -18,11 +14,13 @@ Lazy=1
 Priority=low
 KeepAlive=1
 User=lookup
+BootModes=text,graphical
 
 [DHCPClient]
 Priority=low
 KeepAlive=1
 User=root
+BootModes=text,graphical
 
 [NotificationServer]
 Socket=/tmp/portal/notify
@@ -37,6 +35,7 @@ Socket=/tmp/portal/launch
 SocketPermissions=600
 Lazy=1
 User=anon
+BootModes=text,graphical
 
 [WindowServer]
 Socket=/tmp/portal/window
@@ -109,3 +108,17 @@ User=anon
 [Terminal]
 User=anon
 WorkingDirectory=/home/anon
+
+[Shell@tty0]
+Executable=/bin/Shell
+StdIO=/dev/tty0
+Environment=TERM=xterm
+KeepAlive=1
+BootModes=text
+
+[Shell@tty1]
+Executable=/bin/Shell
+StdIO=/dev/tty1
+Environment=TERM=xterm
+KeepAlive=1
+BootModes=text

+ 7 - 6
Base/usr/share/man/man5/SystemServer.md

@@ -50,12 +50,13 @@ Priority=low
 KeepAlive=1
 User=anon
 
-# Spawn the TTYServer on /dev/tty1 once on startup with a high priority,
-# additionally passing it "tty1" as an argument.
-[TTYServer]
-Arguments=tty1
-StdIO=/dev/tty1
-Priority=high
+# Launch the Shell on /dev/tty0 on startup when booting in text mode.
+[Shell@tty0]
+Executable=/bin/Shell
+StdIO=/dev/tty0
+Environment=TERM=xterm
+KeepAlive=1
+BootModes=text
 ```
 
 ## See also

+ 0 - 1
Services/CMakeLists.txt

@@ -9,6 +9,5 @@ add_subdirectory(SystemMenu)
 add_subdirectory(SystemServer)
 add_subdirectory(Taskbar)
 add_subdirectory(TelnetServer)
-add_subdirectory(TTYServer)
 add_subdirectory(WebServer)
 add_subdirectory(WindowServer)

+ 0 - 6
Services/TTYServer/CMakeLists.txt

@@ -1,6 +0,0 @@
-set(SOURCES
-    main.cpp
-)
-
-serenity_bin(TTYServer)
-target_link_libraries(TTYServer LibC)

+ 0 - 68
Services/TTYServer/main.cpp

@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this
- *    list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <AK/Assertions.h>
-#include <AK/LogStream.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-int main(int argc, char** argv)
-{
-    if (pledge("stdio tty proc exec", nullptr) < 0) {
-        perror("pledge");
-        return 1;
-    }
-
-    if (unveil("/bin/Shell", "x") < 0) {
-        perror("unveil");
-        return 1;
-    }
-
-    unveil(nullptr, nullptr);
-
-    if (argc < 2)
-        return -1;
-
-    dbgprintf("Starting console server on %s\n", argv[1]);
-
-    while (true) {
-        dbgprintf("Running shell on %s\n", argv[1]);
-
-        auto child = fork();
-        if (!child) {
-            int rc = execl("/bin/Shell", "Shell", nullptr);
-            ASSERT(rc < 0);
-            perror("execl");
-            exit(127);
-        } else {
-            int wstatus;
-            waitpid(child, &wstatus, 0);
-            dbgprintf("Shell on %s exited with code %d\n", argv[1], WEXITSTATUS(wstatus));
-        }
-    }
-}