2013-07-13 17:19:22 +01:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
|
|
|
|
|
|
|
|
. /etc/config
|
|
|
|
|
|
|
|
if [ -z "$cfg_tmpfs_size" ]; then
|
|
|
|
cfg_tmpfs_size='2097152'
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$cfg_min_free_kbytes" ]; then
|
|
|
|
cfg_min_free_kbytes='8192'
|
|
|
|
fi
|
|
|
|
|
|
|
|
sysinit()
|
|
|
|
{
|
2015-02-08 15:50:41 +00:00
|
|
|
if ! [ -c /dev/null ]; then
|
|
|
|
mount -t devtmpfs devtmpfs /dev
|
|
|
|
fi
|
|
|
|
|
2013-07-13 17:19:22 +01:00
|
|
|
if [ -f /.reboot ]; then
|
|
|
|
mount -t proc proc /proc
|
|
|
|
mount -o remount,rw /
|
|
|
|
rm /.reboot
|
|
|
|
mount -o remount,ro /
|
|
|
|
reboot
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2015-02-08 15:50:41 +00:00
|
|
|
# Mount pseudo-filesystems.
|
2013-07-13 17:19:22 +01:00
|
|
|
mount -t sysfs sysfs /sys &&
|
|
|
|
mount -t proc proc /proc &&
|
|
|
|
mkdir /dev/shm /dev/pts &&
|
|
|
|
mount -t tmpfs -o size="$cfg_tmpfs_size" tmpfs /dev/shm &&
|
|
|
|
mount -t devpts devpts /dev/pts &&
|
|
|
|
|
2015-02-08 15:50:41 +00:00
|
|
|
# Register mdev as hotplug event handler.
|
2013-07-13 17:19:22 +01:00
|
|
|
echo >/dev/mdev.seq &&
|
|
|
|
echo /sbin/mdev > /proc/sys/kernel/hotplug &&
|
|
|
|
|
2015-02-08 15:50:41 +00:00
|
|
|
# Update ld cache, populate /dev.
|
2013-07-13 17:19:22 +01:00
|
|
|
/sbin/mdev -s &&
|
|
|
|
|
2015-02-08 15:50:41 +00:00
|
|
|
# Set minimum free kbytes.
|
2013-07-13 17:19:22 +01:00
|
|
|
echo "$cfg_min_free_kbytes" > /proc/sys/vm/min_free_kbytes &&
|
|
|
|
|
2015-02-08 15:50:41 +00:00
|
|
|
# Set hostname.
|
2013-07-13 17:19:22 +01:00
|
|
|
hostname "$cfg_hostname" &&
|
|
|
|
|
2015-02-08 15:50:41 +00:00
|
|
|
# Loopback device.
|
2013-07-13 17:19:22 +01:00
|
|
|
ifconfig lo 127.0.0.1 netmask 255.0.0.0 up &&
|
|
|
|
|
2015-02-08 15:50:41 +00:00
|
|
|
# Load modules.
|
2013-07-13 17:19:22 +01:00
|
|
|
modprobe -a $cfg_modules $cfg_modules1
|
|
|
|
|
2015-02-08 15:50:41 +00:00
|
|
|
# Start services.
|
2013-07-13 17:19:22 +01:00
|
|
|
for service in $cfg_services0 $cfg_services1 $cfg_services2; do
|
|
|
|
. /etc/rc.d/$service
|
|
|
|
start
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
syshalt()
|
|
|
|
{
|
|
|
|
if [ -f /.reboot ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
srv=''
|
|
|
|
|
|
|
|
for s in $cfg_services0 $cfg_services1 $cfg_services2; do
|
|
|
|
srv="$s $srv"
|
|
|
|
done
|
|
|
|
|
|
|
|
for s in $srv; do
|
|
|
|
. /etc/rc.d/$s
|
|
|
|
stop
|
|
|
|
done
|
|
|
|
|
|
|
|
umount -r /dev/pts /dev/shm /sys / /proc
|
|
|
|
}
|
|
|
|
|
|
|
|
service()
|
|
|
|
{
|
|
|
|
. /etc/rc.d/"$1"
|
|
|
|
|
|
|
|
case "$2" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
stop
|
|
|
|
sleep 4
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 <service> [start,stop,restart]"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
sysinit)
|
|
|
|
sysinit
|
|
|
|
;;
|
|
|
|
syshalt)
|
|
|
|
syshalt
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
service "$1" "$2"
|
|
|
|
;;
|
|
|
|
esac
|