mirror of
https://github.com/HeyPuter/puter.git
synced 2026-02-20 21:48:37 -06:00
dev: rootfs-v0.2.0
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<link href="<%= htmlWebpackPlugin.files.css[css] %>" rel="stylesheet">
|
||||
<% } %>
|
||||
|
||||
<script src="/puter.js/v2"></script>
|
||||
<script src="https://puter.com/puter.js/v2"></script>
|
||||
<script src="/vendor/v86/libv86.js"></script>
|
||||
<style>
|
||||
div {
|
||||
|
||||
@@ -16,40 +16,84 @@ RUN apk add --update \
|
||||
chsh -s /bin/bash
|
||||
|
||||
RUN apk add neofetch
|
||||
|
||||
COPY rootfs/ /
|
||||
|
||||
COPY basic-boot /etc/init.d/
|
||||
RUN chmod +x /etc/init.d/basic-boot
|
||||
|
||||
COPY assets/twisp /bin/twisp
|
||||
RUN chmod u+x /bin/twisp
|
||||
COPY twisp-service /etc/init.d/
|
||||
RUN chmod +x /etc/init.d/twisp-service
|
||||
RUN rc-update add twisp-service default
|
||||
|
||||
COPY debug-service /etc/init.d/
|
||||
RUN chmod +x /etc/init.d/debug-service
|
||||
RUN rc-update add debug-service default
|
||||
|
||||
COPY initd/network-service /etc/init.d/
|
||||
RUN chmod +x /etc/init.d/network-service
|
||||
RUN rc-update add network-service default
|
||||
|
||||
# programming language tools
|
||||
RUN apk add --no-cache \
|
||||
nodejs npm \
|
||||
php \
|
||||
perl \
|
||||
go
|
||||
|
||||
# RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
# ENV PATH="/root/.cargo/bin:${PATH}"
|
||||
# RUN rustup default nightly
|
||||
|
||||
# setup init system
|
||||
# COPY rc.conf /etc/rc.conf
|
||||
RUN rc-update add dmesg sysinit
|
||||
RUN rc-update add basic-boot sysinit
|
||||
RUN \
|
||||
rc-update add dmesg sysinit && \
|
||||
rc-update add basic-boot sysinit && \
|
||||
rc-update add root boot && \
|
||||
rc-update add localmount boot && \
|
||||
rc-update add modules boot && \
|
||||
rc-update add sysctl boot && \
|
||||
rc-update add bootmisc boot && \
|
||||
rc-update add syslog boot && \
|
||||
rc-update add mount-ro shutdown && \
|
||||
rc-update add killprocs shutdown && \
|
||||
rc-update add savecache shutdown
|
||||
|
||||
RUN rc-update add root boot
|
||||
RUN rc-update add localmount boot
|
||||
RUN rc-update add modules boot
|
||||
RUN rc-update add sysctl boot
|
||||
RUN rc-update add bootmisc boot
|
||||
RUN rc-update add syslog boot
|
||||
# Fun packages
|
||||
RUN apk add cowsay --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
|
||||
|
||||
RUN rc-update add mount-ro shutdown
|
||||
RUN rc-update add killprocs shutdown
|
||||
RUN rc-update add savecache shutdown
|
||||
# Shell
|
||||
RUN apk add zsh sudo git libgit2
|
||||
|
||||
COPY rootfs/ /
|
||||
RUN mkdir /root/Downloads
|
||||
|
||||
RUN bash
|
||||
# Setup user
|
||||
RUN useradd -m -s /bin/zsh puter-user
|
||||
RUN usermod -aG wheel puter-user
|
||||
RUN echo "puter-user:changeme" | chpasswd
|
||||
RUN echo '%wheel ALL=(ALL) ALL' > /etc/sudoers.d/wheel
|
||||
|
||||
# CLI Configuration
|
||||
# -- install powerlevel10k
|
||||
RUN mkdir /repos
|
||||
# RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git /repos/powerlevel10k
|
||||
# RUN echo "source /repos/powerlevel10k/powerlevel10k.zsh-theme" >> /root/.zshrc
|
||||
RUN echo "export COLORTERM=truecolor" >> /root/.bashrc
|
||||
RUN echo "export COLORTERM=truecolor" >> /root/.zshrc
|
||||
|
||||
RUN echo "export TERM=xterm-256color" >> /root/.bashrc
|
||||
RUN echo "export TERM=xterm-256color" >> /root/.zshrc
|
||||
|
||||
RUN echo "export LC_ALL=en_US.UTF-8" >> /root/.bashrc
|
||||
RUN echo "export LC_ALL=en_US.UTF-8" >> /root/.zshrc
|
||||
|
||||
# RUN echo "source /repos/powerlevel10k/powerlevel10k.zsh-theme" >> /home/puter-user/.zshrc
|
||||
RUN echo "export PS1='(\$?) [\u@puter:\$(basename \$(tty)) \$(prompt-path)] \\033[36;1m❯\\033[0m '" >> /root/.bashrc
|
||||
RUN echo "setopt PROMPT_SUBST" >> /root/.zshrc
|
||||
RUN echo "export PROMPT='(%?) [%n@puter:\$(basename \$(tty)) \$(prompt-path)] ❯ '" >> /root/.zshrc
|
||||
|
||||
RUN echo "/etc/puter-motd" >> /root/.bashrc
|
||||
RUN echo "/etc/puter-motd" >> /root/.zshrc
|
||||
|
||||
RUN cp /root/.zshrc /home/puter-user/.zshrc
|
||||
RUN cp /root/.bashrc /home/puter-user/.bashrc
|
||||
|
||||
RUN bash
|
||||
|
||||
@@ -25,7 +25,7 @@ docker rm "$CONTAINER_NAME" || true
|
||||
docker create --platform linux/386 -t -i --name "$CONTAINER_NAME" "$IMAGE_NAME" bash
|
||||
|
||||
docker export "$CONTAINER_NAME" > "$OUT_ROOTFS_TAR"
|
||||
dd if=/dev/zero "of=$OUT_ROOTFS_BIN" bs=512M count=2
|
||||
dd if=/dev/zero "of=$OUT_ROOTFS_BIN" bs=512M count=3
|
||||
|
||||
loop=$(sudo losetup -f)
|
||||
sudo losetup -P "$loop" "$OUT_ROOTFS_BIN"
|
||||
|
||||
91
src/emulator/image/rootfs/bin/apt
Executable file
91
src/emulator/image/rootfs/bin/apt
Executable file
@@ -0,0 +1,91 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo -e "\x1B[36;1m⚠️ This is not APT.\x1B[0m"
|
||||
echo -e "This is a simple wrapper for 'apk', Alpine's package manager."
|
||||
echo -e "https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management"
|
||||
echo ""
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: apt [options] [command] [command-options]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
valid_commands=("update" "install" "remove" "upgrade" "dist-upgrade" "full-upgrade" "search" "list" "autoremove" "clean" "show")
|
||||
|
||||
global_options=()
|
||||
command_options=()
|
||||
command=""
|
||||
|
||||
# Collect global options until a valid command is found
|
||||
while (("$#")); do
|
||||
arg="$1"
|
||||
shift
|
||||
if [[ " ${valid_commands[*]} " == *" $arg "* ]]; then
|
||||
command="$arg"
|
||||
break
|
||||
else
|
||||
global_options+=("$arg")
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$command" ]; then
|
||||
echo "Error: No valid command found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Collect command options and arguments
|
||||
while (("$#")); do
|
||||
command_options+=("$1")
|
||||
shift
|
||||
done
|
||||
|
||||
case "$command" in
|
||||
update)
|
||||
apk update "${global_options[@]}" "${command_options[@]}"
|
||||
;;
|
||||
install)
|
||||
args=()
|
||||
for arg in "${global_options[@]}" "${command_options[@]}"; do
|
||||
if [ "$arg" != "-y" ] && [ "$arg" != "--yes" ]; then
|
||||
args+=("$arg")
|
||||
fi
|
||||
done
|
||||
apk add "${args[@]}"
|
||||
;;
|
||||
remove)
|
||||
args=()
|
||||
for arg in "${global_options[@]}" "${command_options[@]}"; do
|
||||
if [ "$arg" != "--purge" ]; then
|
||||
args+=("$arg")
|
||||
fi
|
||||
done
|
||||
apk del "${args[@]}"
|
||||
;;
|
||||
upgrade | dist-upgrade | full-upgrade)
|
||||
apk upgrade "${global_options[@]}" "${command_options[@]}"
|
||||
;;
|
||||
search)
|
||||
apk search "${global_options[@]}" "${command_options[@]}"
|
||||
;;
|
||||
list)
|
||||
if [[ " ${command_options[*]} " == *" --installed "* ]]; then
|
||||
apk info -v "${global_options[@]}"
|
||||
else
|
||||
echo "Unsupported option for list command"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
autoremove)
|
||||
echo "apk does not have an autoremove command"
|
||||
;;
|
||||
clean)
|
||||
apk cache clean "${global_options[@]}" "${command_options[@]}"
|
||||
;;
|
||||
show)
|
||||
apk info "${global_options[@]}" "${command_options[@]}"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported apt command: $command"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
2
src/emulator/image/rootfs/bin/apt-get
Executable file
2
src/emulator/image/rootfs/bin/apt-get
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
/bin/apt
|
||||
28
src/emulator/image/rootfs/bin/prompt-path
Executable file
28
src/emulator/image/rootfs/bin/prompt-path
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Attempts to display the most relevant part of the current working directory
|
||||
|
||||
prompt_path () {
|
||||
local path=${PWD#/}
|
||||
local IFS='/'
|
||||
read -ra dirs <<< "$path"
|
||||
local dir_len=${#dirs[@]}
|
||||
|
||||
if (( dir_len == 0 )); then
|
||||
echo "/"
|
||||
elif (( dir_len == 1 )); then
|
||||
local first_letter=${dirs[0]:0:1}
|
||||
echo "${first_letter^^}"
|
||||
elif (( dir_len == 2 )); then
|
||||
local first_letter=${dirs[0]:0:1}
|
||||
echo "${first_letter^^}/${dirs[1]}"
|
||||
elif (( dir_len == 3 )); then
|
||||
local first_letter=${dirs[0]:0:1}
|
||||
echo "${first_letter^^}/.../${dirs[-1]}"
|
||||
else
|
||||
local first_letter=${dirs[0]:0:1}
|
||||
echo "${first_letter^^}/${dirs[1]}/.../${dirs[-1]}"
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_path
|
||||
0
src/emulator/image/debug-service → src/emulator/image/rootfs/etc/init.d/debug-service
Normal file → Executable file
0
src/emulator/image/debug-service → src/emulator/image/rootfs/etc/init.d/debug-service
Normal file → Executable file
1
src/emulator/image/initd/network-service → src/emulator/image/rootfs/etc/init.d/network-service
Normal file → Executable file
1
src/emulator/image/initd/network-service → src/emulator/image/rootfs/etc/init.d/network-service
Normal file → Executable file
@@ -8,6 +8,7 @@ start() {
|
||||
ifupdown ifup eth0
|
||||
ip link set lo up
|
||||
echo "nameserver 192.168.86.1" > /etc/resolv.conf
|
||||
echo "puter.local" > /etc/hostname
|
||||
eend $?
|
||||
}
|
||||
|
||||
0
src/emulator/image/twisp-service → src/emulator/image/rootfs/etc/init.d/twisp-service
Normal file → Executable file
0
src/emulator/image/twisp-service → src/emulator/image/rootfs/etc/init.d/twisp-service
Normal file → Executable file
4
src/emulator/image/rootfs/etc/puter-motd
Executable file
4
src/emulator/image/rootfs/etc/puter-motd
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
cowsay "Welcome to Alpine Linux in Puter."
|
||||
echo "Some packages are already pre-installed for convenience:"
|
||||
echo " python git nodejs npm php perl go, and others."
|
||||
@@ -220,8 +220,8 @@ window.onload = async function()
|
||||
status.phase_progress = 0;
|
||||
status.phase = 'rootfs-download';
|
||||
const resp = await fetch(
|
||||
// './image/build/rootfs.bin.br',
|
||||
'https://puter-rootfs.b-cdn.net/rootfs.bin.br',
|
||||
'./image/build/rootfs.bin.br',
|
||||
// 'https://puter-rootfs.b-cdn.net/rootfs.bin.br',
|
||||
);
|
||||
const contentLength = resp.headers.get('content-length');
|
||||
const total = parseInt(contentLength, 10);
|
||||
@@ -326,7 +326,7 @@ window.onload = async function()
|
||||
// bzimage_initrd_from_filesystem: true,
|
||||
autostart: true,
|
||||
|
||||
network_relay_url: emu_config.network_relay ?? "wisp://127.0.0.1:3000",
|
||||
network_relay_url: emu_config.network_relay ?? "wisp://127.0.0.1:4000",
|
||||
virtio_console: true,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user