Skip to content

Tsunami014/TerminalOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project is a Terminal OS: A simple, ASCII OS for the Linux Virtual Terminal, avaliable to all via ctrl+alt+F1-12 and then by signing in.

It is recommended to put this (or another that links to this) script (OS.py or you can just rename it to OS for convenience) somewhere in the PATH or your home folder so you can just run OS from the terminal as soon as it starts up.

This probably won't work on most other OS's. I haven't tested it, but it may work on any Linux distro. At least, it works on my Linux Mint (Ubuntu-based) system.

Required packages

  • python3
  • xsel (for clipboard functionality)

To run

MAKE SURE TO MAKE IT A BOOTABLE OS FIRST. You need to run up to step 5, as you need the python stuff in the rootfs folder. Once you've done that, just run OS and it will start up the OS in the terminal - running the OS inside the rootfs folder using the python in that folder too.

To add more apps

Download some python files, MAKING FULL CARE AS TO NOT DOWNLOAD MALICIOUS CODE, as this will run any code it sees. Put them in the external folder (make one if it doesn't exist) in this directory and they will be added to the OS.

To use in virtual terminal

To use this in the virtual terminal, press ctrl+alt+F1-12 and sign in. Then run the script as you would in a normal terminal. I suggest tty1 (ctrl+alt+F1) as it is the first one and is the most likely to be free. And with most systems, you can press ctrl+alt+F7 to return to the GUI (if not just try every one until one works). Then follow the 'to run' instructions above.

To make into a bootable OS

  1. Download python and build it manually into a rootfs (root filesystem) directory
mkdir -p rootfs rootfs/pycore
wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
tar xzf Python-3.12.0.tgz
rm Python-3.12.0.tgz
cd Python-3.12.0
./configure --disable-shared --enable-optimizations --prefix=$(realpath ../rootfs/pycore)
make -j4
make altinstall
cd ../
  1. Get apps that will be used
mkdir -p rootfs/bin
sudo apt install busybox-static
cp /bin/busybox rootfs/bin/sh
  1. Get libraries required
# Python libraries
rootfs/pycore/bin/pip3.12 install evdev requests

mkdir -p rootfs/lib rootfs/lib64

sudo apt install libffi8
sudo cp /usr/lib/x86_64-linux-gnu/libffi.so.8 rootfs/lib/x86_64-linux-gnu/libffi.so.8

for file in rootfs/pycore/bin/python3.12; do
    ldd "$file" | grep -P -o "/[^ \n]+" | while read lib; do
        target_dir="rootfs$(dirname "$lib")"
        mkdir -p "$target_dir"
        cp "$lib" "$target_dir"
    done
done
  1. Copy python code
cp py rootfs/py -r
  1. Add the start script
cat > rootfs/start <<EOF
#!/bin/sh
cd /py
export LANG=$LANG.UTF-8
/pycore/bin/python3.12 OS.py
EOF
chmod +x rootfs/start
  1. Compile and add the init code
gcc -static -o rootfs/init init.c
  1. Pack it into an initrd and move it to the boot folder
(cd rootfs && find . | cpio -o -H newc) | gzip > initrd-tos.img
sudo mv initrd-tos.img /boot/
  1. Update the GRUB to have the new OS as an option
sudo tee /etc/grub.d/40_custom > /dev/null <<EOF
#!/bin/sh
exec tail -n +3 $0

menuentry "Terminal OS"{
            search --set=root --file /boot/vmlinuz
            linux /boot/vmlinuz root=/dev/ram0 rdinit=/init
            initrd /boot/initrd-tos.img
}
EOF
sudo chmod +x /etc/grub.d/40_custom
sudo update-grub

Or here it is in one command:

# Get python
mkdir -p rootfs rootfs/pycore

wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
tar xzf Python-3.12.0.tgz
rm Python-3.12.0.tgz
cd Python-3.12.0

./configure --disable-shared --enable-optimizations --prefix=$(realpath ../rootfs/pycore)
make -j4
make altinstall

cd ../

# Get python libraries required
rootfs/pycore/bin/pip3.12 install evdev requests

# Get apps
mkdir -p rootfs/bin
sudo apt install busybox-static
cp /bin/busybox rootfs/bin/sh

# Get binary libraries required
mkdir -p rootfs/lib rootfs/lib64

sudo apt install libffi8
sudo cp /usr/lib/x86_64-linux-gnu/libffi.so.8 rootfs/lib/x86_64-linux-gnu/libffi.so.8

for file in rootfs/pycore/bin/python3.12; do
    ldd "$file" | grep -P -o "/[^ \n]+" | while read lib; do
        target_dir="rootfs$(dirname "$lib")"
        mkdir -p "$target_dir"
        cp "$lib" "$target_dir"
    done
done

# Copy python code
cp py rootfs/py -r

# Add init shell script
cat > rootfs/start <<EOF
#!/bin/sh
cd /py
export LANG=$LANG.UTF-8
/pycore/bin/python3.12 OS.py
EOF
chmod +x rootfs/start

# Compile init code
gcc -static -o rootfs/init init.c

# Compress into a .img
(cd rootfs && find . | cpio -o -H newc) | gzip > initrd-tos.img
sudo mv initrd-tos.img /boot/

# Add the register to GRUB
sudo tee /etc/grub.d/40_custom > /dev/null <<EOF
#!/bin/sh
exec tail -n +3 $0

menuentry "Terminal OS"{
            search --set=root --file /boot/vmlinuz
            linux /boot/vmlinuz root=/dev/ram0 rdinit=/init
            initrd /boot/initrd-tos.img
}
EOF
sudo chmod +x /etc/grub.d/40_custom
sudo update-grub

About

A window manager made entirely in ASCII for the Linux Virtual Terminal

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published