This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
lsts_glued/rules/filesystem/fs/sbin/services

126 lines
2.1 KiB
Plaintext
Raw Normal View History

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()
{
echo ""
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
# Mount pseudo-filesystems.
2013-07-13 17:19:22 +01:00
mount -t sysfs sysfs /sys &&
mount -t proc proc /proc &&
mkdir -p /dev/shm /dev/pts &&
2013-07-13 17:19:22 +01:00
mount -t tmpfs -o size="$cfg_tmpfs_size" tmpfs /dev/shm &&
mount -t devpts devpts /dev/pts &&
# 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 &&
# Update ld cache, populate /dev.
2013-07-13 17:19:22 +01:00
/sbin/mdev -s &&
# Set minimum free kbytes.
2013-07-13 17:19:22 +01:00
echo "$cfg_min_free_kbytes" > /proc/sys/vm/min_free_kbytes &&
# Set hostname.
2013-07-13 17:19:22 +01:00
hostname "$cfg_hostname" &&
# Loopback device.
2013-07-13 17:19:22 +01:00
ifconfig lo 127.0.0.1 netmask 255.0.0.0 up &&
# Load modules.
2013-07-13 17:19:22 +01:00
modprobe -a $cfg_modules $cfg_modules1
# 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
echo ""
2013-07-13 17:19:22 +01:00
}
syshalt()
{
echo ""
2013-07-13 17:19:22 +01:00
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 > /dev/null 2>&1
echo ""
2013-07-13 17:19:22 +01:00
}
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