Initial commit

This commit is contained in:
lw-everestlinux
2022-09-13 17:52:14 -04:00
commit 76ce8eab95
8 changed files with 328 additions and 0 deletions

21
clfs/rc.d/init.d/functions Executable file
View File

@@ -0,0 +1,21 @@
# Common Routines
#
# Default Path for scripts
#
PATH=/bin:/sbin:/usr/bin:/usr/sbin
# Check status and print
# OK or FAIL
#
check_status()
{
local ERR=$?
echo -en "\\033[65G"
if [ $ERR = 0 ]; then
echo -en "\\033[1;32mOK"
else
echo -en "\\033[1;31mFAIL"
fi
echo -e "\\033[0;39m"
}

25
clfs/rc.d/init.d/netplugd Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/ash
# Netplugd Startup Script
. /etc/rc.d/init.d/functions
case "$1" in
start)
echo -n "Starting netplugd: "
netplugd
check_status
;;
stop)
echo -n "Stopping netplugd: "
killall netplugd
check_status
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac

54
clfs/rc.d/init.d/sshd Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/ash
#
# DropBear SSH
. /etc/rc.d/init.d/functions
DSSKEY=/etc/dropbear/dropbear_dss_host_key
RSAKEY=/etc/dropbear/dropbear_rsa_host_key
PIDFILE=/var/run/dropbear.pid
case "$1" in
start)
if [ ! -r "$DSSKEY" ]; then
echo -n "Generating DSS host key: "
dropbearkey -t dss -f "$DSSKEY" >/dev/null 2>&1
check_status
fi
if [ ! -r "$RSAKEY" ]; then
echo -n "Generating RSA host key: "
dropbearkey -t rsa -f "$RSAKEY" >/dev/null 2>&1
check_status
fi
if [ -r "$PIDFILE" ]; then
echo "Service dropbear already running."
else
echo -n "Starting SSH server: "
dropbear
check_status
fi
;;
stop)
if [ -r "$PIDFILE" ]; then
echo -n "Stopping dropbear SSH server: "
kill `cat "$PIDFILE"`
check_status
else
echo "Service dropbear not running."
fi
;;
restart)
$0 stop
$0 start
;;
status)
if [ -r "$PIDFILE" ]; then
echo "Service dropbear running (PID $(cat "$PIDFILE"))."
else
echo "Service dropbear not running."
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac

34
clfs/rc.d/init.d/syslog Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/ash
# Syslog Startup Script
#
. /etc/rc.d/init.d/functions
SYSLOG_ROTATE_SIZE=65536
case "$1" in
start)
echo -n "Starting syslogd: "
syslogd -m 0 -s $SYSLOG_ROTATE_SIZE -L
check_status
echo -n "Starting klogd: "
klogd
check_status
;;
stop)
echo -n "Stopping klogd: "
killall klogd
check_status
echo -n "Stopping syslogd: "
killall syslogd
check_status
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac

42
clfs/rc.d/shutdown Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/ash
# System Shutdown Script
#
. /etc/rc.d/init.d/functions
echo "[ /\ ] Stopping Everest Linux"
echo
echo "System is going down for reboot or halt now."
echo
echo "Starting stop scripts."
for i in /etc/rc.d/stop/*
do
if [ -x $i ]; then
$i stop
fi
done
if [ -x /sbin/hwclock ] && [ -e /dev/rtc0 ]; then
echo -n "Syncing system clock to hardware clock: "
hwclock --systohc --utc
check_status
fi
if [ -x /sbin/swapoff ] && [ -s /etc/fstab ]; then
echo -n "Disabling swap space: "
swapoff -a
check_status
fi
echo -n "Syncing all filesystems: "
sync
check_status
echo -n "Unmounting all filesystems: "
umount -a -r

98
clfs/rc.d/startup Executable file
View File

@@ -0,0 +1,98 @@
#!/bin/ash
# System Startup Script
#
. /etc/rc.d/init.d/functions
echo "[ /\ ] Starting Everest Linux"
echo "Mounting filesystems: "
/bin/mount -t proc none /proc
/bin/mount -t sysfs none /sys
/bin/mount -t tmpfs /tmp /tmp
/bin/mkdir /dev/pts
/bin/mkdir /dev/shm
/bin/echo "/sbin/mdev" > /proc/sys/kernel/hotplug
echo -n "Starting mdev: "
/sbin/mdev -s
check_status
echo -n "Mounting devpts: "
/bin/mount -t devpts none /dev/pts
check_status
echo -n "Mounting shared memory: "
/bin/mount -t tmpfs none /dev/shm
check_status
if [ -x /sbin/hwclock ] && [ -e /dev/rtc0 ]; then
echo -n "Setting system clock: "
hwclock --hctosys --utc
check_status
fi
if [ -x /sbin/fsck ]; then
echo "Starting fsck for local filesystems."
fsck -A -C -R -T -t nonfs,nosmbfs
if [ "$?" -gt 2 ]; then
echo "WARNING: Errors found while checking filesystems."
echo "You can login as root now, the system will reboot after logout."
sulogin
reboot
elif [ "$?" = "2" ]; then
echo "NOTICE: System needs to be rebooted now."
sleep 1
reboot
else
echo -n "Checking local filesystems: "
check_status
fi
fi
if [ -x /sbin/swapon ]; then
echo -n "Enabling swap space: "
swapon -a
check_status
fi
echo -n "Remounting root rw: "
mount -o remount,rw /
check_status
echo -n "Linking /var/tmp and /tmp: "
ln -s ../tmp /var/tmp
check_status
echo -n "Setting hostname: "
hostname -F /etc/HOSTNAME
check_status
echo -n "Cleaning up system: "
rm -rf /var/run/*
> /var/run/utmp
touch /var/log/wtmp
touch /var/log/messages
chmod 0664 /var/run/utmp
chmod 0664 /var/log/wtmp
chmod 0660 /var/log/messages
rm -rf /tmp/*
check_status
echo -n "Setting up interface lo: "
ifconfig lo up 127.0.0.1
check_status
echo "Running start scripts."
for i in /etc/rc.d/start/*
do
if [ -x $i ]; then
$i start
fi
done
exit 0