import cinit from unix.schottelius.org
Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
This commit is contained in:
parent
3729fc68eb
commit
423ba10303
13396 changed files with 269468 additions and 0 deletions
|
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# cinit: create dependency: service a needs or wants service b
|
||||
|
||||
set -e
|
||||
|
||||
# init variables
|
||||
. $(dirname $0)/cinit.read-conf
|
||||
|
||||
BASEDIR=$DESTDIR/$CINIT_DIR
|
||||
|
||||
if [ $# -ne 3 ]; then
|
||||
echo "`basename $0`: service_A [wants|needs] service_B"
|
||||
echo ""
|
||||
echo " Service A needs or needs Service B."
|
||||
echo " Use relative paths, not absolute."
|
||||
echo " You must specify whether to use wants or needs."
|
||||
echo ""
|
||||
exit 23
|
||||
fi
|
||||
|
||||
SVC_A=$1
|
||||
DEP=$2
|
||||
SVC_B=$3
|
||||
|
||||
case $DEP in
|
||||
wants) DEP=$C_WANTS ;;
|
||||
needs) DEP=$C_NEEDS ;;
|
||||
*) echo "Did not I say \"want\" or \"need\"? You _must_ use those terms."
|
||||
esac
|
||||
|
||||
# FIXME: could some PLEASE simply that?
|
||||
SLASHES=$(echo $SVC_A | sed -e 's,/$,,' -e 's,[^/],,g' -e 's,/,../,g' -e 's,^,../../,')
|
||||
DEST_NAME=$(echo $SVC_B | sed -e 's,/$,,' -e 's,/,-,g')
|
||||
|
||||
SOURCE="${SLASHES}${SVC_B}"
|
||||
DEST="${BASEDIR}/${SVC_A}/${DEP}/${DEST_NAME}"
|
||||
|
||||
echo -n "Linking $SOURCE to $DEST ... "
|
||||
ln -sf "$SOURCE" "$DEST"
|
||||
echo "finished."
|
||||
66
software/cinit/browse_source/cinit-0.0.7/bin/cinit.add.getty
Normal file
66
software/cinit/browse_source/cinit-0.0.7/bin/cinit.add.getty
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# cinit: create gettys
|
||||
# 2005-05-24
|
||||
|
||||
set -e
|
||||
|
||||
# init variables
|
||||
. $(dirname $0)/cinit.read-conf
|
||||
|
||||
BASEDIR=$DESTDIR/$CINIT_DIR/$GETTY_DIR
|
||||
LAST_NUMBER=$(cd $BASEDIR && ls | awk '/^((0[xX])[0-9a-fA-F]+)|([0-9]+)$/ { print }' | tail -n 1)
|
||||
NUMBER=$(echo $LAST_NUMBER + 1 | bc)
|
||||
|
||||
[ ! "$NUMBER" ] && NUMBER=1
|
||||
|
||||
DDIR=$BASEDIR/$NUMBER
|
||||
|
||||
echo "Creating getty number $NUMBER in $DDIR ..."
|
||||
|
||||
if [ "$USE_THIS_GETTY" ]; then
|
||||
GETTYS="$USE_THIS_GETTY"
|
||||
else
|
||||
GETTYS=`echo /sbin/*getty*`
|
||||
fi
|
||||
|
||||
for getty in $GETTYS; do
|
||||
case $getty in
|
||||
*/fgetty|*/mingetty)
|
||||
mygetty=$getty
|
||||
params="/dev/tty${NUMBER}"
|
||||
;;
|
||||
*/agetty|*/getty)
|
||||
mygetty=$getty
|
||||
params="38400 tty${NUMBER} linux"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown Getty type $getty"
|
||||
echo "Please report standard parameters to me."
|
||||
esac
|
||||
|
||||
[ "$mygetty" ] && break
|
||||
done
|
||||
|
||||
read -p "Getty to use [$mygetty]: " rgetty
|
||||
read -p "Parameters to pass [$params]: " rparams
|
||||
|
||||
[ "$rgetty" ] && mygetty=$rgetty
|
||||
[ "$rparams" ] && params=$rparams
|
||||
|
||||
if [ ! "$mygetty" -o ! "$params" ]; then
|
||||
echo "No useable getty and parameters found, exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -n "Putting $mygetty $params into $DDIR ... "
|
||||
mkdir -p "$DDIR"
|
||||
ln -s $mygetty "$DDIR/$C_ON"
|
||||
|
||||
for param in $params; do
|
||||
echo $param >> "$DDIR/${C_ON}${C_PARAMS}"
|
||||
done
|
||||
|
||||
touch "$DDIR/$C_RESPAWN"
|
||||
|
||||
echo "finished."
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# cinit: create templates
|
||||
# 2005-05-24
|
||||
|
||||
set -e
|
||||
|
||||
# init variables
|
||||
. $(dirname $0)/cinit.read-conf
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "`basename $0`: service-name(s)"
|
||||
echo " I do create templates for your services"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASEDIR=$DESTDIR/$CINIT_DIR
|
||||
BASEDIR=./testcinit
|
||||
|
||||
|
||||
for svc in $@; do
|
||||
INSTDIR=${BASEDIR}/${svc}
|
||||
if [ -e "$INSTDIR" ]; then
|
||||
echo "$svc already exists, skipping."
|
||||
continue
|
||||
fi
|
||||
echo -n "Creating $svc ..."
|
||||
# install creates needed parent directories
|
||||
"$INSTALL_PROG" "$INSTALL_DIRECTORY" "${INSTDIR}/${C_NEEDS}"
|
||||
echo "The services this services really needs (it will not start if one failed to start)." > "${INSTDIR}/${C_NEEDS}/README"
|
||||
"$INSTALL_PROG" "$INSTALL_DIRECTORY" "${INSTDIR}/${C_WANTS}"
|
||||
echo "The services this services wants (it will start if one or more fail)." > "${INSTDIR}/${C_WANTS}/README"
|
||||
|
||||
echo '#!/bin/sh' > "${INSTDIR}/${C_ON}"
|
||||
echo "echo This should be a link to an executable or a script" >> "${INSTDIR}/${C_ON}"
|
||||
chmod 0700 "${INSTDIR}/${C_ON}"
|
||||
echo "One paramater on each line." > "${INSTDIR}/${C_ON}${C_PARAMS}"
|
||||
echo "Delete me, if there are no paramaters." > "${INSTDIR}/${C_ON}${C_PARAMS}"
|
||||
echo "Environtment: varx=valuex, one variable on each line." > "${INSTDIR}/${C_ON}${C_ENV}"
|
||||
echo "Delete me, if you do not want to set any variables." > "${INSTDIR}/${C_ON}${C_ENV}"
|
||||
echo "finished."
|
||||
done
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# cinit: read configuration into variables
|
||||
# 2005-05-24
|
||||
|
||||
# try environment first
|
||||
if [ "$CINIT_DIR" ]; then
|
||||
CONFDIR=$CINIT_DIR
|
||||
elif [ -d $(dirname $0)/../conf/ ]; then
|
||||
CONFDIR=$(dirname $0)/../conf/
|
||||
elif [ -d /etc/cinit ]; then
|
||||
CONFDIR=/etc/cinit
|
||||
else
|
||||
echo Did not find cinit configuration 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo $CONFDIR
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# cinit: install basic setup
|
||||
#
|
||||
|
||||
|
||||
. $(dirname $0)/cinit.read-conf
|
||||
|
||||
"$INSTALL_PROG" sbin/cinit $DESTDIR/$PREFIX/sbin/cinit
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# cinit: install basic setup
|
||||
#
|
||||
|
||||
|
||||
. $(dirname $0)/cinit.read-conf
|
||||
|
||||
echo "*** > Currently missing, sorry."
|
||||
|
||||
exit 1
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# cinit: install configuration directory
|
||||
#
|
||||
|
||||
. $(dirname $0)/cinit.read-conf
|
||||
|
||||
"$INSTALL_PROG" "$INSTALL_DIRECTORY" $DESTDIR/$PREFIX/$CINIT_DIR
|
||||
|
|
@ -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"
|
||||
20
software/cinit/browse_source/cinit-0.0.7/bin/cinit.mkheader
Normal file
20
software/cinit/browse_source/cinit-0.0.7/bin/cinit.mkheader
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/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 I didn't see an easier way
|
||||
numeric=$(echo $value | awk '/^((0[xX])[0-9a-fA-F]+)|([0-9]+)$/ { print }')
|
||||
|
||||
[ "$numeric" ] || value="\"$value\""
|
||||
|
||||
echo "#define" "$NAME" "$value"
|
||||
done
|
||||
13
software/cinit/browse_source/cinit-0.0.7/bin/cinit.read-conf
Normal file
13
software/cinit/browse_source/cinit-0.0.7/bin/cinit.read-conf
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# cinit: read configuration into variables
|
||||
#
|
||||
|
||||
CONFS=$($(dirname $0)/cinit.get-confdir)/../conf/*
|
||||
|
||||
for conf in $CONFS; do
|
||||
NAME="$(basename $conf | tr a-z A-Z)"
|
||||
eval $NAME="$(head -n 1 $conf)"
|
||||
eval export $NAME
|
||||
# eval echo $NAME = \$$NAME
|
||||
done
|
||||
18
software/cinit/browse_source/cinit-0.0.7/bin/cinit.reboot
Normal file
18
software/cinit/browse_source/cinit-0.0.7/bin/cinit.reboot
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# reboot system
|
||||
# 2005-06-09
|
||||
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "`basename $0`"
|
||||
echo " Reboot the system:"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# -ne 0 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
kill -HUP 1
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# cinit: create gettys
|
||||
|
||||
# init variables
|
||||
. $(dirname $0)/cinit.read-conf
|
||||
|
||||
BASEDIR=$DESTDIR/$CINIT_DIR/$GETTY_DIR
|
||||
NUMBER=$(cd $BASEDIR && ls | awk '/^((0[xX])[0-9a-fA-F]+)|([0-9]+)$/ { print }' | tail -n 1)
|
||||
|
||||
|
||||
[ ! "$NUMBER" ] && exit 1
|
||||
|
||||
DDIR=$BASEDIR/$NUMBER
|
||||
|
||||
echo "Removing getty number $NUMBER located in $DDIR ..."
|
||||
read -p "Are you sure [y/N]? " yes
|
||||
|
||||
if [ "$yes" = "y" ]; then
|
||||
rm -r $DDIR
|
||||
else
|
||||
echo "Aborted."
|
||||
fi
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# cinit: switch respawning off
|
||||
# 2005-05-24
|
||||
|
||||
set -e
|
||||
|
||||
# init variables
|
||||
. $(dirname $0)/cinit.read-conf
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "`basename $0`: service-name(s)"
|
||||
echo " The respawning mark will be removed from services"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASEDIR=$DESTDIR/$CINIT_DIR
|
||||
|
||||
for svc in $@; do
|
||||
echo -n "Removing respawning mark from $svc ..."
|
||||
rm -f "${BASEDIR}/${svc}/${C_RESPAWN}"
|
||||
echo "finished."
|
||||
done
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# cinit: switch respawning on
|
||||
# 2005-05-24
|
||||
|
||||
set -e
|
||||
|
||||
# init variables
|
||||
. $(dirname $0)/cinit.read-conf
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "`basename $0`: service-name(s)"
|
||||
echo " Services will be marked respawning"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASEDIR=$DESTDIR/$CINIT_DIR
|
||||
|
||||
for svc in $@; do
|
||||
echo -n "Marking $svc respawning ..."
|
||||
touch "${BASEDIR}/${svc}/${C_RESPAWN}"
|
||||
echo "finished."
|
||||
done
|
||||
|
||||
27
software/cinit/browse_source/cinit-0.0.7/bin/cinit.shutdown
Normal file
27
software/cinit/browse_source/cinit-0.0.7/bin/cinit.shutdown
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# shutdown system
|
||||
# 2005-05-24
|
||||
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "`basename $0` -[ohr]"
|
||||
echo " Shutdown the system:"
|
||||
echo " -o|--off: Power off"
|
||||
echo " -h|--halt: Halt"
|
||||
echo " -r|--reboot: Reboot"
|
||||
echo " "
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
-r|--reboot) kill -HUP 1 ;;
|
||||
-o|--off) kill -TERM 1 ;;
|
||||
-h|--halt) kill -USR1 1 ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# cinit: create templates
|
||||
# 2005-05-24
|
||||
|
||||
set -e
|
||||
|
||||
# init variables
|
||||
. $(dirname $0)/cinit.read-conf
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "`basename $0`: service-name (including category)"
|
||||
echo " I do create a service for you"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASEDIR=$DESTDIR/$CINIT_DIR
|
||||
|
||||
# read input (from gentoo-bug.sh, http://linux.schottelius.org/scripts/#gentoo-bug
|
||||
reread()
|
||||
{
|
||||
_tmp=""
|
||||
name="$1"
|
||||
|
||||
while [ ! "$_tmp" ]; do
|
||||
read -p "$1 [$_tmp]: " _tmp
|
||||
done
|
||||
|
||||
echo $_tmp
|
||||
}
|
||||
|
||||
|
||||
for svc in $@; do
|
||||
echo -n "Creating $svc ..."
|
||||
mkdir -p "${BASEDIR}/${svc}"
|
||||
cd ${BASEDIR}/${svc}
|
||||
mkdir -p "${C_WANTS}" "${C_NEEDS}"
|
||||
echo "finished."
|
||||
done
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue