Browse Source

- move fstab init script away from skel-root

master
vanhofen 5 years ago
parent
commit
649c133852
  1. 2
      make/target-rootfs.mk
  2. 6
      make/target-scripts.mk
  3. 195
      skel-root/armbox/hd51/etc/init.d/fstab
  4. 195
      skel-root/coolstream/hd1/etc/init.d/fstab
  5. 195
      skel-root/coolstream/hd2/etc/init.d/fstab
  6. 0
      skel-root/general/scripts/fstab.init

2
make/target-rootfs.mk

@ -50,8 +50,6 @@ endif
$(CD) $(TARGET_DIR)/etc; \
ln -sf /proc/mounts mtab
$(CD) $(TARGET_DIR)/etc/init.d; \
ln -sf fstab K99fstab; \
ln -sf fstab S01fstab; \
ln -sf networking K99networking
ifeq ($(BOXSERIES), hd2)
$(CD) $(TARGET_DIR)/etc; \

6
make/target-scripts.mk

@ -11,6 +11,7 @@ init-scripts: \
$(TARGET_DIR)/etc/init.d/coredump \
$(TARGET_DIR)/etc/init.d/crond \
$(TARGET_DIR)/etc/init.d/custom-poweroff \
$(TARGET_DIR)/etc/init.d/fstab \
$(TARGET_DIR)/etc/init.d/hostname \
$(TARGET_DIR)/etc/init.d/inetd \
$(TARGET_DIR)/etc/init.d/swap \
@ -45,6 +46,11 @@ ifeq ($(BOXTYPE), coolstream)
$(INSTALL_EXEC) -D $(IMAGEFILES)/scripts/custom-poweroff.init $@
endif
$(TARGET_DIR)/etc/init.d/fstab:
$(INSTALL_EXEC) -D $(IMAGEFILES)/scripts/fstab.init $@
ln -sf fstab $(TARGET_DIR)/etc/init.d/S01fstab
ln -sf fstab $(TARGET_DIR)/etc/init.d/K99fstab
$(TARGET_DIR)/etc/init.d/hostname:
$(INSTALL_EXEC) -D $(IMAGEFILES)/scripts/hostname.init $@

195
skel-root/armbox/hd51/etc/init.d/fstab

@ -1,195 +0,0 @@
#!/bin/sh
. /etc/init.d/globals
SRVFLAG=/var/etc/.srv
MTAB=/etc/mtab
FSTAB=/etc/fstab
if [ -e /var/etc/fstab ]; then
FSTAB=/var/etc/fstab
fi
is_mount()
{
RET=1
test -f $MTAB || return $RET
while read _DEV _MTPT _FSTYPE _OPTS _REST
do
case "$_FSTYPE" in
"tmpfs") continue ;;
esac
case "$1" in
"$_DEV"|"$_MTPT") RET=0; break ;;
esac
done < $MTAB
return $RET
}
mount_local()
{
SHOWINFO "mount all local stuff from $FSTAB"
test -f $FSTAB || return
while read DEV MTPT FSTYPE OPTS REST
do
case "$DEV" in
""|\#*)
continue
;;
esac
case "$OPTS" in
noauto|*,noauto|noauto,*|*,noauto,*)
continue
;;
esac
case "$FSTYPE" in
swap)
#SHOWINFO "enable all swaps from $FSTAB"
#swapon -a
SHOWINFO "ignoring all swaps from $FSTAB"
continue
;;
nfs|cifs)
continue
;;
*)
test -d $MTPT || mkdir -p $MTPT;
SHOWINFO "trying to mount $DEV to $MTPT"
if OUT=$(mount $MTPT 2>&1 >/dev/null)
then
RET=$?
LOGINFO "mount: $MTPT - success ($RET)"
else
RET=$?
LOGWARN "mount: $MTPT - failed ($RET)"
echo "$OUT" | LOGWARN
fi
;;
esac
done < $FSTAB
}
mount_netfs()
{
SHOWINFO "mount all netfs stuff from $FSTAB"
test -f $FSTAB || return
rm -f $SRVFLAG
while read DEV MTPT FSTYPE OPTS REST
do
case "$DEV" in
""|\#*)
continue
;;
esac
case "$OPTS" in
noauto|*,noauto|noauto,*|*,noauto,*)
continue
;;
esac
case "$FSTYPE" in
nfs|cifs)
if ! is_mount $MTPT; then
test -d $MTPT || mkdir -p $MTPT;
SHOWINFO "trying to mount $DEV to $MTPT"
(
try=51
while(true); do
if OUT=$(mount $MTPT 2>&1 >/dev/null); then
RET=$?
LOGINFO "mount: $MTPT - success ($RET)"
test -e $SRVFLAG || touch $SRVFLAG
break
else
RET=$?
LOGWARN "mount: $MTPT - failed ($RET)"
echo "$OUT" | LOGWARN
if [ ${try:1:1} -eq ${try:0:1} ]; then
LOGWARN "mount: $MTPT - cancel!"
break
fi
try=$((try+1))
LOGWARN "mount: $MTPT - try ${try:1:1} in 30 seconds ..."
sleep 30
fi
done
) &
else
SHOWINFO "already mounted $MTPT"
test -e $SRVFLAG || touch $SRVFLAG
fi
;;
*)
continue
;;
esac
done < $FSTAB
}
umount_netfs()
{
SHOWINFO "unmount all netfs stuff from $MTAB"
test -f $MTAB || return
rm -f $SRVFLAG
while read DEV MTPT FSTYPE OPTS REST
do
case "$OPTS" in
noauto|*,noauto|noauto,*|*,noauto,*)
continue
;;
esac
case "$FSTYPE" in
nfs|cifs)
SHOWINFO "trying to unmount $DEV from $MTPT"
(
if OUT=$(umount -f $MTPT 2>&1 >/dev/null); then
RET=$?
LOGINFO "umount: $MTPT - success ($RET)"
else
RET=$?
LOGWARN "umount: $MTPT - failed ($RET)"
echo "$OUT" | LOGWARN
test -e $SRVFLAG || touch $SRVFLAG
fi
) &
;;
*)
continue
;;
esac
done < $MTAB
}
if [ -e /tmp/.flash.start ]; then
SHOWINFO "flash.start flag found"
umount_netfs
SHOWINFO "exiting"
exit 0
fi
case "$1" in
"start")
mount_local
mount_netfs
;;
"start_netfs")
mount_netfs
;;
"stop_netfs")
umount_netfs
;;
"stop")
umount_netfs
#SHOWINFO "unmount all sysfs, tmpfs, devpts and usbfs mounts"
#umount -a -t sysfs, tmpfs, devpts, usbfs
#SHOWINFO "disable all swaps"
#swapoff -a
#SHOWINFO "detach jffs2 filesystems"
#umount -l -t jffs2
;;
*)
echo "[$BASENAME] Usage: $0 {start|start_netfs|stop_netfs|stop}"
;;
esac

195
skel-root/coolstream/hd1/etc/init.d/fstab

@ -1,195 +0,0 @@
#!/bin/sh
. /etc/init.d/globals
SRVFLAG=/var/etc/.srv
MTAB=/etc/mtab
FSTAB=/etc/fstab
if [ -e /var/etc/fstab ]; then
FSTAB=/var/etc/fstab
fi
is_mount()
{
RET=1
test -f $MTAB || return $RET
while read _DEV _MTPT _FSTYPE _OPTS _REST
do
case "$_FSTYPE" in
"tmpfs") continue ;;
esac
case "$1" in
"$_DEV"|"$_MTPT") RET=0; break ;;
esac
done < $MTAB
return $RET
}
mount_local()
{
SHOWINFO "mount all local stuff from $FSTAB"
test -f $FSTAB || return
while read DEV MTPT FSTYPE OPTS REST
do
case "$DEV" in
""|\#*)
continue
;;
esac
case "$OPTS" in
noauto|*,noauto|noauto,*|*,noauto,*)
continue
;;
esac
case "$FSTYPE" in
swap)
#SHOWINFO "enable all swaps from $FSTAB"
#swapon -a
SHOWINFO "ignoring all swaps from $FSTAB"
continue
;;
nfs|cifs)
continue
;;
*)
test -d $MTPT || mkdir -p $MTPT;
SHOWINFO "trying to mount $DEV to $MTPT"
if OUT=$(mount $MTPT 2>&1 >/dev/null)
then
RET=$?
LOGINFO "mount: $MTPT - success ($RET)"
else
RET=$?
LOGWARN "mount: $MTPT - failed ($RET)"
echo "$OUT" | LOGWARN
fi
;;
esac
done < $FSTAB
}
mount_netfs()
{
SHOWINFO "mount all netfs stuff from $FSTAB"
test -f $FSTAB || return
rm -f $SRVFLAG
while read DEV MTPT FSTYPE OPTS REST
do
case "$DEV" in
""|\#*)
continue
;;
esac
case "$OPTS" in
noauto|*,noauto|noauto,*|*,noauto,*)
continue
;;
esac
case "$FSTYPE" in
nfs|cifs)
if ! is_mount $MTPT; then
test -d $MTPT || mkdir -p $MTPT;
SHOWINFO "trying to mount $DEV to $MTPT"
(
try=51
while(true); do
if OUT=$(mount $MTPT 2>&1 >/dev/null); then
RET=$?
LOGINFO "mount: $MTPT - success ($RET)"
test -e $SRVFLAG || touch $SRVFLAG
break
else
RET=$?
LOGWARN "mount: $MTPT - failed ($RET)"
echo "$OUT" | LOGWARN
if [ ${try:1:1} -eq ${try:0:1} ]; then
LOGWARN "mount: $MTPT - cancel!"
break
fi
try=$((try+1))
LOGWARN "mount: $MTPT - try ${try:1:1} in 30 seconds ..."
sleep 30
fi
done
) &
else
SHOWINFO "already mounted $MTPT"
test -e $SRVFLAG || touch $SRVFLAG
fi
;;
*)
continue
;;
esac
done < $FSTAB
}
umount_netfs()
{
SHOWINFO "unmount all netfs stuff from $MTAB"
test -f $MTAB || return
rm -f $SRVFLAG
while read DEV MTPT FSTYPE OPTS REST
do
case "$OPTS" in
noauto|*,noauto|noauto,*|*,noauto,*)
continue
;;
esac
case "$FSTYPE" in
nfs|cifs)
SHOWINFO "trying to unmount $DEV from $MTPT"
(
if OUT=$(umount -f $MTPT 2>&1 >/dev/null); then
RET=$?
LOGINFO "umount: $MTPT - success ($RET)"
else
RET=$?
LOGWARN "umount: $MTPT - failed ($RET)"
echo "$OUT" | LOGWARN
test -e $SRVFLAG || touch $SRVFLAG
fi
) &
;;
*)
continue
;;
esac
done < $MTAB
}
if [ -e /tmp/.flash.start ]; then
SHOWINFO "flash.start flag found"
umount_netfs
SHOWINFO "exiting"
exit 0
fi
case "$1" in
"start")
mount_local
mount_netfs
;;
"start_netfs")
mount_netfs
;;
"stop_netfs")
umount_netfs
;;
"stop")
umount_netfs
#SHOWINFO "unmount all sysfs, tmpfs, devpts and usbfs mounts"
#umount -a -t sysfs, tmpfs, devpts, usbfs
#SHOWINFO "disable all swaps"
#swapoff -a
#SHOWINFO "detach jffs2 filesystems"
#umount -l -t jffs2
;;
*)
echo "[$BASENAME] Usage: $0 {start|start_netfs|stop_netfs|stop}"
;;
esac

195
skel-root/coolstream/hd2/etc/init.d/fstab

@ -1,195 +0,0 @@
#!/bin/sh
. /etc/init.d/globals
SRVFLAG=/var/etc/.srv
MTAB=/etc/mtab
FSTAB=/etc/fstab
if [ -e /var/etc/fstab ]; then
FSTAB=/var/etc/fstab
fi
is_mount()
{
RET=1
test -f $MTAB || return $RET
while read _DEV _MTPT _FSTYPE _OPTS _REST
do
case "$_FSTYPE" in
"tmpfs") continue ;;
esac
case "$1" in
"$_DEV"|"$_MTPT") RET=0; break ;;
esac
done < $MTAB
return $RET
}
mount_local()
{
SHOWINFO "mount all local stuff from $FSTAB"
test -f $FSTAB || return
while read DEV MTPT FSTYPE OPTS REST
do
case "$DEV" in
""|\#*)
continue
;;
esac
case "$OPTS" in
noauto|*,noauto|noauto,*|*,noauto,*)
continue
;;
esac
case "$FSTYPE" in
swap)
#SHOWINFO "enable all swaps from $FSTAB"
#swapon -a
SHOWINFO "ignoring all swaps from $FSTAB"
continue
;;
nfs|cifs)
continue
;;
*)
test -d $MTPT || mkdir -p $MTPT;
SHOWINFO "trying to mount $DEV to $MTPT"
if OUT=$(mount $MTPT 2>&1 >/dev/null)
then
RET=$?
LOGINFO "mount: $MTPT - success ($RET)"
else
RET=$?
LOGWARN "mount: $MTPT - failed ($RET)"
echo "$OUT" | LOGWARN
fi
;;
esac
done < $FSTAB
}
mount_netfs()
{
SHOWINFO "mount all netfs stuff from $FSTAB"
test -f $FSTAB || return
rm -f $SRVFLAG
while read DEV MTPT FSTYPE OPTS REST
do
case "$DEV" in
""|\#*)
continue
;;
esac
case "$OPTS" in
noauto|*,noauto|noauto,*|*,noauto,*)
continue
;;
esac
case "$FSTYPE" in
nfs|cifs)
if ! is_mount $MTPT; then
test -d $MTPT || mkdir -p $MTPT;
SHOWINFO "trying to mount $DEV to $MTPT"
(
try=51
while(true); do
if OUT=$(mount $MTPT 2>&1 >/dev/null); then
RET=$?
LOGINFO "mount: $MTPT - success ($RET)"
test -e $SRVFLAG || touch $SRVFLAG
break
else
RET=$?
LOGWARN "mount: $MTPT - failed ($RET)"
echo "$OUT" | LOGWARN
if [ ${try:1:1} -eq ${try:0:1} ]; then
LOGWARN "mount: $MTPT - cancel!"
break
fi
try=$((try+1))
LOGWARN "mount: $MTPT - try ${try:1:1} in 30 seconds ..."
sleep 30
fi
done
) &
else
SHOWINFO "already mounted $MTPT"
test -e $SRVFLAG || touch $SRVFLAG
fi
;;
*)
continue
;;
esac
done < $FSTAB
}
umount_netfs()
{
SHOWINFO "unmount all netfs stuff from $MTAB"
test -f $MTAB || return
rm -f $SRVFLAG
while read DEV MTPT FSTYPE OPTS REST
do
case "$OPTS" in
noauto|*,noauto|noauto,*|*,noauto,*)
continue
;;
esac
case "$FSTYPE" in
nfs|cifs)
SHOWINFO "trying to unmount $DEV from $MTPT"
(
if OUT=$(umount -f $MTPT 2>&1 >/dev/null); then
RET=$?
LOGINFO "umount: $MTPT - success ($RET)"
else
RET=$?
LOGWARN "umount: $MTPT - failed ($RET)"
echo "$OUT" | LOGWARN
test -e $SRVFLAG || touch $SRVFLAG
fi
) &
;;
*)
continue
;;
esac
done < $MTAB
}
if [ -e /tmp/.flash.start ]; then
SHOWINFO "flash.start flag found"
umount_netfs
SHOWINFO "exiting"
exit 0
fi
case "$1" in
"start")
mount_local
mount_netfs
;;
"start_netfs")
mount_netfs
;;
"stop_netfs")
umount_netfs
;;
"stop")
umount_netfs
#SHOWINFO "unmount all sysfs, tmpfs, devpts and usbfs mounts"
#umount -a -t sysfs, tmpfs, devpts, usbfs
#SHOWINFO "disable all swaps"
#swapoff -a
#SHOWINFO "detach jffs2 filesystems"
#umount -l -t jffs2
;;
*)
echo "[$BASENAME] Usage: $0 {start|start_netfs|stop_netfs|stop}"
;;
esac

0
skel-root/armbox/bre2ze4k/etc/init.d/fstab → skel-root/general/scripts/fstab.init

Loading…
Cancel
Save