Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,6 @@ $ git push
5. Check the repository in UI
Open the mono-ui in your browser with `http://localhost:3000`, and you will see the `project` folder.

## Quick Review of Architecture

![Mega Architect](docs/images/Mega_Bin_and_Modules.png)

1. **mono** - Mega's api endpoint, responsible for handling `git`, `git-lfs` and web UI requests through the HTTP and SSH protocol.
2. **mega** - The main entry of Mega, parse cli command with clap.
3. **gateway** - The Gateway extend **mono** and contains ztm agent, which is responsible for ztm network capabilities. More information on the [Gateway](gateway/README.md).
4. **libra** - The Libra is a `git` program that rewrite in Rust. More information on the [Libra](libra/README.md).
5. **gemini** - The Gemini is a decentralized module of Mega. More information on the [Gemini](gemini/README.md).
6. **scorpio** - The Scorpio is a FUSE filesystem that allow you to mount a Mega repository as a local filesystem. More information on the [Scorpio](scorpio/README.md).
7. **mercury** - The Mercury module is the core module of Mega, which rewrites Git internal object like Blob, Tree, etc. More information on the [Mercury Module](mercury/README.md).
8. **ceres** - The Ceres is Mega's Monorepo Engine and implement the git transport protocol. More information on the [Ceres](ceres/README.md).
9. **jupiter** - The Jupiter is storage engine for Mega. More information on the [Jupiter](jupiter/README.md).
10. **saturn** - The Saturn module implement user permissions with Cedar policy [Saturn](saturn/README.md).
11. **vault** - The Vault module is used for key and certificate management, implemented with RustyVault
12. **lunar** - The Lunar is a tauri app with Mega. More information on the [Lunar](lunar/README.md).
13. **aries** - The Mega's ztm Relay Server. More information on the [Aries](aries/README.md).
14. **altas** - AI API Module. More information on the [Altas](altas/README.md).
15. **moon** - The Moon is a web UI for Mono Engine. More information on the [Moon](moon/README.md).
16. **mars** - The Mars is website for Mega. More information on the [Mars](mars/README.md).



## Contributing

The mega project relies on community contributions and aims to simplify getting started. To develop Mega, clone the repository, then install all dependencies and initialize the database schema, run the test suite and try it out locally. Pick an issue, make changes, and submit a pull request for community review.
Expand Down
17 changes: 17 additions & 0 deletions blackhole/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Build directory
archiso
38 changes: 38 additions & 0 deletions blackhole/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# blackhole - Creating a clean build environment for base on Arch Linux

## How to run blackhole

1. Install build tools

```bash
sudo pacman -S archiso
```

"Archiso is a highly-customizable tool for building Arch Linux live CD/USB ISO images. The official images are built with Archiso. It can be used as the basis for rescue systems, linux installers or other systems. This wiki article explains how to install Archiso, and how to configure it to control aspects of the resulting ISO image such as included packages and files. Technical requirements and build steps can be found in the official project documentation. Archiso is implemented with a number of bash scripts. The core component of Archiso is the mkarchiso command. Its options are documented in mkarchiso -h and not covered here." - [1]

2. Create a configuration file directory for the build process

```bash
cd blackhole
mkdir -p ./archiso
cd ./archiso
cp -r /usr/share/archiso/configs/releng/* .
cp -r ../airootfs ./
cp ../packages.x86_64 .
sudo mkarchiso -v -w work/ -o out/ .
```

* Use kvm to run the built image to install the host system.

* The configuration that needs to be confirmed is that three virtual disks must be configured. The first disk has a capacity of 20GB and is used for host system installation. The second disk is 30GB and is used as the target disk. The third disk is selected according to the actual situation. Block disk capacity plus memory capacity greater than 35GB
* The installer will run automatically within about 5 minutes after the host image starts. After the installer starts, you need to manually select the install option, and you don’t need to set any options.
* If it does not run automatically or runs incorrectly, execute the command manually: ```archinstall --config user_configuration.json --creds user_credentials.json --disk_layouts user_disk_layout.json```
* After the installation is complete, you will be prompted whether to enter the chroot environment. Here,  you can choose no and then reboot.
* After the host environment is installed, you need to manually mount the swap partition.
* Host username root password root

## References

1. [https://wiki.archlinux.org/title/archiso](https://wiki.archlinux.org/title/archiso)
2. [https://github.com/archlinux/archinstall](https://github.com/archlinux/archinstall)
3. [https://github.com/archlinux/archinstall/wiki/Building-and-Testing](https://github.com/archlinux/archinstall/wiki/Building-and-Testing)
1 change: 1 addition & 0 deletions blackhole/airootfs/etc/hostname
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
archiso
1 change: 1 addition & 0 deletions blackhole/airootfs/etc/locale.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LANG=C.UTF-8
1 change: 1 addition & 0 deletions blackhole/airootfs/etc/localtime
67 changes: 67 additions & 0 deletions blackhole/airootfs/etc/mkinitcpio.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# vim:set ft=sh
# MODULES
# The following modules are loaded before any boot hooks are
# run. Advanced users may wish to specify all system modules
# in this array. For instance:
# MODULES=(piix ide_disk reiserfs)
MODULES=()

# BINARIES
# This setting includes any additional binaries a given user may
# wish into the CPIO image. This is run last, so it may be used to
# override the actual binaries included by a given hook
# BINARIES are dependency parsed, so you may safely ignore libraries
BINARIES=()

# FILES
# This setting is similar to BINARIES above, however, files are added
# as-is and are not parsed in any way. This is useful for config files.
FILES=()

# HOOKS
# This is the most important setting in this file. The HOOKS control the
# modules and scripts added to the image, and what happens at boot time.
# Order is important, and it is recommended that you do not change the
# order in which HOOKS are added. Run 'mkinitcpio -H <hook name>' for
# help on a given hook.
# 'base' is _required_ unless you know precisely what you are doing.
# 'udev' is _required_ in order to automatically load modules
# 'filesystems' is _required_ unless you specify your fs modules in MODULES
# Examples:
## This setup specifies all modules in the MODULES setting above.
## No raid, lvm2, or encrypted root is needed.
# HOOKS=(base)
#
## This setup will autodetect all modules for your system and should
## work as a sane default
# HOOKS=(base udev autodetect block filesystems)
#
## This setup will generate a 'full' image which supports most systems.
## No autodetection is done.
# HOOKS=(base udev block filesystems)
#
## This setup assembles a pata mdadm array with an encrypted root FS.
## Note: See 'mkinitcpio -H mdadm' for more information on raid devices.
# HOOKS=(base udev block mdadm encrypt filesystems)
#
## This setup loads an lvm2 volume group on a usb device.
# HOOKS=(base udev block lvm2 filesystems)
#
## NOTE: If you have /usr on a separate partition, you MUST include the
# usr, fsck and shutdown hooks.
HOOKS=(base udev modconf kms memdisk archiso archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs block filesystems keyboard)

# COMPRESSION
# Use this to compress the initramfs image. By default, gzip compression
# is used. Use 'cat' to create an uncompressed image.
#COMPRESSION="gzip"
#COMPRESSION="bzip2"
#COMPRESSION="lzma"
COMPRESSION="xz"
#COMPRESSION="lzop"
#COMPRESSION="lz4"
#COMPRESSION="zstd"

# COMPRESSION_OPTIONS
# Additional options for the compressor
#COMPRESSION_OPTIONS=()
8 changes: 8 additions & 0 deletions blackhole/airootfs/etc/mkinitcpio.d/linux.preset
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# mkinitcpio preset file for the 'linux' package on archiso

PRESETS=('archiso')

ALL_kver='/boot/vmlinuz-linux'
ALL_config='/etc/mkinitcpio.conf'

archiso_image="/boot/initramfs-linux.img"
7 changes: 7 additions & 0 deletions blackhole/airootfs/etc/modprobe.d/broadcom-wl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The broadcom-wl package requires some modules to be disabled in order to use
# wl. Since the ISO image needs to cover many hardware cases, this file
# overrides the default blacklist in /usr/lib/modprobe.d/
#
# If you need to use wl, you may need to delete this file, then `rmmod` any
# already-loaded modules that are now blacklisted before proceeding to modprobe
# wl itself.
11 changes: 11 additions & 0 deletions blackhole/airootfs/etc/motd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
To install Arch Linux follow the installation guide:
https://wiki.archlinux.org/title/Installation_guide

For Wi-Fi, authenticate to the wireless network using the iwctl utility.
For mobile broadband (WWAN) modems, connect with the mmcli utility.
Ethernet, WLAN and WWAN interfaces using DHCP should work automatically.

After connecting to the internet, the installation guide can be accessed
via the convenience script Installation_guide.

                                          
13 changes: 13 additions & 0 deletions blackhole/airootfs/etc/pacman.d/hooks/uncomment-mirrors.hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# remove from airootfs!
[Trigger]
Operation = Install
Operation = Upgrade
Type = Package
Target = pacman-mirrorlist

[Action]
Description = Uncommenting all mirrors in /etc/pacman.d/mirrorlist...
When = PostTransaction
Depends = pacman-mirrorlist
Depends = sed
Exec = /usr/bin/sed -i "s/#Server/Server/g" /etc/pacman.d/mirrorlist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# remove from airootfs!
# As a workaround for https://bugs.archlinux.org/task/49347 , remove pacman hooks specific to the ISO build process.
# If not, they would be used when pacstrap is run in the live environment.

[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = *

[Action]
Description = Work around FS#49347 by removing custom pacman hooks that are only required during ISO build...
When = PostTransaction
Depends = sh
Depends = coreutils
Depends = grep
Exec = /bin/sh -c "rm -- $(grep -Frl 'remove from airootfs' /etc/pacman.d/hooks/)"
1 change: 1 addition & 0 deletions blackhole/airootfs/etc/passwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
root:x:0:0:root:/root:/usr/bin/zsh
1 change: 1 addition & 0 deletions blackhole/airootfs/etc/resolv.conf
1 change: 1 addition & 0 deletions blackhole/airootfs/etc/shadow
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
root::14871::::::
116 changes: 116 additions & 0 deletions blackhole/airootfs/etc/ssh/sshd_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# $OpenBSD: sshd_config,v 1.104 2021/07/02 05:11:21 dtucker Exp $

# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/sbin:/usr/local/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no

# Change to no to disable s/key passwords
KbdInteractiveAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the KbdInteractiveAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via KbdInteractiveAuthentication may bypass
# the setting of "PermitRootLogin prohibit-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and KbdInteractiveAuthentication to 'no'.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem sftp /usr/lib/ssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Journal]
Storage=volatile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Login]
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
21 changes: 21 additions & 0 deletions blackhole/airootfs/etc/systemd/network/20-ethernet.network
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Match]
# Matching with "Type=ether" causes issues with containers because it also matches virtual Ethernet interfaces (veth*).
# See https://bugs.archlinux.org/task/70892
# Instead match by globbing the network interface name.
Name=en*
Name=eth*

[Network]
DHCP=yes
IPv6PrivacyExtensions=yes

# systemd-networkd does not set per-interface-type default route metrics
# https://github.com/systemd/systemd/issues/17698
# Explicitly set route metric, so that Ethernet is preferred over Wi-Fi and Wi-Fi is preferred over mobile broadband.
# Use values from NetworkManager. From nm_device_get_route_metric_default in
# https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/main/src/core/devices/nm-device.c
[DHCPv4]
RouteMetric=100

[IPv6AcceptRA]
RouteMetric=100
17 changes: 17 additions & 0 deletions blackhole/airootfs/etc/systemd/network/20-wlan.network
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Match]
Name=wl*

[Network]
DHCP=yes
IPv6PrivacyExtensions=yes

# systemd-networkd does not set per-interface-type default route metrics
# https://github.com/systemd/systemd/issues/17698
# Explicitly set route metric, so that Ethernet is preferred over Wi-Fi and Wi-Fi is preferred over mobile broadband.
# Use values from NetworkManager. From nm_device_get_route_metric_default in
# https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/main/src/core/devices/nm-device.c
[DHCPv4]
RouteMetric=600

[IPv6AcceptRA]
RouteMetric=600
Loading