On Thu, Jan 01, 2015 at 03:52:17PM -0500, stephen Turner wrote:
> >
> >
> > It doesn't have to be a script, but it does have to be written to match
> > a specific set of rc scripts (the rc scripts are the shell part of
> > the init system; there's OpenRC, the LFS init scripts, the Debian init
> > scripts, the old RedHat init scripts, upstart and systemd implementions,
> > Slackware init scripts, and probably several more I'm not aware of).
> >
> >
> >
> Got it, well im just looking for standard start/stop/restart services so
> ill do a google later for a script or something i can utilize.

If you have standard (sysv-ish/openrc) init scripts,
# service sshd start
is equal to:
# /etc/init.d/sshd start

In other words, a basic implementation that wouldn't work with 
upstart/systemd is as follows:
#!/bin/sh
"/etc/init.d/$1" "$2"

> > No. It's toys/other/oneit.c (in the toybox tree).
> >
> > HTH,
> > Isaac Dunham
> >
> >
> Thanks, so I found the man for oneit but it only specifies opening a
> terminal. what about processing an inittab? will it allow for runlevels or
> adapt busybox style of no runlevel init?

oneit runs a command.
eg at the grub commandline:

grub> root (hd0,5)
grub> kernel /boot/bzImage root=/dev/sda6 init=/sbin/oneit -p sh
grub> boot

(hypothetical config with monolithic kernel built as bzImage, no
inittmpfs/initramfs/initrd support, installed on second logical
partition.)

There is no inittab. There are no startup scripts, unless you write and
run them manually.


If you want a (busybox-style) inittab and init scripts, enable "init"
in toys/pending. It hasn't been cleaned up, but I know it works.
You will then want to create some files:
/etc/inittab                    # chmod 0644
/etc/init.d/rcS                 # chmod 0755
/init                           # chmod 0755; hack because init needs /dev

Traditionally, /etc/init.d/rcS ultimately does essentially:
for SERVICE in /etc/rc${RUNLEVEL}.d/S*
  do "$SERVICE" start
  done
for SERVICE in /etc/rc${RUNLEVEL}.d/K*
  do "$SERVICE" stop
  done

and goes to the next runlevel.
Of course, $RUNLEVEL is irrelevant in toybox.
And that method gives you a serial boot making it rather slow, and 
there are traditionally a dozen levels of indirection, making it
even slower.

A minimalist example follows:
==/init==
#!/bin/sh
mount -t devtmpfs devtmpfs /dev
exec /sbin/init
==EOF==

==/etc/inittab==
::sysinit:/etc/init.d/rcS
tty1::respawn:/sbin/getty -l /bin/sh 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2
tty3::respawn:/sbin/getty 38400 tty3
::shutdown:/bin/sync
::restart:/bin/sync
tty1::shutdown:/bin/umount -a
tty1::restart:/bin/umount -a
==EOF==

==rcS==
#!/bin/sh
PATH=/sbin:/bin
mount -o remount,rw /dev/root /
mount -t proc proc /proc
mount -t sysfs sys /sys
mkdir -p /dev/pts /dev/shm
mount -t devpts devpts /dev/pts
mount -t tmpfs devshm /dev/shm
#to set modes of files in /dev:
#echo "/sbin/mdev" >/proc/sys/kernel/hotplug
#/sbin/mdev -s
#/var/run and /var/log should be made writeable if they are not already:
#mount -t tmpfs run /var/run
#mount -t tmpfs log /var/log
syslogd -S -D
klogd
find /sys -name modalias |xargs cat|xargs modprobe -abqs
==EOF==

This will not do much for you, beyond making sure that drivers are loaded.
You would need to configure networking.
Also note that you get a login-free root shell on tty1.

HTH,
Isaac Dunham
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to