add cinit-0.3pre16

Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
This commit is contained in:
Nico Schottelius 2009-09-29 21:36:27 +02:00
commit 0c13ed6979
1089 changed files with 101811 additions and 0 deletions

View file

@ -0,0 +1,3 @@
Scripts for internal use.
Users: Use bin/ for usable helper programs.

View file

@ -0,0 +1,20 @@
#!/bin/sh
# Nico Schottelius, 2006-07-28
#
# cinit: configure the ipc method to use
#
HIER=$(dirname $0)
DDIR=$HIER/../../src/ipc
DFILE=${DDIR}/current
IPC_METHOD=$(head -n 1 "$HIER/../../conf/ipc_method")
echo "Configure: IPC: Using \"$IPC_METHOD\" as IPC method"
# always remove link before, as ln seems to be broken
# Doing ln -sf src/ipc/$method current twice, will create the file
# "current" _BELOW_ src/ipc/$method and not overwrite the link
# src/ipc/current
rm -f "${DFILE}"
ln -sf "${IPC_METHOD}" "${DFILE}"

View file

@ -0,0 +1,8 @@
#!/bin/sh
# Nico Schottelius
# cinit: touch a file to mark everything configured
# 2006-08-27
#
echo "Configure: MK: Marking directory as configured"
touch .configured

View file

@ -0,0 +1,15 @@
#!/bin/sh
# Nico Schottelius
# cinit: setups symlinks for the os
#
DDIR=$(dirname $0)/../../src/os
DFILE="$DDIR/current"
OSCONFIG=$(dirname $0)/../../conf/os
OS=$(head -n 1 "$OSCONFIG")
echo "Configure: OS: Binaries are created for $OS ..."
rm -f "${DFILE}"
ln -sf "${OS}" "${DFILE}"

View file

@ -0,0 +1,24 @@
#!/bin/sh
# Nico Schottelius
# cinit: setups scripts for compiling and linking
#
HIER=$(dirname $0)
DDIR=$HIER/../../tmpbin/
CC=$(head -n 1 "$HIER/../../conf/cc")
CFLAGS=$(head -n 1 "$HIER/../../conf/cflags")
LD=$(head -n 1 "$HIER/../../conf/ld")
LDFLAGS=$(head -n 1 "$HIER/../../conf/ldflags")
STRIP=$(head -n 1 "$HIER/../../conf/strip")
echo "Configure: CC: Creating cc, ld and strip ..."
mkdir -p "$DDIR"
cd "$DDIR"
echo "$CC $CFLAGS \"\$@\"" > cc
echo "$LD $LDFLAGS \"\$@\"" > ld
echo "$STRIP \"\$@\"" > strip
# set correct permissions
chmod 0700 *

View file

@ -0,0 +1,20 @@
#!/bin/sh
# Nico Schottelius
# 2007-05-20, 0110 CEST
# cconfig: create makefile from conf/ directory
# currently: all files
# later: only built-defines
#
CONFS=$($(dirname $0)/cinit.get-confdir)/../conf/*
echo "#"
echo "# Warning: Autogenerated by $0, do not edit. "
echo "#"
for conf in ${CONFS}; do
NAME="$(basename $conf | tr a-z A-Z)"
value=$(head -n 1 $conf)
echo "${NAME}=${value}"
done

View file

@ -0,0 +1,12 @@
#!/bin/sh
# Nico Schottelius
# cinit: build environment to be used in scripts
# * Should be sourced by using scripts
# 2006-10-26
#
. $(dirname $0)/cinit.read-conf
export BASEDIR=${DESTDIR}${CINIT_DIR}
export SERVICES=${BASEDIR}/${SVCDIR}
export CONFIG=${BASEDIR}/${CONFDIR}

View file

@ -0,0 +1,17 @@
#!/bin/sh
# Nico Schottelius
# cinit: read configuration into variables
# Date: 2005-05-24 (Last Changed: 2005-08-08)
# try environment first
if [ "$CINIT_CONF_DIR" ]; then
CONFDIR=$CINIT_CONF_DIR
elif [ -d $(dirname $0)/../conf/ ]; then
CONFDIR=$(dirname $0)/../conf/
else
echo 'Did not find cinit configuration!' >&2
echo "Please set the variable CINIT_CONF_DIR" >&2
exit 1
fi
echo $CONFDIR

View file

@ -0,0 +1,32 @@
#!/bin/sh
# Nico Schottelius
# cinit: create header file
#
CONFS=$($(dirname $0)/cinit.get-confdir)/../conf/*
echo "/* Warning: Autogenerated by $0, do not edit. */"
for conf in $CONFS; do
NAME="$(basename $conf | tr a-z A-Z)"
value=$(head -n 1 $conf)
# check if numeric: no quotes needed
is_numeric=$(echo $value | awk '/^((0[xX])[0-9a-fA-F]+)|([0-9]+)$/ { print }')
is_string="$(echo $value | grep '^"')"
#
# Check for quote type
#
if [ ! "$is_numeric" -a ! "$is_string" ]; then
one_char=$(echo -n $value | wc -c)
if [ "$one_char" -eq 1 ]; then
value="'$value'"
else
# is a string
value="\"$value\""
fi
fi
echo "#define" "$NAME" "$value"
done

View file

@ -0,0 +1,18 @@
#!/bin/sh
# Nico Schottelius
# cinit: read configuration into variables
# ~ 2005
#
CONFS=$($(dirname $0)/cinit.get-confdir)
set -e
for conf in ${CONFS}/*; do
NAME="$(basename $conf | tr a-z A-Z)"
if eval test -z \$$NAME; then
eval $NAME=\"$(head -n 1 $conf)\"
eval export $NAME
fi
# eval echo $NAME = \$$NAME
done

View file

@ -0,0 +1 @@
Scripts used to generate or aid in creating a configuration.

View file

@ -0,0 +1,10 @@
#!/bin/sh
# Nico Schottelius
# 2007-05-21
#
# Task:
# Reads list of services to create from stdin
# Create services (add correct dependencies)
#
# Options:
# -d: alternate destination directory (instead of /etc/cinit/svc)

View file

@ -0,0 +1,10 @@
#!/bin/sh
# Nico Schottelius
# 2007-05-21
#
# Task:
# Reads list of services to enabled from stdin
# Services must already exist
#
# Options:
# -d: alternate destination directory (instead of /etc/cinit/svc)

View file

@ -0,0 +1,12 @@
#!/bin/sh
# Nico Schottelius
# 2007-05-21
#
# Task:
# Search for enabled services:
# - /etc/rc.conf
# - /usr/local/etc/rc.d/
# Output list of services to stdout
#
# Options:
# -r <alternate root directory>

View file

@ -0,0 +1,12 @@
#!/bin/sh
# Nico Schottelius
# 2007-05-21
#
# Task:
# Search all services:
# - /etc/rc.conf
# - /usr/local/etc/rc.d/
# Output list of all services to stdout
#
# Options:
# -r <alternate root directory>

View file

@ -0,0 +1 @@
Scripts that should move to bin/ as soon as they are ready to be used.

View file

@ -0,0 +1,126 @@
#!/bin/sh
# Nico Schottelius
# Date: Sun Oct 16 16:57:03 CEST 2005
# cLinux/cinit
# Automagically convert Debian-Sysv-Iinit
# THIS IS NOT CLEAN.
# THIS IS NOT EVEN INTENTED TO BE CLEAN.
# This is just a small hack, because my girlfriend wants her notebook back.
# -- She's not my girlfriend anymore, but now I want to test cinit-0.3pre15 on
# my notebook
echo "***> $(basename $0): converting Debian-Sys-V-Init"
# read standard values, may be overwritten from outside
. $(dirname $0)/cinit-conf.read-conf
if [ -d "${CINIT_DIR}" ]; then
echo "ERROR: Configuration directory exists already at ${CINIT_DIR}."
exit 1
fi
echo "***> Finding standard config ..."
# variables, which can be set from the outside
: ${ROOT_DEV:=$(awk '$2 ~ /^\/$/ { print $1 }' ${DESTDIR}/etc/fstab)}
: ${ROOT_FSCK:=$(awk '$2 ~ /^\/$/ { print $6 }' ${DESTDIR}/etc/fstab)}
: ${ROOT_FS:=$(awk '$2 ~ /^\/$/ { print $3 }' ${DESTDIR}/etc/fstab)}
: ${HOSTNAME:=$(hostname)}
echo "***> Configuration"
echo "Destdir: (\$DESTDIR): $DESTDIR"
echo "Hostname (\$HOSTNAME): $HOSTNAME"
#echo "Keymap (\$C_KEYMAP): $C_KEYMAP"
echo "Root device (\$ROOT_DEV): $ROOT_DEV"
echo "Root fsck (\$ROOT_FSCK): $ROOT_FSCK"
echo "Root FS (\$ROOT_FS): $ROOT_FS"
echo "Config-Dir: (\$CINIT_DIR): $CINIT_DIR"
read -p "Is this correct (Y/n) " correct
set -x
echo "***> Installing standard structure and dependencies"
set -e
$(dirname $0)/cinit-conf.install.dirs.base
$(dirname $0)/cinit-conf.install.dirs.svc-categories
$(dirname $0)/cinit-conf.install.standard.init.deps
echo "***> Adding mount / r/w"
$(dirname $0)/cinit-conf.install.service.mount-root
if [ "$ROOT_FSCK" = "1" ]; then
echo "***> Adding fsck for $ROOT_DEV ..."
$(dirname $0)/cinit-conf.install.service.linux.fsck root "$ROOT_DEV" "$ROOT_FS"
echo "***> Adding dependency"
$(dirname $0)/cinit-conf.add.dependency mount/root needs fsck/root
else
echo "***> Skipping fsck for $ROOT_DEV (\$ROOT_FSCK is not 1 in fstab)..."
fi
echo "***> Setting up hostname: $HOSTNAME"
$(dirname $0)/cinit-conf.install.service.linux.hostname "$HOSTNAME"
echo "***> Creating getties (tty1-8)"
for i in `seq 1 8`; do
$(dirname $0)/cinit-conf.getty.add
# each getty needs:
# - root r/w
$(dirname $0)/cinit.add.dependency getty/$i needs mount/root
# - hostname
$(dirname $0)/cinit.add.dependency getty/$i needs network/hostname
done
echo "***> Enabling getties (tty2-8)"
for i in `seq 2 8`; do
# add getties to getty/
$(dirname $0)/cinit-conf.add.dependency getty wants getty/$i
done
exit 0
# FIXME: Stopped here
echo "***> Setting up standard mounts ..."
$(dirname $0)/cinit.install.service.hostname.generic "$HOSTNAME"
#
# Convert services: check /etc/rcS.d and /etc/rcX.d
#
echo "***> Converting services ..."
for script in $(cd /etc/rcS.d/; ls S*; cd /etc/rc${RUNLEVEL}.d/; ls S*); do
echo -n "$script: "
case $script in
# SCRIPTS READY
*ntpdate)
$(dirname $0)/cinit.install.service.ntpdate.debian
$(dirname $0)/cinit.add.dependency local-tuning/ntpdate needs network
;;
*udev*)
$(dirname $0)/cinit.install.service.udev
# SCRIPTS NEVER READY
*glibc.sh|*module-init-tools|*modutils|*procps.sh|*hotplug-net|*bootmisc.sh|*nviboot|*screen-cleanup|*x11-common|*sudo|*makedev|*rmnologin)
echo "Ignoring (useless)."
;;
# SCRIPTS NOT YET READY
*mountvirtfs|*checkroot.sh|*ifupdown-clean|*checkfs.sh|*mountall.sh|*ifupdown|*hostname*|*mountnfs.sh|*alsa|*rsync|*ssh|*fam|*cron|*gdm)
echo "converting planned later."
;;
# SCRIPTS LATER TO DO
*bootlogd|*keymap.sh|*hwclock*|*discover|*pppd-dns|*dns-clean|*networking|*portmap|*console-screen.sh|*urandom|*klogd|*apmd|*dbus-1|*exim4|*pcmcia|*nfs-common|*stop-bootlogd)
echo "unsupported currently (FIXME PLEASE)."
;;
*sysklogd|*ppp|*inetd|*lpd|*aumix|*atd)
echo "unsupported (choose a better alternative)."
;;
*initrd-tools.sh|*libdevmapper*|*hotplug)
echo "Ignoring (general or bloated script)."
;;
*)
echo "Ignoring (unknown)"
;;
esac
done
echo "***> Finished."

View file

@ -0,0 +1,139 @@
#!/bin/sh
# Nico Schottelius
# Date: Sun Oct 16 16:57:03 CEST 2005
# cLinux/cinit
# Automagically convert Debian-Sysv-Iinit
# THIS IS NOT CLEAN.
# THIS IS NOT EVEN INTENTED TO BE CLEAN.
# This is just a small hack, because my girlfriend wants her notebook back.
# -- She's not my girlfriend anymore, but now I want to test cinit-0.3pre15 on
# my notebook
echo "***> $(basename $0): converting Debian-Sys-V-Init"
# read standard values, may be overwritten from outside
. $(dirname $0)/cinit-conf.read-conf
echo "***> Finding standard config ..."
# variables, which can be set from the outside
ROOT_DEV=${ROOT_DEV:-$(awk '$2 ~ /^\/$/ { print $1 }' /etc/fstab)}
ROOT_FSCK=${ROOT_FSCK:-$(awk '$2 ~ /^\/$/ { print $6 }' /etc/fstab)}
ROOT_FS=${ROOT_FS:-$(awk '$2 ~ /^\/$/ { print $3 }' /etc/fstab)}
RUNLEVEL=${RUNLEVEL:-$(runlevel | awk '{ print $2 }')}
echo "***> Detecting keymap (this may take some time)"
if [ -z "$C_KEYMAP" ]; then
echo "Please set the variable C_KEYMAP to your keymap."
echo "It is impossible to detect reliable your keymap in Debian."
exit 1
fi
echo "***> Configuration"
echo "Hostname (\$HOSTNAME): $HOSTNAME"
echo "Keymap (\$C_KEYMAP): $C_KEYMAP"
echo "Root device (\$ROOT_DEV): $ROOT_DEV"
echo "Root fsck (\$ROOT_FSCK): $ROOT_FSCK"
echo "Root FS (\$ROOT_FS): $ROOT_FS"
echo "Runlevel (\$RUNLEVEL): $RUNLEVEL"
echo "Destdir: (\$DESTDIR): $DESTDIR"
echo "Config-Dir: (\$CINIT_DIR): $CINIT_DIR"
read -p "Is this correct (Y/n) " correct
if [ "$correct" != "y" -a "$correct" != "Y" ]; then
echo "***> Abort."
exit 1
fi
if [ -d "${DESTDIR}${CINIT_DIR}" ]; then
echo "ERROR: Configuration already exists at ${DESTDIR}${CINIT_DIR}."
exit 1
fi
echo "***> Installing standard structure and dependencies"
set -e
$(dirname $0)/cinit.install.config-dir
$(dirname $0)/cinit.install.standard.dirs
$(dirname $0)/cinit.install.standard.init.deps
echo "***> Adding mount / r/w"
$(dirname $0)/cinit.install.service.mount-root
if [ "$ROOT_FSCK" = "1" ]; then
echo "***> Adding fsck for $ROOT_DEV ..."
$(dirname $0)/cinit.install.fsck root "$ROOT_DEV" "$ROOT_FS"
echo "***> Adding dependency"
$(dirname $0)/cinit.add.dependency mount/root needs fsck/root
else
echo "***> Skipping fsck for $ROOT_DEV ..."
fi
echo "***> Setting up standard mounts ..."
$(dirname $0)/cinit.install.service.hostname.generic "$HOSTNAME"
echo "***> Setting up hostname: $HOSTNAME"
$(dirname $0)/cinit.install.service.hostname.generic "$HOSTNAME"
echo "***> Setting up keymap"
$(dirname $0)/cinit.install.service.keymap.c_keymap
echo "***> Creating getties (tty1-8)"
for i in `seq 1 8`; do
$(dirname $0)/cinit.add.getty
# each getty needs:
# - root r/w
$(dirname $0)/cinit.add.dependency getty/$i needs mount/root
# - hostname
$(dirname $0)/cinit.add.dependency getty/$i needs network/hostname
done
echo "***> Enabling getties (tty2-8)"
for i in `seq 2 8`; do
# add getties to getty/
$(dirname $0)/cinit.add.dependency getty wants getty/$i
done
#
# Convert services: check /etc/rcS.d and /etc/rcX.d
#
echo "***> Converting services ..."
for script in $(cd /etc/rcS.d/; ls S*; cd /etc/rc${RUNLEVEL}.d/; ls S*); do
echo -n "$script: "
case $script in
# SCRIPTS READY
*ntpdate)
$(dirname $0)/cinit.install.service.ntpdate.debian
$(dirname $0)/cinit.add.dependency local-tuning/ntpdate needs network
;;
*udev*)
$(dirname $0)/cinit.install.service.udev
# SCRIPTS NEVER READY
*glibc.sh|*module-init-tools|*modutils|*procps.sh|*hotplug-net|*bootmisc.sh|*nviboot|*screen-cleanup|*x11-common|*sudo|*makedev|*rmnologin)
echo "Ignoring (useless)."
;;
# SCRIPTS NOT YET READY
*mountvirtfs|*checkroot.sh|*ifupdown-clean|*checkfs.sh|*mountall.sh|*ifupdown|*hostname*|*mountnfs.sh|*alsa|*rsync|*ssh|*fam|*cron|*gdm)
echo "converting planned later."
;;
# SCRIPTS LATER TO DO
*bootlogd|*keymap.sh|*hwclock*|*discover|*pppd-dns|*dns-clean|*networking|*portmap|*console-screen.sh|*urandom|*klogd|*apmd|*dbus-1|*exim4|*pcmcia|*nfs-common|*stop-bootlogd)
echo "unsupported currently (FIXME PLEASE)."
;;
*sysklogd|*ppp|*inetd|*lpd|*aumix|*atd)
echo "unsupported (choose a better alternative)."
;;
*initrd-tools.sh|*libdevmapper*|*hotplug)
echo "Ignoring (general or bloated script)."
;;
*)
echo "Ignoring (unknown)"
;;
esac
done
echo "***> Finished."

View file

@ -0,0 +1,103 @@
#!/bin/sh
# Nico Schottelius
# cinit: install basic setup
# Date: 2005-08-07
#
. $(dirname $0)/cinit.read-conf
echo "****************************************************************************"
echo "******************************* WARNING ************************************"
echo "****************************************************************************"
echo ""
echo "This will install a minimal cinit configuration."
echo "This configuration _SHOULD_ be able to run on _MOST_ systems."
echo "Still, it's highly EXPERIEMENTAL, use with CAUTION."
echo ""
echo "Please make sure, that"
echo " - you are using a journaling filesystem (fsck is not used)"
echo " - you have agetty, fgetty or mingetty installed"
echo " - you are runnig Linux 2.6 (sysfs is used)"
echo " - you have udev or static device nodes (you need /dev/tty*)"
echo " - getties will run on tty2-tty7, tty1 is used or logging"
echo ""
echo "****************************************************************************"
echo "******************************* WARNING ************************************"
echo "****************************************************************************"
notosoftwarepatents="Please keep an eye on software patents, they are evil."
read -p "Do you really want to continue? [y/N] " notosoftwarepatents
if [ "$notosoftwarepatents" = "y" -o "$notosoftwarepatents" = "Y" ]; then
echo "Let us try it ..."
else
echo 'Bye bye!'
exit 0
fi
set -e
# Create basic layout
$(dirname $0)/cinit.install.standard-dirs
# Install services:
# - mount root r/w
# - mount /proc
# - mount /sys
# - install getties on tty2-tty7
# - add cleanup for /etc/mtab
# - add loopback device
# - init service + echo
################################### mount #####################################
# mount root read/write
$(dirname $0)/cinit.install.service.mount-root
# - mount /proc
$(dirname $0)/cinit.install.service.mount-proc
# - mount /sys
$(dirname $0)/cinit.install.service.mount-sys
# mount needs everything below it
"$INSTALL_PROG" "$INSTALL_DIRECTORY" "${DESTDIR}/${CINIT_DIR}/mount/$C_NEEDS"
ln -sf "${DESTDIR}/${CINIT_DIR}/mount/root" "${DESTDIR}/${CINIT_DIR}/mount/$C_NEEDS"
ln -sf "${DESTDIR}/${CINIT_DIR}/mount/proc" "${DESTDIR}/${CINIT_DIR}/mount/$C_NEEDS"
ln -sf "${DESTDIR}/${CINIT_DIR}/mount/sys" "${DESTDIR}/${CINIT_DIR}/mount/$C_NEEDS"
################################### getty #####################################
# mount root read/write
# install getties
begin_getty=2
end_getty=7
i=$begin_getty
"$INSTALL_PROG" "$INSTALL_DIRECTORY" "${DESTDIR}/${CINIT_DIR}/getty/$C_WANTS"
while [ "$i" -le "$end_getty" ]; do
$(dirname $0)/cinit.add.getty
ln -sf "${DESTDIR}/${CINIT_DIR}/getty/$i" "${DESTDIR}/${CINIT_DIR}/getty/$C_WANTS"
i=$(($i+1))
done
################################### mtab #####################################
# - add cleanup for /etc/mtab
"$INSTALL_PROG" "$INSTALL_DIRECTORY" "${DESTDIR}/${CINIT_DIR}/local-tuning/$C_NEEDS"
$(dirname $0)/cinit.install.service.cleanup-mtab
ln -sf "${DESTDIR}/${CINIT_DIR}/local-tuning/cleanup-mtab" "${DESTDIR}/${CINIT_DIR}/local-tuning/$C_NEEDS"
################################### lo #####################################
# - add loopback device
"$INSTALL_PROG" "$INSTALL_DIRECTORY" "${DESTDIR}/${CINIT_DIR}/network/$C_NEEDS"
$(dirname $0)/cinit.install.service.network-lo
ln -sf "${DESTDIR}/${CINIT_DIR}/network/lo" "${DESTDIR}/${CINIT_DIR}/network/$C_NEEDS"
# - init service + echo
# init depends on mount, getty -> everything from base-layout
$(dirname $0)/cinit.install.service.init
"$INSTALL_PROG" "$INSTALL_DIRECTORY" "${DESTDIR}/${CINIT_DIR}/${C_INIT}/${C_NEEDS}"
ln -sf "${DESTDIR}/${CINIT_DIR}/local-services/" "${DESTDIR}/${CINIT_DIR}/${C_INIT}/${C_NEEDS}"
ln -sf "${DESTDIR}/${CINIT_DIR}/getty/" "${DESTDIR}/${CINIT_DIR}/${C_INIT}/${C_NEEDS}"
ln -sf "${DESTDIR}/${CINIT_DIR}/local-tuning/" "${DESTDIR}/${CINIT_DIR}/${C_INIT}/${C_NEEDS}"
ln -sf "${DESTDIR}/${CINIT_DIR}/network/" "${DESTDIR}/${CINIT_DIR}/${C_INIT}/${C_NEEDS}"

View file

@ -0,0 +1,4 @@
Make it work with a system.
Same aim as cinit.install.test, but different approach:
This script tries to build the config dynamically.

View file

@ -0,0 +1,20 @@
#!/bin/sh
# Nico Schottelius
# cinit: install basic test config
#
. $(dirname $0)/cinit.read-conf
TARDIR=$(dirname $0)/../samples
case `uname -s` in
Linux)
[ -e /etc/gentoo-release ] && TAR=${TARDIR}/gentoo.tar
[ -e /etc/debian_version ] && TAR=${TARDIR}/debian.tar
[ -e /etc/SuSE-release ] && TAR=${TARDIR}/suse.tar
[ -e /etc/mandrake-release ] && TAR=${TARDIR}/mandrake.tar
[ -e /etc/fedora-release ] && TAR=${TARDIR}/fedora.tar
;;
esac
tar xf ${TAR} -C "$DESTDIR/$PREFIX/$CINIT_DIR"

View file

@ -0,0 +1 @@
See ditz: portability-1

View file

@ -0,0 +1,15 @@
#!/bin/sh
# Nico Schottelius
# 2006-10-23
# cLinux/cinit
. $(dirname $0)/cinit.build-env
set -e
mkdir -p "${BASEDIR}"
mkdir -p "${SERVICES}"
mkdir -p "${SERVICES}/${C_INIT}"
mkdir -p "${CONFIG}"

View file

@ -0,0 +1,34 @@
#!/bin/sh
#
# 2008 Nico Schottelius (nico-cinit-conf at schottelius.org)
#
# This file is part of cinit-conf.
#
# cinit-conf is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cinit-conf is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cinit-conf. If not, see <http://www.gnu.org/licenses/>.
#
bd="${0%/*}"
export bd
echo "Trying to configure cinit for your Debian Linux"
# migrate /etc/fstab to mounts
"$bd/linux/sys-v-init/migrate-fstab.sh"
# migrate / create 6 getties
# migrate network
# migrate services

View file

@ -0,0 +1 @@
Scripts to be used for installing (NOT CONFIGURING) cinit.

View file

@ -0,0 +1,30 @@
#!/bin/sh
# Nico Schottelius
# cinit: install basic setup
# Date: -
#
. $(dirname $0)/cinit.read-conf
"$INSTALL_PROG" sbin/cinit $DESTDIR/$PREFIX/sbin/cinit
"$INSTALL_PROG" sbin/cservice $DESTDIR/$PREFIX/sbin/cservice
"$INSTALL_PROG" sbin/ccontrol $DESTDIR/$PREFIX/sbin/ccontrol
"$INSTALL_PROG" bin/cinit.reboot $DESTDIR/$PREFIX/sbin/cinit.reboot
"$INSTALL_PROG" bin/cinit.shutdown $DESTDIR/$PREFIX/sbin/cinit.shutdown
"$INSTALL_PROG" bin/cinit.wait.for.daemon \
$DESTDIR/$PREFIX/sbin/cinit.wait.for.daemon
# install as /sbin/init, if /sbin/init does not exist
if [ ! -e $DESTDIR/$PREFIX/sbin/init ]; then
ln -s $PREFIX/sbin/cinit $DESTDIR/$PREFIX/sbin/init
fi
# install as /sbin/shutdown, if it does not exist
if [ ! -e $DESTDIR/$PREFIX/sbin/shutdown ]; then
ln -s $PREFIX/sbin/cinit.shutdown $DESTDIR/$PREFIX/sbin/shutdown
fi
# install as /sbin/reboot, if it does not exist
if [ ! -e $DESTDIR/$PREFIX/sbin/reboot ]; then
ln -s $PREFIX/sbin/cinit.reboot $DESTDIR/$PREFIX/sbin/reboot
fi

View file

@ -0,0 +1,14 @@
#!/bin/sh
# Nico Schottelius
# cinit: install needed directories
# Date: - (Last Modified: 2005-08-06)
#
. $(dirname $0)/cinit.read-conf
"$INSTALL_PROG" "$INSTALL_DIRECTORY" "$DESTDIR/$PREFIX/sbin"
"$INSTALL_PROG" "$INSTALL_DIRECTORY" "$DESTDIR/$CINIT_DIR"
"$INSTALL_PROG" "$INSTALL_DIRECTORY" "$DESTDIR/$CINIT_DIR/$C_TMP"
"$INSTALL_PROG" "$INSTALL_DIRECTORY" "$DESTDIR/$CINIT_DIR/$C_INIT"
exit 0

View file

@ -0,0 +1 @@
Only to be used by Nico Schottelius.

View file

@ -0,0 +1,82 @@
#!/bin/sh
# Nico Schottelius
# Build release tar
# Date: Sat Oct 15 21:38:29 CEST 2005
# Last Changed: ls -l
if [ $# -ne 1 ]; then
echo "This is a maintainer-only script to release cinit"
echo $(basename $0): version
exit 1
fi
# paths
D_BASE="/home/users/nico/privat/computer/net/netzseiten/www.nico.schottelius.org/src/software/cinit"
D_DIR=${D_BASE}/archives/
D_SOURCE=${D_BASE}/browse_source/
# versions to check
VERSION_CONF="$(head -n1 $(dirname $0)/../../conf/version | sed 's/^"\(.*\)"$/\1/')"
VERSION_ARGV="$1"
VERSION_GIT="$(git describe)"
VERSION_README=$(grep -q "$VERSION_ARGV" README && echo $VERSION_ARGV)
echo "=> Version commandline: $VERSION_ARGV"
echo "=> Version conf/version: $VERSION_CONF"
echo "=> Version git: $VERSION_GIT"
echo "=> Version README: $VERSION_README"
if [ "$VERSION_ARGV" = "$VERSION_CONF" -a "$VERSION_ARGV" = "$VERSION_GIT" ]; then
echo "=> Version confirmed."
else
echo "*** VERSION MISMATCH ***"
exit 42
fi
# Finally, accept the right version
VERSION="$VERSION_GIT"
NAME="cinit-${VERSION}"
TARNAME="cinit-${VERSION}.tar.bz2"
TARPATH="$D_DIR/$TARNAME"
echo -n "=> Continue to release $NAME? "
read yes
git archive $VERSION --prefix="${NAME}/" --output="${TARPATH}"
( cd "$D_SOURCE" && tar xvf "$TARPATH" )
echo "Please do not forget to update the website..."
################################################################################
# Unused, but interesting
# make sure the examples are not executed anymore
exit 0
# match cinit-$version as directory name
VERSION_DIR="$(cd "$DIR"; pwd -P | sed 's;.*/cinit-;;')"
# grep version string from CHANGES file (often used, obsoleted here)
VERSION_CHANGES="$(head -n1 "$(dirname $0)/../../CHANGES" | sed 's/cinit-\(.*\):.*/\1/')"
# Correct umask 077 results
echo "Correcting paranoid permissions"
ssh "$D_HOST" "find \"$D_SOURCE/$RDIR\" -type f -exec chmod 0644 {} \\;"
ssh "$D_HOST" "find \"$D_SOURCE/$RDIR\" -type d -exec chmod 0755 {} \\;"
ssh "$D_HOST" "cd \"$D_SOURCE\" && rm -f \"$LINK\" && ln -s \"$RDIR\" \"$LINK\""
# Create archive
echo "Creating bzip2 compressed tar"
cd $DDIR
tar cj -X $DIR/.exclude -f "$OUT_NAME" "$RDIR"
chmod 0644 "$OUT_NAME"
# Transfer to a remote host
echo "Transfering to $D_HOST"
scp "$OUT_NAME" "$D_HOST:$D_DIR"
echo "Extracting to $D_SOURCE"
ssh "$D_HOST" "tar xfj $D_DIR/$OUT_NAME -C $D_SOURCE"

View file

@ -0,0 +1,20 @@
#!/bin/sh
# yah - yet another hack
if [ ! "$1" ]; then
echo "HOSTNAME"
exit 23
fi
host="$1"
hier=$(dirname $0)
$hier/compile_test.sh "$host"
if [ $? -ne 0 ]; then
echo "aborting, did not compile on $1"
exit 1
fi
ssh "${host}" './cinit/src/cinit & (sleep 30; kill -9 $(pgrep cinit))'

View file

@ -0,0 +1,24 @@
# just a hack
dir=$(dirname $0)
sys=$(uname -s)
sys_small=$(echo $sys | tr '[A-Z]' '[a-z]')
case $(uname -s) in
NetBSD|OpenBSD)
make=gmake
;;
*)
make=make
;;
esac
cd "${dir}/../../"
echo $sys_small > conf/os
# automatically called by make..
#./bin/cinit.configure.os
cd "src"
$make clean
$make cinit

View file

@ -0,0 +1,14 @@
what=$(dirname $0)/../../
what_real=$(cd "$what" && pwd -P)
dest=~compiler/cinit-test
set -e
sudo rsync -av "${what_real}/" "$dest"
sudo chown -R compiler "$dest"
sudo -u compiler "${dest}/scripts/internal/compile_local.sh"
sudo -u compiler "${dest}/src/cinit" &
sleep 13
sudo -u compiler "${dest}/scripts/internal/stop_cinit.sh"
# exit 0 for make
exit 0

View file

@ -0,0 +1,8 @@
#!/bin/sh
# yah - yet another hack
host="$1"
what=$(dirname $0)/../../
rsync --exclude .git --exclude \*.o -av "${what}" "${host}:cinit"
ssh "${host}" "./cinit/scripts/internal/compile_local.sh"

View file

@ -0,0 +1,18 @@
hier=$(dirname $0)
set -e
${hier}/../cinit.install.standard.dirs
cat > /etc/cinit/svc/init/on << eof
#!/bin/sh
echo test1
sleep 4
echo test2 - \$@
eof
chmod 0755 /etc/cinit/svc/init/on
cat > /etc/cinit/svc/init/on.params << eof
es
scheint
zu
gehen
eof

View file

@ -0,0 +1,24 @@
#!/bin/sh
src="$(dirname $0)/../../"
src_abs=$(cd "$src" && pwd -P)
for commit in $( git log --pretty=short | awk '/^commit/ { print $2 }'); do
set -e
cd "$src_abs"
temp=$(mktemp -d /tmp/cinit.XXXXXXXXXX)
git-archive --format=tar "$commit" | ( cd "$temp"; tar x )
cd "${temp}/src"
set +e
make clean && make cinit && ./cinit
if [ "$?" -eq 0 ]; then
echo "Commit $commit is ok"
exit 0
fi
echo "Broken $commit"
sleep 1
set -e
rm -rf "$temp"
done
exit 1

View file

@ -0,0 +1,67 @@
#!/bin/sh
# Nico Schottelius (nico-linux at schottelius.org)
# indents like kr with a little bit more beauty look
# 13-May-2004
# written for the monotone project, adapted for all my projects
#
# Copying: GPLv3
if [ $# -lt 1 ]; then
echo "$0: <files to indent>"
exit 1
fi
opts=""
opts="${opts} -bap" # --blank-lines-after-procedures
opts="${opts} -bbb" # --blank-lines-before-block-comments
opts="${opts} -bad" # --blank-lines-after-declarations
opts="${opts} -bbo" # --break-before-boolean-operator
opts="${opts} -br" # --braces-on-if-line
opts="${opts} -brs" # --braces-on-struct-decl-line
opts="${opts} -cdb" # --comment-delimiters-on-blank-lines
opts="${opts} -cbi0" # --case-brace-indentation
opts="${opts} -cdw" # --cuddle-do-while
opts="${opts} -ce" # --cuddle-else, see -br
opts="${opts} -ci0" # --continuation-indentation (see -lp)
opts="${opts} -cli3" # --case-indentation
opts="${opts} -cp33" # --else-endif-columnn
opts="${opts} -cs" # --space-after-cast
opts="${opts} -d0" # --line-comments-indentationn
opts="${opts} -di0" # --declaration-indentation
opts="${opts} -fca" # --format-all-comments
opts="${opts} -hnl" # --honour-newlines
opts="${opts} -i3" # --indent-level
opts="${opts} -ip0" # --parameter-indentation
opts="${opts} -l80" # --line-length
opts="${opts} -lc80" # --line-length
opts="${opts} -lp" # --continue-at-parentheses
opts="${opts} -lps" # --leave-preprocessor-space
opts="${opts} -nbc" # --no-blank-lines-after-commas
opts="${opts} -nbfda" # --dont-break-function-decl-args
opts="${opts} -nbfde" # NOT --break-function-decl-args
opts="${opts} -nfc1" # --dont-format-first-column-comments
opts="${opts} -npcs" # --no-space-after-function-call-names
opts="${opts} -nprs" # --no-space-after-parentheses
opts="${opts} -npsl" # --dont-break-procedure-type
opts="${opts} -nsaf" # --no-space-after-for
opts="${opts} -nsai" # --no-space-after-if
opts="${opts} -nsaw" # --no-space-after-while
opts="${opts} -npsl" # --dont-break-procedure-type
opts="${opts} -nut" # --no-tabs
opts="${opts} -nv" # --no-verbosity
opts="${opts} -npro" # --ignore-profile
opts="${opts} -pi0" # --paren-indentationn
opts="${opts} -ppi3" # preprocessor indent
opts="${opts} -sbi0" # --struct-brace-indentation
opts="${opts} -sc" # --start-left-side-of-comments
opts="${opts} -sob" # --swallow-optional-blank-lines
opts="${opts} -ss" # --space-special-semicolon
for file in "$@"; do
indent $opts "$file"
done
# old:
# -ad \
# -ts3 -nut -sc -ce -cdw -cli0 -nbc lp -ppi3 -di1 -c33 -cd33 -ncdb -ci3 -cp33 -cs -d0 -di0 -l75 -nfc1 -nfca -hnl -ip0 -nprs -saf -sai -saw -nsob -nss -npsl "$file"

View file

@ -0,0 +1,57 @@
#!/bin/sh
#
# Nico Schottelius <nico-linux@schottelius.org>
# Date: 21-Aug-2005
# Last Modified: -
#
set -e
[ $# -ne 1 ] && exit 23
SRC=$1
cd "$SRC"
#
# Title heading
#
echo .TH $(cat "meta/name" "meta/man_section" "meta/date")
#
# Name
#
echo .SH NAME
echo $(cat meta/name) - $(cat meta/short_description)
#
# Synopsis
#
echo .SH SYNOPSIS
echo $(cat path) $(cat parameters)
#
# description
#
echo .SH DESCRIPTION
echo $(cat long_description)
#
# availability
#
for section in availability examples "see also" author; do
if [ -f "$section" ]; then
echo .SH $section | tr '[a-z]' '[A-Z]'
cat "$section"
fi
done
#
# files
#
if [ -f files ]; then
echo .SH FILES
cat files | sed 's/\(.*\)/.IP "\1" /'
fi
exit 0

View file

@ -0,0 +1,22 @@
#!/bin/sh
# Nico Schottelius
# 2007-09-03: For testing cinit in qemu
#
emud="${HOME}/emu"
img="${emud}/debian-hd.img"
ddir="${emud}/mount"
loop=/dev/loop1
fsck="/sbin/fsck.jfs"
# my jfs is on the first partition, 512*63 bytes offset
offset="32256"
set -e
set -x
sudo losetup -o "${offset}" "${loop}" "${img}"
sudo "${fsck}" "${loop}"
sudo mount "${loop}" "${ddir}"
sudo umount "${loop}"
sudo losetup -d "${loop}"

View file

@ -0,0 +1,4 @@
#!/bin/sh
# Linux specific, but don't care, I am the only person that should use it
killall -TERM cinit

View file

@ -0,0 +1,11 @@
#!/bin/sh
# Nico Schottelius
# 2007-09-27: Test cmd
#
echo "Testing cmd..."
sudo /sbin/cmd -s /etc/cinit/svc/init
sudo /sbin/cmd -p /etc/cinit/svc/init
sudo /sbin/cmd -v
sudo /sbin/cmd -V

View file

@ -0,0 +1,23 @@
#!/bin/sh
# Nico Schottelius
# Date: 2005-08-08
# cinit-conf
LIBEXEC=$(dirname $0)/../libexec/cinit-conf/
. ${LIBEXEC}/dialog-alias.sh
dialog --calendar "Test" 0 0 18 12 1982
dialog --checklist "Checktest" 0 0 0 item1 on item2 off item3 on
dialog --infobox "Infotext" 0 0
dialog --inputbox "inputbox" 0 0 "vorgegebener text"
dialog --menu "menu" 0 0 0 tag1 item1 tag2 item2 bla blub
dialog --infobox "Infotext" 0 0
dialog --msgbox "Infotext" 0 0
dialog --radiolist "Infotext" 0 0 0 tag1 item1 on tag2 item2 off
dialog --textbox ~/.bashrc 0 0
dialog --yesno "Ja oder nein?" 0 0
dialog --gauge "Checktest" 0 0 10
#dialog --inputmenu "Infotext" 0 0 0 tag1 item1 tag2 item2 bla blub

View file

@ -0,0 +1,40 @@
#!/bin/sh
# Nico Schottelius
# build, install and test cinit in an uml image
set -e
set -x
###################### Params ########################################
# where the cinit source can be found
CINIT=/root/cinit-0.1
# the image you want to put cinit on (I am using gentoo stage3)
IMG=stage3-p4.img
# where to mount the image
MNT=/mnt/uml
# what fsck to use
FSCK=fsck.jfs
# the uml-linux-kernel
LINUX=./linux-2.6.11.11
# parameters to kernel - should not needed to be changed
LINUX_PARAM="ubd0=$IMG umid=cinit$$ init=/sbin/cinit"
######################################################################
HIER=$(pwd)
"$FSCK" "$IMG"
mount "$IMG" "$MNT" -o loop
echo "$MNT" > "$CINIT/conf/destdir"
make -C "$CINIT" clean all install
umount "$MNT"
"$FSCK" "$IMG"
"$LINUX" $LINUX_PARAM
# restore console, if broken
#reset

View file

@ -0,0 +1,12 @@
#!/bin/sh
# yah
hosts="penrose.bsdprojects.net jiffies.forkbomb.ch ddna044.netstream.ch"
set -e
for host in $hosts; do
echo "$1 on $host"
"$1" "$host" | sed "s/^/${host}: /"
echo "==> Finished $host"
done

View file

@ -0,0 +1 @@
valgrind -v --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --leak-resolution=high ./cinit

View file

@ -0,0 +1,18 @@
#!/bin/sh
# Nico Schottelius
# 2006-12-08
# Report compile success
#
echo "cinit compile success report"
echo "----------------------------"
"$(dirname $0)/cinit.mkheader"
echo "----------------------------"
uname -a
echo "----------------------------"
. "$(dirname $0)/cinit.read-conf"
echo '$CC'
"$CC" -v
echo "----------------------------"
echo -n "Size: "
ls -l "$(dirname $0)/../src/cinit"

View file

@ -0,0 +1,207 @@
#!/bin/sh
# Nico Schottelius (nico-cinit /at/ schottelius.org)
# 2007-05-21
# Behave as being shutdown from Linux' sysvinit
# Always needed variables / functions
_0_short=${0##*/}
_o_seperator=":"
_oecho_seperator=":"
_eecho_seperator=">"
# ok-exit/echo
_oecho()
{
echo "${_0_short}${_oecho_seperator}" "$@"
}
_oexit()
{
_oecho "$@"
exit 0
}
# error-exit/echo
_eecho()
{
echo "${_0_short}${_oecho_seperator}" "$@" >&2
}
_eexit()
{
_eecho "$@"
exit 1
}
# Program specific variables
time_t=0 # -t sec
warn_only_k=0 # -k
reboot_r=0 # -r
halt_h=0 # -h
poweroff_P=0 # -P
cancel_c=0 # -c
time=-1 # [time]
message="" # [warning-message]
cmd="" # what to execute internally
pidfile="/var/run/cinit.shutdown"
pid=""
runs=""
version="0.1"
version_date="2007-10-30"
message_intro="The system is going down for"
message_reboot="reboot"
message_halt="halt"
message_poweroff="poweroff"
# unimplemented: -a, -H, -f, -F
# deprecated and thus not implemented: -n
# traping signals
trap_signals()
{
_oexit "Aborted shutdown"
}
# all the functions
usage()
{
cat << cinit_usage
*** cinit linux-sysvinit shutdown wrapper (Version ${version} ${version_date}) ***
Usage shutdown [-akrhHPfnc] [-t secs] time [warning message]
-a: use /etc/shutdown.allow
-k: don't really shutdown, only warn.
-r: reboot after shutdown.
-h: halt after shutdown.
-P: halt action is to turn off power.
-H: halt action is to just halt.
-f: do a 'fast' reboot (skip fsck).
-F: Force fsck on reboot.
-n: do not go through "init" but go down real fast.
-c: cancel a running shutdown.
-t secs: delay between warning and kill signal.
** the "time" argument is mandatory! (try "now") **
You can also call "cinit.{halt|reboot|poweroff}" directly
(instead of using this wrapper).
cinit_usage
exit 0
}
warn()
{
( echo ""; echo "$@"; echo "" ) | wall
( echo ""; echo "$@"; echo "" )
}
if [ "$#" -lt 1 ]; then
usage
fi
# getopt!
while [ "$#" -ge 1 ]; do
arg="$1"; shift
case "${arg}" in
-a|-F|-f|-n)
_oexit "Sorry, ${arg} is not implemented."
;;
-t)
if [ "$#" -lt 1 ]; then
_eexit "-t needs the time argument"
fi
time_t="$1"; shift
;;
-k)
warn_only_k=1
cmd=true
;;
-r)
reboot_r=1
cmd=cinit.reboot
message_what="${message_reboot}"
;;
-h|-H)
halt_h=1
cmd=cinit.halt
message_what="${message_halt}"
;;
-P)
poweroff_P=1
cmd=cinit.poweroff
message_what="${message_poweroff}"
;;
-c)
cancel_c=1
;;
*)
# time unset?
if [ "${time}" = -1 ]; then
time="${arg}"
[ "${time}" = "now" ] && time=0
elif [ -z "${message}" ]; then
message="${arg}"
else
_eexit "Already specified time and message"
fi
;;
esac
done
if [ -f "${pidfile}" ]; then
pid=$(cat "${pidfile}")
runs=$(kill -CONT "${pid}" >/dev/null 2>&1 && echo yes)
fi
# do cancel or abort or locking
if [ "${cancel_c}" -eq 1 ]; then
if [ "${runs}" ]; then
kill -TERM "${pid}"
_oexit "Terminated running shutdown at \"${pid}\"."
else
_eexit "Cannot abort shutdown, not running."
fi
fi
if [ -z "${time}" ]; then
usage
fi
if [ -z "${cmd}" ]; then
_eexit "You need to specify one of -h, -P, -H, -r."
fi
# add lock
if [ "${pid}" ]; then
if [ "${runs}" ]; then
_eexit "Shutdown already running."
else
_oecho "Overwriting stale pidfile"
fi
fi
echo $$ > "${pidfile}"
if [ "${message}" ]; then
warn "${message}"
fi
# signals to abort on
trap trap_signals INT HUP TERM
while [ "${time}" -gt 0 ]; do
warn "${message_intro} ${message_what} in ${time} minute(s)."
sleep 60
time=$((${time}-1))
done
warn "${message_intro} ${message_what} now."
"${cmd}"