From 3370b358114367e2ee1935fd1861d488d48c336b Mon Sep 17 00:00:00 2001 From: Mark Poliakov Date: Fri, 8 Dec 2023 17:52:21 +0200 Subject: [PATCH] init: scripts can now use #! --- build.sh | 1 + etc/inittab | 2 +- etc/rc.d/00-mount | 2 ++ etc/rc.d/99-motd | 0 init/src/rc.rs | 2 +- shell/src/main.rs | 4 ++++ 6 files changed, 9 insertions(+), 2 deletions(-) mode change 100644 => 100755 etc/rc.d/00-mount mode change 100644 => 100755 etc/rc.d/99-motd diff --git a/build.sh b/build.sh index 45ece895..edb50732 100755 --- a/build.sh +++ b/build.sh @@ -64,6 +64,7 @@ pack_initrd() { cp ${build_dir}/red ${root_dir}/bin/red cp -r ${workspace_dir}/etc ${root_dir}/ + chmod +x ${root_dir}/etc/rc.d/* cd "${root_dir}" mkdir -p dev diff --git a/etc/inittab b/etc/inittab index 970e4c55..e20b92de 100644 --- a/etc/inittab +++ b/etc/inittab @@ -1,3 +1,3 @@ init:1:wait:/sbin/rc default -user:1:once:/sbin/login /dev/ttyS0 +user:1:once:/sbin/login /dev/tty0 diff --git a/etc/rc.d/00-mount b/etc/rc.d/00-mount old mode 100644 new mode 100755 index 952aa04c..1bb7166e --- a/etc/rc.d/00-mount +++ b/etc/rc.d/00-mount @@ -1,2 +1,4 @@ +#!/bin/sh + /sbin/mount -t devfs /dev /sbin/mount -t sysfs /sys diff --git a/etc/rc.d/99-motd b/etc/rc.d/99-motd old mode 100644 new mode 100755 diff --git a/init/src/rc.rs b/init/src/rc.rs index 9111a0ca..9257c13c 100644 --- a/init/src/rc.rs +++ b/init/src/rc.rs @@ -42,7 +42,7 @@ fn exec_script>(path: P, arg: &str) -> Result<(), Error> { // TODO run those in parallel, if allowed // TODO binfmt guessing - let mut process = Command::new("/bin/sh").arg(path).arg(arg).spawn()?; + let mut process = Command::new(path).arg(arg).spawn()?; if !process.wait()?.success() { eprintln!("{:?}: Failed", path); diff --git a/shell/src/main.rs b/shell/src/main.rs index 9f23fd90..3f45d2fd 100644 --- a/shell/src/main.rs +++ b/shell/src/main.rs @@ -141,6 +141,10 @@ fn run(mut input: Input, vars: &mut HashMap) -> io::Result line.trim(), + None => line + }; let cmd = parser::parse_line(vars, line).unwrap(); match exec(input.is_interactive(), &cmd, vars) {