aboutsummaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
Diffstat (limited to 'files')
-rw-r--r--files/SETUP50
-rw-r--r--files/boot/grub.cfg31
-rw-r--r--files/boot/grub.initrd.cfg19
-rw-r--r--files/etc/fstab1
-rw-r--r--files/etc/group2
-rw-r--r--files/etc/hostname1
-rw-r--r--files/etc/mtab4
-rw-r--r--files/etc/passwd1
-rw-r--r--files/etc/resolv.conf0
-rw-r--r--files/etc/shadow1
-rwxr-xr-xfiles/rc133
-rwxr-xr-xfiles/runsystem137
-rw-r--r--files/runsystem.hurd155
-rwxr-xr-xfiles/runsystem.initrd10
14 files changed, 545 insertions, 0 deletions
diff --git a/files/SETUP b/files/SETUP
new file mode 100644
index 0000000..2fc10a3
--- /dev/null
+++ b/files/SETUP
@@ -0,0 +1,50 @@
+#!/bin/bash
+# Setup critical hurd translators
+
+PATH=/bin:/sbin:/hurd
+
+# BOOT_DEV="$1"
+# if [ ! "$BOOT_DEV" ]; then
+# echo "No device to install a boot loader was specified."
+# echo "Here are some possible devices to use:"
+# /bin/devprobe sd0 hd0 sd1 hd1
+# echo -n "Boot device? [none] "
+# read BOOT_DEV
+# fi
+#
+# if [ "$BOOT_DEV" ]; then
+# if /bin/devprobe -s "$BOOT_DEV"; then true; else
+# echo 2>&1 "$0: $BOOT_DEV: No such device known"; exit 1
+# fi
+# fi
+
+set -v
+
+# Make sure the filesystem is writable
+fsysopts / --writable
+
+# Set up standard passive translators
+/bin/settrans -c /servers/socket/local /hurd/pflocal
+/bin/settrans -c /servers/crash /hurd/crash
+/bin/settrans -c /servers/password /hurd/password
+/bin/settrans -c /servers/acpi /hurd/acpi
+/bin/settrans -c /servers/bus/pci /hurd/pci-arbiter
+
+# Setup crucial devices
+cd /dev
+rm -f console
+/bin/bash /sbin/MAKEDEV console std hd0 hd0s1 sd0 rumpdisk wd0 wd0s1 tty1 tty2 tty3 tty4 tty5 tty6
+set +v
+
+# if test "$BOOT_DEV" && /bin/sh ./MAKEDEV "$BOOT_DEV"; then
+# echo -n "Install grub as main boot record on $BOOT_DEV? [y] "
+# read yn
+# case "$yn" in
+# "" | "[yY]*")
+# /bin/sh /INSTALL-GRUB-MBR /dev/$BOOT_DEV;;
+# esac
+# fi
+
+rm -f /SETUP
+sync
+reboot
diff --git a/files/boot/grub.cfg b/files/boot/grub.cfg
new file mode 100644
index 0000000..25db24f
--- /dev/null
+++ b/files/boot/grub.cfg
@@ -0,0 +1,31 @@
+insmod part_msdos
+insmod ext2
+set root='hd0,msdos1'
+set menu_color_normal=cyan/blue
+set menu_color_highlight=white/black
+set timeout=1
+
+menuentry 'GNU' {
+ set root='hd0,msdos1'
+ echo 'Loading GNU Mach'
+ multiboot /boot/gnumach.gz root=part:1:device:wd0 noide
+ insmod part_msdos
+ insmod ext2
+ set root='hd0,msdos1'
+ echo 'Loading the Hurd ...'
+ module /hurd/pci-arbiter.static pci-arbiter \
+ --host-priv-port='${host-port}' --device-master-port='${device-port}' \
+ --next-task='${acpi-task}' \
+ '$(pci-task=task-create)' '$(task-resume)'
+ module /hurd/acpi.static acpi \
+ --next-task='${disk-task}' \
+ '$(acpi-task=task-create)'
+ module /hurd/rumpdisk.static rumpdisk \
+ --next-task='${fs-task}' \
+ '$(disk-task=task-create)'
+ module /hurd/ext2fs.static ext2fs \
+ --multiboot-command-line='${kernel-command-line}' \
+ --exec-server-task='${exec-task}' -T typed '${root}' \
+ '$(fs-task=task-create)'
+ module /lib/ld.so exec /hurd/exec '$(exec-task=task-create)'
+}
diff --git a/files/boot/grub.initrd.cfg b/files/boot/grub.initrd.cfg
new file mode 100644
index 0000000..41325bf
--- /dev/null
+++ b/files/boot/grub.initrd.cfg
@@ -0,0 +1,19 @@
+insmod part_msdos
+insmod ext2
+set root='hd0,msdos1'
+set menu_color_normal=cyan/blue
+set menu_color_highlight=white/black
+set timeout=20
+
+menuentry 'Hurd' {
+ set root='hd0,msdos1'
+ echo 'Loading GNU Mach'
+ multiboot /boot/gnumach console=com0
+ echo 'Loading the Hurd initrd...'
+ module /boot/initrd.ext2 initrd.ext2 '$(ramdisk-create)'
+ echo 'Loading ext2fs.static'
+ module /sbin/ext2fs.static ext2fs --multiboot-command-line='${kernel-command-line}' --readonly --host-priv-port='${host-port}' --device-master-port='${device-port}' --exec-server-task='${exec-task}' --kernel-task='${kernel-task}' -T device rd0 '$(fs-task=task-create)' '$(prompt-task-resume)'
+ echo 'Loading exec'
+ module /lib/ld.so.1 ld.so.1 /hurd/exec --device-master-port='${device-port}' '$(exec-task=task-create)'
+ boot
+}
diff --git a/files/etc/fstab b/files/etc/fstab
new file mode 100644
index 0000000..a1df882
--- /dev/null
+++ b/files/etc/fstab
@@ -0,0 +1 @@
+/dev/wd0s1 / ext2 defaults 0 1
diff --git a/files/etc/group b/files/etc/group
new file mode 100644
index 0000000..fcfc2a1
--- /dev/null
+++ b/files/etc/group
@@ -0,0 +1,2 @@
+root:x:0:
+daemon:x:1:
diff --git a/files/etc/hostname b/files/etc/hostname
new file mode 100644
index 0000000..16b8348
--- /dev/null
+++ b/files/etc/hostname
@@ -0,0 +1 @@
+hurd
diff --git a/files/etc/mtab b/files/etc/mtab
new file mode 100644
index 0000000..4140ff7
--- /dev/null
+++ b/files/etc/mtab
@@ -0,0 +1,4 @@
+/dev/wd0s1 / ext2fs writable,no-inherit-dir-group,store-type=typed 0 0
+none /run /hurd/tmpfs writable,no-suid,no-exec,no-inherit-dir-group,no-sync,size=187152K 0 0
+none /run/lock /hurd/tmpfs writable,no-suid,no-exec,no-inherit-dir-group,no-sync,size=5M 0 0
+none /run/shm /hurd/tmpfs writable,no-suid,no-exec,no-inherit-dir-group,no-sync,size=415520K 0 0
diff --git a/files/etc/passwd b/files/etc/passwd
new file mode 100644
index 0000000..5e5956e
--- /dev/null
+++ b/files/etc/passwd
@@ -0,0 +1 @@
+root::0:0:root:/root:/bin/bash
diff --git a/files/etc/resolv.conf b/files/etc/resolv.conf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/files/etc/resolv.conf
diff --git a/files/etc/shadow b/files/etc/shadow
new file mode 100644
index 0000000..6081749
--- /dev/null
+++ b/files/etc/shadow
@@ -0,0 +1 @@
+root:*:0:0:99999:7:::
diff --git a/files/rc b/files/rc
new file mode 100755
index 0000000..0339eaf
--- /dev/null
+++ b/files/rc
@@ -0,0 +1,133 @@
+#!/bin/bash
+
+PATH=/bin:/sbin:/hurd
+
+# Set up swap space. This will complain if no default pager is functioning.
+swapon -a
+
+# Check filesystems.
+if [ -r /fastboot ]
+then
+ # ... or don't.
+ rm -f /fastboot
+ echo Fast boot ... skipping disk checks
+elif [ $1x = autobootx ]
+then
+ echo Automatic boot in progress...
+ date
+
+ /sbin/fsck -a
+
+ case $? in
+ # Successful completion
+ 0)
+ ;;
+ # Filesystem modified (but ok now)
+ 1)
+ ;;
+ # Filesystem modified, filesystem should be restarted
+ # Ideally we would only restart the filesystem
+ 2 | 3)
+ /sbin/reboot
+ ;;
+ # Fsck couldn't fix it.
+ 4 | 5 | 8 | 9)
+ echo "Automatic boot failed... help!"
+ exit 1
+ ;;
+ # Signal that really interrupted something
+ 20 | 130 | 131)
+ echo "Boot interrupted"
+ exit 1
+ ;;
+ # Special `let fsck finish' interruption (SIGQUIT)
+ 12)
+ echo "Boot interrupted (filesystem checks complete)"
+ exit 1
+ ;;
+ # Oh dear.
+ *)
+ echo "Unknown error during fsck (exit status $?)"
+ exit 1
+ ;;
+ esac
+fi
+
+fsysopts / --writable
+echo -n cleaning up left over files...
+rm -f /etc/nologin
+rm -f /var/lock/LCK.*
+if test -d /tmp; then
+
+ # Forcibly remove all translators in the directory.
+ # It is then safe to attempt to remove files and descend directories.
+ # All parameters must begin with "./".
+ function remove_translators() {
+ local f
+ for f; do
+ settrans -pagfS "$f"
+ if [ -L "$f" ] || [ ! -d "$f" ]; then
+ rm "$f"
+ else
+ remove_translators "$f"/* "$f"/.[!.] "$f"/.??*
+ rmdir "$f"
+ fi
+ done
+ }
+
+ (cd /tmp
+ shopt -s nullglob
+ for f in * .[!.] .??*; do
+ case "$f" in
+ 'lost+found'|'quotas') ;;
+ *) remove_translators "./$f"
+ esac
+ done)
+
+ unset -f remove_translators # because it relies on nullglob
+
+fi
+if test -d /var/run; then
+ (cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
+fi
+echo done
+
+# This file must exist for e2fsck to work. XXX
+touch /var/run/mtab
+
+#echo -n restoring pty permissions...
+#chmod 666 /dev/tty[pqrs]*
+#echo done
+
+#echo -n updating /etc/motd...
+#echo GNU\'s Not Unix Version `uname --release` > /tmp/newmotd
+#egrep -v 'GNU|Version' /etc/motd >> /tmp/newmotd
+#mv /tmp/newmotd /etc/motd
+#echo done
+
+chmod 664 /etc/motd
+
+echo -n starting daemons:
+
+if [ -x "/sbin/syslogd" ]; then
+ /sbin/syslogd && echo -n ' syslogd'
+fi
+if [ -x "/sbin/inetd" ]; then
+ /sbin/inetd && echo -n ' inetd'
+fi
+
+if test -x /sbin/sendmail -a -r /etc/sendmail.cf; then
+ /sbin/sendmail -bd -q30m && echo -n ' sendmail'
+fi
+
+echo .
+
+echo -n starting translators:
+
+if [ ! -e /proc/cmdline ]; then
+ settrans -ac /proc /hurd/procfs --compatible && echo -n ' procfs'
+fi
+
+echo .
+
+date
diff --git a/files/runsystem b/files/runsystem
new file mode 100755
index 0000000..98d7f42
--- /dev/null
+++ b/files/runsystem
@@ -0,0 +1,137 @@
+#!/bin/bash
+#
+# This program is run by /hurd/init at boot time after the essential
+# servers are up. It does some initialization of its own and then
+# execs /hurd/init or any other roughly SysV init-compatible program
+# to bring up the "userland" parts of a normal system.
+#
+
+
+###
+### Where to find programs, etc.
+###
+
+PATH=/bin:/sbin:/hurd
+export PATH
+
+umask 022
+
+# If we lose badly, try to exec each of these in turn.
+fallback_shells='/bin/bash /bin/dash /bin/sh /bin/csh /bin/ash /bin/shd'
+
+# Shell used for normal single-user startup.
+SHELL=/bin/bash
+
+# The init program to call.
+#
+# Can be overridden using init=something in the kernel command line.
+init=/hurd/init
+
+###
+
+
+# If we get a SIGLOST, attempt to reopen the console in case
+# our console ports were revoked. This lets us print messages.
+function reopen_console ()
+{
+ exec 1>/dev/console 2>&1 || exit 3
+}
+trap 'reopen_console' SIGLOST
+
+
+# Call this when we are losing badly enough that we want to punt normal
+# startup entirely. We exec a single-user shell, so we will not come back
+# here. The only way to get to multi-user from that shell will be
+# explicitly exec this script or something like that.
+function singleuser()
+{
+ test $# -eq 0 || echo "$0: $*"
+ for try in ${fallback_shells}; do
+ SHELL=${try}
+ exec ${SHELL}
+ done
+ exit 127
+}
+
+# Print a newline.
+echo
+echo "Starting the HURD..."
+
+# See whether pflocal is set up already, and do so if not (install case)
+#
+# Normally this should be the case, but we better make sure since
+# without the pflocal server, pipe(2) does not work.
+if ! test -e /servers/socket/1 ; then
+ # The root filesystem should be read-only at this point.
+ if fsysopts / --update --writable ; then
+ settrans -c /servers/socket/1 /hurd/pflocal
+ else
+ singleuser "Failed to create /servers/socket/1."
+ fi
+fi
+
+if [ -x "/SETUP" ]; then
+ echo "This is the first execution of the system."
+ echo "I'm going to setup everything and then reboot. Please wait..."
+ sleep 2
+ ./SETUP
+ exit 0
+fi
+
+# We expect to be started by console-run, which gives us no arguments and
+# puts FALLBACK_CONSOLE=file-name in the environment if our console is
+# other than a normal /dev/console.
+
+if [ "${FALLBACK_CONSOLE+set}" = set ]; then
+ singleuser "Running on fallback console ${FALLBACK_CONSOLE}"
+fi
+
+
+###
+### Normal startup procedures
+###
+
+# Parse the multiboot command line. We only pay attention to -s and -f.
+# The first argument is the kernel file name; skip that.
+shift
+flags=
+single=
+while [ $# -gt 0 ]; do
+ arg="$1"
+ shift
+ case "$arg" in
+ --*) ;;
+ init=*)
+ eval "${arg}"
+ ;;
+ *=*) ;;
+ -*)
+ flags="${flags}${arg#-}"
+ ;;
+ 'single')
+ single="-s"
+ ;;
+ 'fastboot'|'emergency')
+ ;;
+ esac
+done
+
+# Check boot flags.
+case "$flags" in
+*s*)
+ single="-s" # force single-user
+ ;;
+esac
+
+# Start the default pager. It will bail if there is already one running.
+# TODO: we crash if we start it, investigate to understand what is happening.
+# /hurd/mach-defpager
+
+# This is necessary to make stat / return the correct device ids.
+# Work around a race condition (probably in the root translator).
+for i in `seq 1 100000` ; do : ; done # XXX
+
+fsysopts / --update --readonly
+
+# Finally, start the actual init.
+exec ${init} ${single} -a
diff --git a/files/runsystem.hurd b/files/runsystem.hurd
new file mode 100644
index 0000000..60f9e72
--- /dev/null
+++ b/files/runsystem.hurd
@@ -0,0 +1,155 @@
+#!/bin/bash
+#
+# This program is run by /hurd/init at boot time after the essential
+# servers are up, and is responsible for running the "userland" parts of a
+# normal system. This includes running the single-user shell as well as a
+# multi-user system. This program is expected never to exit.
+#
+
+
+###
+### Where to find programs, etc.
+###
+
+PATH=/bin:/sbin:/hurd
+export PATH
+
+umask 022
+
+# If we lose badly, try to exec each of these in turn.
+fallback_shells='/bin/sh /bin/bash /bin/dash /bin/csh /bin/ash /bin/shd'
+
+# Shell used for normal single-user startup.
+SHELL=/bin/bash
+
+# Programs that do multi-user startup.
+RUNCOM=/libexec/rc
+RUNTTYS=/libexec/runttys
+# Signals that we should pass down to runttys.
+runttys_sigs='TERM INT HUP TSTP'
+
+###
+
+
+# If we get a SIGLOST, attempt to reopen the console in case
+# our console ports were revoked. This lets us print messages.
+function reopen_console ()
+{
+ exec 1>/dev/console 2>&1 || exit 3
+}
+trap 'reopen_console' SIGLOST
+
+
+# Call this when we are losing badly enough that we want to punt normal
+# startup entirely. We exec a single-user shell, so we will not come back
+# here. The only way to get to multi-user from that shell will be
+# explicitly exec this script or something like that.
+function singleuser ()
+{
+ test $# -eq 0 || echo "$0: $*"
+ for try in ${fallback_shells}; do
+ SHELL=${try}
+ exec ${SHELL}
+ done
+ exit 127
+}
+
+
+# See whether pflocal is set up already, and do so if not (install case)
+#
+# Normally this should be the case, but we better make sure since
+# without the pflocal server, pipe(2) does not work.
+if ! test -e /servers/socket/1 ; then
+ # The root filesystem should be read-only at this point.
+ if fsysopts / --update --writable ; then
+ settrans -c /servers/socket/1 /hurd/pflocal
+ else
+ singleuser "Failed to create /servers/socket/1."
+ fi
+fi
+
+# We expect to be started by console-run, which gives us no arguments and
+# puts FALLBACK_CONSOLE=file-name in the environment if our console is
+# other than a normal /dev/console.
+
+if [ "${FALLBACK_CONSOLE+set}" = set ]; then
+ singleuser "Running on fallback console ${FALLBACK_CONSOLE}"
+fi
+
+
+###
+### Normal startup procedures
+###
+
+# Parse the multiboot command line. We only pay attention to -s and -f.
+# The first argument is the kernel file name; skip that.
+shift
+flags=
+while [ $# -gt 0 ]; do
+ arg="$1"
+ shift
+ case "$arg" in
+ --*) ;;
+ *=*) ;;
+ -*)
+ flags="${flags}${arg#-}"
+ ;;
+ 'single'|'emergency') # Linux compat
+ flags="${flags}s"
+ ;;
+ 'fastboot')
+ flags="${flags}f"
+ ;;
+ esac
+done
+
+# Check boot flags.
+case "$flags" in
+*s*)
+ rc=false # force single-user
+ ;;
+*f*)
+ rc="${RUNCOM}" # fastboot
+ ;;
+*)
+ rc="${RUNCOM} autoboot" # multi-user default
+ ;;
+esac
+
+# Large infinite loop. If this script ever exits, init considers that
+# a serious bogosity and punts to a fallback single-user shell.
+# We handle here the normal transitions between single-user and multi-user.
+while : ; do
+
+ # Run the rc script. As long as it exits nonzero, punt to single-user.
+ # After the single-user shell exits, we will start over attempting to
+ # run rc; but later invocations strip the `autoboot' argument.
+ until $rc; do
+ rc=${RUNCOM}
+
+ # Run single-user shell and repeat as long as it dies with a signal.
+ until ${SHELL} || test $? -lt 128; do
+ :
+ done
+ done
+
+ # Now we are officially ready for normal multi-user operation.
+
+ # Trap certain signals and send them on to runttys. For this to work, we
+ # must run it asynchronously and wait for it with the `wait' built-in.
+ runttys_pid=0
+ for sig in $runttys_sigs; do
+ trap "kill -$sig \${runttys_pid}" $sig
+ done
+
+ # This program reads /etc/ttys and starts the programs it says to.
+ ${RUNTTYS} &
+ runttys_pid=$!
+
+ # Wait for runttys to die, meanwhile handling trapped signals.
+ wait
+
+ # Go back to the top of the infinite loop, as if booting single-user.
+ rc=false
+
+done
diff --git a/files/runsystem.initrd b/files/runsystem.initrd
new file mode 100755
index 0000000..be3ccfc
--- /dev/null
+++ b/files/runsystem.initrd
@@ -0,0 +1,10 @@
+#!/bin/sh
+# runsystem for initrd.
+
+settrans -ac /dev/mach-console /hurd/streamio console
+exec <>/dev/mach-console >&0 2>&0
+export PATH=/bin:/sbin
+echo Hello from /bin/sh!
+uname -a
+settrans -ac /proc /hurd/procfs --stat-mode=444
+exec /bin/sh -i