Compare commits
3 Commits
e5905a33e1
...
33c1a9c92b
Author | SHA1 | Date | |
---|---|---|---|
33c1a9c92b | |||
65834ff491 | |||
5c2718545f |
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,6 +5,7 @@ initrd/boot/moon
|
|||||||
env-local.sh
|
env-local.sh
|
||||||
initrd/bin/**
|
initrd/bin/**
|
||||||
base/usr/**
|
base/usr/**
|
||||||
|
base/etc/skel/LICENSE
|
||||||
.fakeroot
|
.fakeroot
|
||||||
kernel/config.cmake
|
kernel/config.cmake
|
||||||
ports/out/
|
ports/out/
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include <luna/String.h>
|
#include <luna/String.h>
|
||||||
#include <os/ArgumentParser.h>
|
#include <os/ArgumentParser.h>
|
||||||
#include <os/File.h>
|
#include <os/File.h>
|
||||||
|
#include <os/FileSystem.h>
|
||||||
|
#include <os/Prompt.h>
|
||||||
|
|
||||||
using os::File;
|
using os::File;
|
||||||
|
|
||||||
@ -14,10 +16,20 @@ Result<int> luna_main(int argc, char** argv)
|
|||||||
parser.add_positional_argument(pathname, "path"_sv, true);
|
parser.add_positional_argument(pathname, "path"_sv, true);
|
||||||
parser.parse(argc, argv);
|
parser.parse(argc, argv);
|
||||||
|
|
||||||
|
if (os::FileSystem::exists(pathname))
|
||||||
|
{
|
||||||
|
String prompt = TRY(String::format("File %s already exists. Overwrite?"_sv, pathname.chars()));
|
||||||
|
bool overwrite = os::conditional_prompt(prompt.chars(), os::DefaultNo);
|
||||||
|
if (!overwrite) return 0;
|
||||||
|
}
|
||||||
|
|
||||||
auto file = TRY(File::open_or_create(pathname, File::WriteOnly));
|
auto file = TRY(File::open_or_create(pathname, File::WriteOnly));
|
||||||
|
|
||||||
auto input = File::standard_input();
|
auto input = File::standard_input();
|
||||||
|
|
||||||
|
os::println("- Editing %s. Press Enter to start a new line, or Ctrl+D at the start of a line to save and exit. -",
|
||||||
|
pathname.chars());
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
String line = TRY(input->read_line());
|
String line = TRY(input->read_line());
|
||||||
|
@ -323,7 +323,7 @@ static void mount_shmfs()
|
|||||||
if (chmod("/dev/shm", 01777) < 0) exit(255);
|
if (chmod("/dev/shm", 01777) < 0) exit(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> sysinit()
|
Result<int> sysinit(StringView path)
|
||||||
{
|
{
|
||||||
if (getpid() != 1)
|
if (getpid() != 1)
|
||||||
{
|
{
|
||||||
@ -358,7 +358,8 @@ Result<int> sysinit()
|
|||||||
|
|
||||||
TRY(os::Security::pledge("stdio rpath wpath cpath proc exec id", nullptr));
|
TRY(os::Security::pledge("stdio rpath wpath cpath proc exec id", nullptr));
|
||||||
|
|
||||||
start_services("/etc/init");
|
if (path.is_empty()) path = "/etc/init";
|
||||||
|
start_services(path);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -394,7 +395,7 @@ Result<int> sysinit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> user_init()
|
Result<int> user_init(StringView path)
|
||||||
{
|
{
|
||||||
setpgid(0, 0);
|
setpgid(0, 0);
|
||||||
|
|
||||||
@ -405,7 +406,8 @@ Result<int> user_init()
|
|||||||
|
|
||||||
TRY(os::Security::pledge("stdio rpath wpath cpath proc exec", nullptr));
|
TRY(os::Security::pledge("stdio rpath wpath cpath proc exec", nullptr));
|
||||||
|
|
||||||
start_services("/etc/user");
|
if (path.is_empty()) path = "/etc/user";
|
||||||
|
start_services(path);
|
||||||
|
|
||||||
TRY(os::Security::pledge("stdio rpath wpath proc exec", nullptr));
|
TRY(os::Security::pledge("stdio rpath wpath proc exec", nullptr));
|
||||||
|
|
||||||
@ -446,13 +448,16 @@ Result<int> user_init()
|
|||||||
Result<int> luna_main(int argc, char** argv)
|
Result<int> luna_main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
bool user;
|
bool user;
|
||||||
|
StringView service_path;
|
||||||
|
|
||||||
os::ArgumentParser parser;
|
os::ArgumentParser parser;
|
||||||
parser.add_description("The init system for Luna.");
|
parser.add_description("The init system for Luna.");
|
||||||
parser.add_system_program_info("init"_sv);
|
parser.add_system_program_info("init"_sv);
|
||||||
parser.add_switch_argument(user, 'u', "user"_sv, "initialize a user session instead of the system");
|
parser.add_switch_argument(user, 'u', "user"_sv, "initialize a user session instead of the system");
|
||||||
|
parser.add_value_argument(service_path, 's', "service-path"_sv,
|
||||||
|
"change the default service path (/etc/init or /etc/user)");
|
||||||
parser.parse(argc, argv);
|
parser.parse(argc, argv);
|
||||||
|
|
||||||
if (user) return user_init();
|
if (user) return user_init(service_path);
|
||||||
return sysinit();
|
return sysinit(service_path);
|
||||||
}
|
}
|
||||||
|
14
base/etc/skel/welcome
Normal file
14
base/etc/skel/welcome
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Welcome to the Luna operating system!
|
||||||
|
You are running on the default user account, selene.
|
||||||
|
|
||||||
|
If you are familiar with Unix-style operating systems (like Linux or *BSD), you should be able to use the Luna terminal without much problems.
|
||||||
|
|
||||||
|
Following the traditional Unix filesystem structure, programs are installed in /usr/bin (/bin is a symlink to /usr/bin). The command `ls /bin` will show all commands available on your current Luna installation.
|
||||||
|
|
||||||
|
Currently, because of driver limitations, the root file system is mounted read-only. Your home folder is writable, but volatile; it is created and populated on boot, and its contents will vanish after a reboot.
|
||||||
|
|
||||||
|
The system is booted using the 'init' program. You can read its configuration files in the /etc/init directory to learn more about the boot process.
|
||||||
|
|
||||||
|
Luna is free software, released under the BSD-2-Clause license. The license is included in the LICENSE file in your home directory.
|
||||||
|
|
||||||
|
View the source code and read more about Luna at https://git.cloudapio.eu/apio/Luna.
|
@ -1,3 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# Create and populate a volatile home directory.
|
||||||
mount -t tmpfs tmpfs /home/selene
|
mount -t tmpfs tmpfs /home/selene
|
||||||
chown selene:selene /home/selene
|
chown selene:selene /home/selene
|
||||||
|
cp /etc/skel/welcome /home/selene/
|
||||||
|
cp /etc/skel/LICENSE /home/selene/
|
||||||
|
@ -31,3 +31,5 @@ mkdir -p base/tmp
|
|||||||
|
|
||||||
rm -f base/bin
|
rm -f base/bin
|
||||||
ln -s usr/bin base/bin
|
ln -s usr/bin base/bin
|
||||||
|
|
||||||
|
cp $LUNA_ROOT/LICENSE base/etc/skel/LICENSE
|
||||||
|
Loading…
Reference in New Issue
Block a user