From 24c03e809079f56e7e27f2a8c246d0b39a793d6d Mon Sep 17 00:00:00 2001 From: Marc Date: Sat, 26 Feb 2022 19:23:34 +0100 Subject: [PATCH] =?UTF-8?q?Reorganisation=20de=20tout=20le=20syst=C3=A9me?= =?UTF-8?q?=20de=20build=20+=20debuggage=20os=20loader=20au=20autre=20scri?= =?UTF-8?q?pts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + TODO.MD | 6 + build.sh | 123 ++++++++++++------ clean.sh | 1 + createLiveImage.sh | 18 ++- fakesh/build.sh | 2 +- grub/build.sh | 13 +- libc/build.sh | 5 +- libgcc/build.sh | 2 +- liblzma/build.sh | 2 +- libudev/build.sh | 2 +- lvm2/build.sh | 2 +- nodejs/build.sh | 13 +- nodejs/patch.sh | 2 +- npmi.sh | 2 +- osLoader/build.sh | 4 +- osLoader/osLoader.c | 6 +- rootfs overrides/boot/grub/grub.cfg | 4 +- rootfs overrides/core/hook.js | 33 ++++- rootfs overrides/core/index.js | 9 +- rootfs overrides/core/ip.js | 13 +- rootfs overrides/etc/init.d/startupSound.js | 2 +- rootfs overrides/usr/bin/sheebr.js | 27 +--- .../usr/lib/sheebr/environment.js | 1 - utillinux/build.sh | 2 +- 25 files changed, 188 insertions(+), 107 deletions(-) create mode 100644 TODO.MD diff --git a/.gitignore b/.gitignore index d633cc6..34b1806 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ rootfs.iso chibrax.tar.gz rootfs +libfs linux-firmware disk.img diskoffset diff --git a/TODO.MD b/TODO.MD new file mode 100644 index 0000000..7889991 --- /dev/null +++ b/TODO.MD @@ -0,0 +1,6 @@ +#TODO LIST + +- grub-mkconfig.js +- set ipv4 +- dns +- desktop \ No newline at end of file diff --git a/build.sh b/build.sh index 1499729..bf96085 100755 --- a/build.sh +++ b/build.sh @@ -1,88 +1,115 @@ -#!/bin/bash +#!./bash-static if [ "$EUID" = 0 ] then echo "Please don't run this as root" exit fi +unset LD_LIBRARY_PATH +export LD_LIBRARY_PATH=$(pwd)/libfs/usr/lib +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/libfs/usr/lib32 +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/libfs/usr/lib64 +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/libfs/usr/local/lib64 +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/libfs/usr/local/lib +#host system for backup +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib64 +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib32 +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64 +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib + +unset LD_LIBRARY_PATH + +echo $LD_LIBRARY_PATH + +function makeroot { + mkdir -p ${1}/boot || exit 1 + mkdir -p ${1}/chibrax || exit 1 + mkdir -p ${1}/usr/local/bin || exit 1 + mkdir -p ${1}/usr/local/sbin || exit 1 + mkdir -p ${1}/usr/local/lib || exit 1 + mkdir -p ${1}/usr/local/lib64 || exit 1 + mkdir -p ${1}/usr/local/etc || exit 1 + mkdir -p ${1}/usr/bin || exit 1 + mkdir -p ${1}/usr/sbin || exit 1 + mkdir -p ${1}/usr/lib || exit 1 + mkdir -p ${1}/usr/lib32 || exit 1 + mkdir -p ${1}/dev || exit 1 + mkdir -p ${1}/sys || exit 1 + mkdir -p ${1}/tmp || exit 1 + mkdir -p ${1}/home || exit 1 + mkdir -p ${1}/root || exit 1 + mkdir -p ${1}/proc || exit 1 + mkdir -p ${1}/run || exit 1 + + echo "creating ${1} links" + cd ${1} + ln -s usr/bin bin || exit 1 + ln -s usr/sbin sbin || exit 1 + ln -s usr/lib lib || exit 1 + ln -s usr/lib lib64 || exit 1 + cd - + cd ${1}/usr + ln -s lib lib64 || exit 1 + cd - +} + # 2> /dev/null veut dire que l'on veut pas voire les erreurs sudo umount rootfs/proc -R 2> /dev/null sudo rm -rf rootfs/ 2> /dev/null +sudo rm -rf libfs/ 2> /dev/null sudo rm root.iso 2> /dev/null sudo rm chibrax.tar.gz 2> /dev/null -mkdir -p rootfs/ -mkdir -p rootfs/boot -mkdir -p rootfs/chibrax -mkdir -p rootfs/usr/local/bin -mkdir -p rootfs/usr/local/sbin -mkdir -p rootfs/usr/local/lib -mkdir -p rootfs/usr/local/lib64 -mkdir -p rootfs/usr/local/etc -mkdir -p rootfs/usr/bin -mkdir -p rootfs/usr/sbin -mkdir -p rootfs/usr/lib -mkdir -p rootfs/usr/lib32 -mkdir -p rootfs/dev -mkdir -p rootfs/sys -mkdir -p rootfs/tmp -mkdir -p rootfs/home -mkdir -p rootfs/root -#TODO: faire des lien vers usr/bin et usr/sbin -mkdir -p rootfs/proc -mkdir -p rootfs/run +makeroot libfs || exit 1 +makeroot rootfs || exit 1 npm i -cd rootfs -ln -s usr/bin bin || exit 1 -ln -s usr/sbin sbin || exit 1 -ln -s usr/lib lib || exit 1 -ln -s usr/lib lib64 || exit 1 -cd - cd rootfs/usr ln -s lib lib64 - cd - +echo "done" + echo "construction de la libc" chmod +x ./libc/build.sh -cd libc && ./build.sh || exit 1 && cd - +cd libc && ./build.sh > /dev/null || exit 1 && cd - echo "done" echo "construction de gcc" chmod +x ./libgcc/build.sh -cd libgcc && ./build.sh || exit 1 && cd - +cd libgcc && ./build.sh > /dev/null || exit 1 && cd - echo "done" echo "construction de eudev" chmod +x ./libudev/build.sh -cd libudev && ./build.sh || exit 1 && cd - +cd libudev && ./build.sh > /dev/null || exit 1 && cd - echo "done" echo "construction de lvm2(libdemapper)" chmod +x ./lvm2/build.sh -cd lvm2 && ./build.sh || exit 1 && cd - +cd lvm2 && ./build.sh > /dev/null || exit 1 && cd - echo "done" echo "construction de liblzma" chmod +x ./liblzma/build.sh -cd liblzma && ./build.sh || exit 1 && cd - +cd liblzma && ./build.sh > /dev/null || exit 1 && cd - echo "done" echo "construction de grub" chmod +x ./grub/build.sh -cd grub && ./build.sh || exit 1 && cd - +cd grub && ./build.sh > /dev/null || exit 1 && cd - echo "done" echo "construction de Nodejs" chmod +x ./nodejs/build.sh -cd nodejs && ./build.sh || exit 1 && cd - +cd nodejs && ./build.sh || exit 1 && cd - echo "done" echo "construction du loader" -chmod +x ./chibraxLoader/build.sh -cd chibraxLoader && ./build.sh && cd - -sudo cp chibraxLoader/init rootfs/usr/bin/ || exit 1 +chmod +x ./osLoader/build.sh +cd osLoader && ./build.sh && cd - +sudo cp osLoader/init rootfs/usr/sbin/ || exit 1 echo "done" echo "construction du bypass de sh" @@ -91,7 +118,7 @@ cd fakesh && ./build.sh && cd - echo "done" echo "construction du kernel" -cd kernel && ./from_current.sh && cd - +cd kernel && ./from_current.sh > /dev/null && cd - echo "done" echo "Cloning the firmware" @@ -103,7 +130,23 @@ sudo cp linux-firmware/* rootfs/usr/lib/firmware/ -r || exit 1 echo "done" echo "rebuilding C++ hooks" -./clibs.sh || exit 1 +./clibs.sh > /dev/null || exit 1 echo "done" +cp libfs/usr/lib64/libstdc++.so.6.0.29 rootfs/usr/lib/ +cd rootfs/usr/lib/ && ln -s libstdc++.so.6.0.29 libstdc++.so.6 && ln -s libstdc++.so.6.0.29 libstdc++.so && cd - +cp libfs/usr/lib/libm.so.6 rootfs/usr/lib/ +cp libfs/usr/lib/ld-linux-x86-64.so.2 rootfs/usr/lib +cp libfs/usr/lib/libgcc_s.so* rootfs/usr/lib +cp libfs/usr/lib/libc.so.6 rootfs/usr/lib +cp libfs/usr/lib/liblzma.so.5.0.4 rootfs/usr/lib +cd rootfs/usr/lib/ && ln -s liblzma.so.5.0.4 liblzma.so.5 && ln -s liblzma.so.5.0.4 liblzma.so && cd - +cp libfs/usr/lib/libdevmapper.so.1.02 rootfs/usr/lib +cd rootfs/usr/lib/ && ln -s libdevmapper.so.1.02 libdevmapper.so && cd - +cp libfs/sbin/ldconfig rootfs/sbin + sudo cp rootfs\ overrides/* rootfs/ -r || exit 1 + +unset LD_LIBRARY_PATH + +#`libtool --finish /usr/lib \ No newline at end of file diff --git a/clean.sh b/clean.sh index 36cd887..c0c397e 100755 --- a/clean.sh +++ b/clean.sh @@ -1,4 +1,5 @@ rm -rf rootfs +rm -rf libfs rm -rf build rm -f disk.img rm -f diskoffset \ No newline at end of file diff --git a/createLiveImage.sh b/createLiveImage.sh index 8786390..b26c6fb 100755 --- a/createLiveImage.sh +++ b/createLiveImage.sh @@ -5,22 +5,28 @@ then echo "Please run as root" exit fi -if [ ! -d rootfs\ overrides/chibrax/node_modules ] +if [ ! -d rootfs\ overrides/core/node_modules ] then echo "please run npmi.sh" exit 1 fi -CHIBRAX_MOUNT_POINT="/tmp/chibraxMountPoint" +CHIBRAX_MOUNT_POINT="/tmp/core" rm -f disk.img +while umount -R rootfs/proc +do + echo "" +done + #create a 8Gb iso dd if=/dev/zero of=disk.img bs=1024k seek=$((1000 * 8)) count=0 #creating a msdos image for mbr boot parted disk.img mklabel msdos parted disk.img mkpart primary ext4 0% 100% +#parted disk.img name 1 root START_SECTOR=$(file disk.img | cut -d',' -f 8 | cut -d' ' -f3) echo "Start sector :" $START_SECTOR OFFSET=$((512*$START_SECTOR)) @@ -39,7 +45,7 @@ mkfs.ext4 ${LOOP} mount ${LOOP} $CHIBRAX_MOUNT_POINT echo "rebuilding C++ hooks" -./clibs.sh +./clibs.sh > /dev/null 2> /dev/null echo "done" echo "coping rootfs" @@ -54,16 +60,16 @@ mount --rbind /sys $CHIBRAX_MOUNT_POINT/sys mount --make-rslave $CHIBRAX_MOUNT_POINT/sys mount --rbind /tmp $CHIBRAX_MOUNT_POINT/tmp -chroot $CHIBRAX_MOUNT_POINT /sbin/ldconfig -p +chroot $CHIBRAX_MOUNT_POINT /usr/sbin/ldconfig chroot $CHIBRAX_MOUNT_POINT /usr/sbin/grub-install --target=i386-pc ${LOOP_ROOT} --modules=part_msdos -chroot $CHIBRAX_MOUNT_POINT /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg +#chroot $CHIBRAX_MOUNT_POINT /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg PARTUUID=$(lsblk $LOOP --fs | awk '{print $4}' | grep -v LABEL) echo "menuentry 'Chibrax OS' {" >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg echo " set root='hd0,msdos1'" >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg -echo " linux /boot/vmlinuz rootfstype=ext4 root=/dev/sda1 rw " >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg +echo " linux /boot/vmlinuz rootfstype=ext4 root=/dev/sda1 rw " >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg echo "}" >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg umount $CHIBRAX_MOUNT_POINT/dev -l diff --git a/fakesh/build.sh b/fakesh/build.sh index cc4259b..07eb844 100755 --- a/fakesh/build.sh +++ b/fakesh/build.sh @@ -1,4 +1,4 @@ #!/bin/sh -gcc fakesh.c -o executor +gcc fakesh.c -O3 -o executor cp executor ../rootfs/bin/ \ No newline at end of file diff --git a/grub/build.sh b/grub/build.sh index 9cb3b7c..6a605e4 100755 --- a/grub/build.sh +++ b/grub/build.sh @@ -18,15 +18,14 @@ then fi cd src - #no shure git.sv.gnu.org still exists but i had problems with my proxy anyway + #not sure git.sv.gnu.org still exists but i had problems with my proxy anyway sed -i "s/git\:\/\/git\.sv\.gnu\.org\/gnulib/https\:\/\/git.savannah.gnu.org\/git\/gnulib.git/g" ./bootstrap - ./bootstrap - ./configure --disable-werror --prefix=/usr - make -j$(nproc) + ./configure \ + --disable-werror \ + --prefix=/usr || exit 1 + make -j$(nproc) || exit 1 - DESTDIR=$(pwd)/../../rootfs - - sudo make install DESTDIR=$(realpath $DESTDIR) + sudo make install DESTDIR=$(realpath $(pwd)/../../rootfs) cd - diff --git a/libc/build.sh b/libc/build.sh index 1dd6710..ead45f8 100755 --- a/libc/build.sh +++ b/libc/build.sh @@ -6,6 +6,7 @@ fi git clone https://sourceware.org/git/glibc.git src cd src +git restore . git checkout release/2.34/master git pull cd - @@ -13,8 +14,8 @@ cd - mkdir src/build -p cd src/build pwd -../configure --sysconfdir=/etc -prefix=/usr --with-headers=/usr/include --with-bugurl=https://bugs.archlinux.org/ --enable-add-ons --enable-bind-now --enable-cet --enable-kernel=4.4 --enable-lock-elision --enable-multi-arch --enable-stack-protector=strong --enable-stackguard-randomization --enable-static-pie --enable-systemtap --disable-profile --disable-werror || exit 1 +../configure --sysconfdir=/etc -prefix=/usr --with-headers=/usr/include --enable-add-ons --enable-bind-now --enable-cet --enable-kernel=5.14 --enable-lock-elision --enable-multi-arch --enable-stack-protector=strong --enable-stackguard-randomization --enable-static-pie --enable-systemtap --disable-profile --disable-werror || exit 1 make -j$(nproc) || exit 1 -DESTDIR=$(pwd)/../../../rootfs +DESTDIR=$(pwd)/../../../libfs sudo make install DESTDIR=$(realpath $DESTDIR) cd - \ No newline at end of file diff --git a/libgcc/build.sh b/libgcc/build.sh index b4ccc43..05afa6b 100755 --- a/libgcc/build.sh +++ b/libgcc/build.sh @@ -14,6 +14,6 @@ fi cd src ./configure --prefix=/usr make -j$(nproc) -DESTDIR=$(pwd)/../../rootfs +DESTDIR=$(pwd)/../../libfs sudo make install DESTDIR=$(realpath $DESTDIR) cd - diff --git a/liblzma/build.sh b/liblzma/build.sh index 5c62962..262b327 100755 --- a/liblzma/build.sh +++ b/liblzma/build.sh @@ -9,7 +9,7 @@ git pull ./configure --prefix /usr make -j$(nproc) -DESTDIR=$(pwd)/../../rootfs +DESTDIR=$(pwd)/../../libfs sudo make install DESTDIR=$(realpath $DESTDIR) cd - \ No newline at end of file diff --git a/libudev/build.sh b/libudev/build.sh index c18f71a..fc2afab 100755 --- a/libudev/build.sh +++ b/libudev/build.sh @@ -16,7 +16,7 @@ cd src ./configure --prefix=/usr --sysconfdir=/etc --enable-add-ons --enable-bind-now --enable-cet --enable-kernel=4.4 --enable-lock-elision --enable-stack-protector=strong --enable-stackguard-randomization --enable-static-pie --enable-systemtap --disable-profile --disable-werror make -j$(nproc) -DESTDIR=$(pwd)/../../rootfs +DESTDIR=$(pwd)/../../libfs sudo make install DESTDIR=$(realpath $DESTDIR) cd - \ No newline at end of file diff --git a/lvm2/build.sh b/lvm2/build.sh index c13d49b..aa4d22e 100755 --- a/lvm2/build.sh +++ b/lvm2/build.sh @@ -7,6 +7,6 @@ git pull ./autogen.sh ./configure make -j$(nproc) -DESTDIR=$(pwd)/../../rootfs +DESTDIR=$(pwd)/../../libfs sudo make install DESTDIR=$(realpath $DESTDIR) cd - \ No newline at end of file diff --git a/nodejs/build.sh b/nodejs/build.sh index dcba376..73369f8 100755 --- a/nodejs/build.sh +++ b/nodejs/build.sh @@ -5,7 +5,7 @@ then echo "Please don't run this as root" exit fi -VERSION=17.5.0 +export VERSION=17.6.0 if [ ! -f src/node-$VERSION/Makefile ] then @@ -14,18 +14,15 @@ cd src echo "clonning" curl https://github.com/nodejs/node/archive/refs/tags/v$VERSION.zip -L --output $VERSION.zip || exit 1 unzip $VERSION.zip || exit 1 -./patch.sh cd - +./patch.sh || exit 1 fi echo "building" -#LD_LIBRARY_PATH=$(pwd)/../rootfs/lib:$(pwd)/../rootfs/lib64:$(pwd)/../rootfs/usr/lib:$(pwd)/../rootfs/usr/lib32:$(pwd)/../rootfs/usr/lib64:/lib:$(pwd)/lib64:$(pwd)/usr/lib:$(pwd)/usr/lib32:$(pwd)/usr/lib64 +#privilégier les lib interne a l'os cd src/node-$VERSION -#https://github.com/nodejs/node/issues/41497 -./configure --prefix=/usr --fully-static --enable-static || exit 1 -for i in out/tools/v8_gypfiles/gen-regexp-special-case.target.mk out/test_crypto_engine.target.mk; do -sed -i 's/\-static//g' $i || echo "nevermind"; done +./configure --prefix=/usr || exit 1 make -j$(nproc) || exit 1 cd - -sudo src/node-$VERSION/tools/install.py install $(pwd)/../rootfs || exit 1 \ No newline at end of file +sudo src/node-$VERSION/tools/install.py install $(pwd)/../rootfs || exit 1 diff --git a/nodejs/patch.sh b/nodejs/patch.sh index dfb29b0..f6e7b11 100755 --- a/nodejs/patch.sh +++ b/nodejs/patch.sh @@ -1,2 +1,2 @@ #!/bin/bash -patch -R src/node-17.1.0/lib/child_process.js patches/child_process_executor.diff \ No newline at end of file +patch -R src/node-${VERSION}/lib/child_process.js patches/child_process_executor.diff \ No newline at end of file diff --git a/npmi.sh b/npmi.sh index 5d32a6f..6792c5c 100755 --- a/npmi.sh +++ b/npmi.sh @@ -4,4 +4,4 @@ then echo "Please don't run as root" fi npm i -cd rootfs\ overrides/chibrax && npm i && cd - \ No newline at end of file +cd rootfs\ overrides/core && npm i && cd - \ No newline at end of file diff --git a/osLoader/build.sh b/osLoader/build.sh index 10b9465..467191f 100755 --- a/osLoader/build.sh +++ b/osLoader/build.sh @@ -4,4 +4,6 @@ then echo "Please don't run this as root" exit fi -gcc osLoader.c -static -O3 -o init +CFLAGS="" + +gcc osLoader.c -o init diff --git a/osLoader/osLoader.c b/osLoader/osLoader.c index 58cad01..7e34301 100644 --- a/osLoader/osLoader.c +++ b/osLoader/osLoader.c @@ -1,9 +1,9 @@ #include #include //Chemin exacte de node (a changer aprés la creation d'un gestionnaire de packets) -#define node "/usr/local/bin/node" -#define chibrax "/core/index.js" +#define NODE "/usr/local/bin/node" +#define INIT "/core/index.js" int main() { - execl(node, node, chibrax); + execl(NODE, NODE, INIT, NULL); } diff --git a/rootfs overrides/boot/grub/grub.cfg b/rootfs overrides/boot/grub/grub.cfg index 3b1bcfa..f000746 100644 --- a/rootfs overrides/boot/grub/grub.cfg +++ b/rootfs overrides/boot/grub/grub.cfg @@ -55,7 +55,7 @@ if [ x$feature_default_font_path = xy ] ; then else insmod part_gpt insmod ext2 -search --no-floppy --fs-uuid --set=root c461e81d-f7a8-4d29-a874-f441afe07e45 +search --no-floppy --label --set=root root font="/usr/share/grub/unicode.pf2" fi @@ -71,7 +71,7 @@ terminal_input console terminal_output gfxterm insmod part_gpt insmod ext2 -search --no-floppy --fs-uuid --set=root c461e81d-f7a8-4d29-a874-f441afe07e45 +search --no-floppy --label --set=root root insmod gfxmenu loadfont ($root)/usr/share/grub/themes/sleek/DejaVuSans-48.pf2 loadfont ($root)/usr/share/grub/themes/sleek/DejaVuSans-Regular-14.pf2 diff --git a/rootfs overrides/core/hook.js b/rootfs overrides/core/hook.js index 14546a9..1e9eab5 100644 --- a/rootfs overrides/core/hook.js +++ b/rootfs overrides/core/hook.js @@ -1,5 +1,5 @@ //@ts-check -const { exec, fork } = require('child_process'); +const { exec, fork, spawn } = require('child_process'); /** * @param {string} path * @deprecated @@ -20,4 +20,33 @@ async function fHook(path) { }) } -module.exports = { hookTo, fHook } \ No newline at end of file +/** + * @param { string } cmd + * @param { import('child_process').SpawnOptionsWithoutStdio } [option] + */ +async function spawnAndWait(cmd, option) { + const child = spawn(cmd, option) + + child.stdout.pipe(process.stdout) + child.stderr.pipe(process.stderr) + process.stdin.pipe(child.stdin) + + await new Promise((res, rej) => { + child.on('exit', () => { + res() + }) + }) + process.stdin.unpipe(child.stdin) +} + +/** + * @param { string } path + * @param { string[] } [args] + * @param { import('child_process').SpawnOptionsWithoutStdio } [options] + */ +async function startjs(path, args = [], options = {}) { + const arguments = args.map(arg => {return arg.includes(' ') ? `"${arg}"` : arg}).join(' ') + return spawnAndWait(`/usr/local/bin/node ${path} ${arguments}`, options) +} + +module.exports = { hookTo, fHook, spawnAndWait, startjs } \ No newline at end of file diff --git a/rootfs overrides/core/index.js b/rootfs overrides/core/index.js index 7df3e4a..cb53c10 100644 --- a/rootfs overrides/core/index.js +++ b/rootfs overrides/core/index.js @@ -1,5 +1,6 @@ - //@ts-check +const fs = require('fs') + function panic() { console.log("/!\\ INIT PANIK /!\\ LOSE CHIBRE") while(1) {} @@ -16,7 +17,11 @@ async function main() { await initd() //chainload into sheebr - await fHook("/usr/bin/sheebr.js") + if(fs.existsSync("/usr/bin/sheebr.js")) { + await fHook("/usr/bin/sheebr.js") + } else { + console.log('wrong shell path') + } reboot.disableCtrlAltSupr() reboot.powerOff() diff --git a/rootfs overrides/core/ip.js b/rootfs overrides/core/ip.js index 4f7b155..2bef57b 100644 --- a/rootfs overrides/core/ip.js +++ b/rootfs overrides/core/ip.js @@ -40,4 +40,15 @@ function getFlags(interface) { return ip.getFlags(interface); } -module.exports = { setFlags, getFlags, flags } \ No newline at end of file +/** + * @param { string } interface + * @param { Uint8Array } address + */ +function setIpv4(interface, address) { + if( address.length !== 4) { + throw new Error('invalid address length'); + } + ip.setIpv4(interface, address.join('.')); +} + +module.exports = { setFlags, getFlags, setIpv4, flags } \ No newline at end of file diff --git a/rootfs overrides/etc/init.d/startupSound.js b/rootfs overrides/etc/init.d/startupSound.js index e3af8bd..f41476f 100644 --- a/rootfs overrides/etc/init.d/startupSound.js +++ b/rootfs overrides/etc/init.d/startupSound.js @@ -1,7 +1,7 @@ const audio = require('../../core/audio') async function init() { - audio('/chibrax/sheeebr.wav') + audio('/core/sheeebr.wav') } const after = [ "filesystem.js" ] // list of init script to load before diff --git a/rootfs overrides/usr/bin/sheebr.js b/rootfs overrides/usr/bin/sheebr.js index ca2883f..d2d0a47 100644 --- a/rootfs overrides/usr/bin/sheebr.js +++ b/rootfs overrides/usr/bin/sheebr.js @@ -4,28 +4,7 @@ const { getline } = require('../lib/sheebr/utils') const fs = require('fs') let environment = require('../lib/sheebr/environment') let aliases = require("../lib/sheebr/aliases") -let { spawn } = require('child_process') - -//utiliser ce code au lieux de execSync permet d'afficher le stdout au fur et a mesure ce qui fait qu'on a les logs quand une application throw une erreur -/** - * @param { string } cmd - * @param { import('child_process').SpawnOptionsWithoutStdio } [option] - */ -async function spawnAndWait(cmd, option) { - const child = spawn(cmd, option) - - child.stdout.pipe(process.stdout) - child.stderr.pipe(process.stderr) - process.stdin.pipe(child.stdin) - - await new Promise((res, rej) => { - child.on('exit', () => { - res() - }) - }) - process.stdin.unpipe(child.stdin) -} - +const { startjs } = require('../../core/hook') let current_dir = process.cwd() @@ -90,7 +69,9 @@ async function evaluateProgram(args){ if(files.includes(`${args[0]}.js`)){ found = true; try { - await spawnAndWait(`${environment.node} ${path + '/' + args[0]}.js ${args.map(arg => {return arg.includes(' ') ? `"${arg}"` : arg}).join(' ')}`, {cwd: current_dir, env: environment, shell: true}); + const cmd = `${path + '/' + args[0]}.js` + const options = {cwd: current_dir, env: environment, shell: true} + await startjs(cmd, args, options) tobreak = true; } catch(e) { console.log("Program crashed") diff --git a/rootfs overrides/usr/lib/sheebr/environment.js b/rootfs overrides/usr/lib/sheebr/environment.js index 55dce3f..27e9d84 100644 --- a/rootfs overrides/usr/lib/sheebr/environment.js +++ b/rootfs overrides/usr/lib/sheebr/environment.js @@ -9,7 +9,6 @@ let environment = { ln: [1, 36], ex: [1, 32] }), - node: "/usr/local/bin/node" } module.exports = environment \ No newline at end of file diff --git a/utillinux/build.sh b/utillinux/build.sh index ae8ad43..0e13beb 100755 --- a/utillinux/build.sh +++ b/utillinux/build.sh @@ -18,6 +18,6 @@ cd src ./autogen.sh || exit 1 ./configure || exit 1 make -j$(nproc)|| exit 1 -DESTDIR=$(pwd)/../../rootfs +DESTDIR=$(pwd)/../../libfs sudo make install DESTDIR=$(realpath $DESTDIR) cd - \ No newline at end of file