NoPaste

beispiel

von Sledge Hammer

SNIPPET_TEXT:
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          mountkernfs
  4. # Required-Start:
  5. # Required-Stop:
  6. # Should-Start:      glibc
  7. # Default-Start:     S
  8. # Default-Stop:
  9. # Short-Description: Mount kernel virtual file systems.
  10. # Description:       Mount initial set of virtual filesystems the kernel
  11. #                    provides and that are required by everything.
  12. ### END INIT INFO
  13.  
  14. PATH=/lib/init:/sbin:/bin
  15. . /lib/init/vars.sh
  16.  
  17. . /lib/lsb/init-functions
  18. . /lib/init/mount-functions.sh
  19.  
  20. [ -f /etc/default/tmpfs ] && . /etc/default/tmpfs
  21.  
  22. do_start () {
  23.         #
  24.         # Get some writable area available before the root is checked
  25.         # and remounted.
  26.         #
  27.         RW_OPT=
  28.         [ "${RW_SIZE:=$TMPFS_SIZE}" ] && RW_OPT=",size=$RW_SIZE"
  29.         domount tmpfs "" /lib/init/rw tmpfs -omode=0755,nosuid$RW_OPT
  30.         touch /lib/init/rw/.ramfs
  31.  
  32.         #
  33.         # Mount proc filesystem on /proc
  34.         #
  35.         domount proc "" /proc proc -onodev,noexec,nosuid
  36.  
  37.         #
  38.         # Mount sysfs on /sys
  39.         #
  40.         # Only mount sysfs if it is supported (kernel >= 2.6)
  41.         if grep -E -qs "sysfs\$" /proc/filesystems
  42.         then
  43.                 domount sysfs "" /sys sysfs -onodev,noexec,nosuid
  44.         fi
  45.  
  46.         # Mount /var/run and /var/lock as tmpfs if enabled
  47.         if [ yes = "$RAMRUN" ] ; then
  48.                 RUN_OPT=
  49.                 [ "${RUN_SIZE:=$TMPFS_SIZE}" ] && RUN_OPT=",size=$RUN_SIZE"
  50.                 domount tmpfs "" /var/run varrun -omode=0755,nosuid$RUN_OPT
  51.                 touch /var/run/.ramfs
  52.         fi
  53.         if [ yes = "$RAMLOCK" ] ; then
  54.                 LOCK_OPT=
  55.                 [ "${LOCK_SIZE:=$TMPFS_SIZE}" ] && LOCK_OPT=",size=$LOCK_SIZE"
  56.                 domount tmpfs "" /var/lock varlock -omode=1777,nodev,noexec,nosuid$LOCK_OPT
  57.                 touch /var/lock/.ramfs
  58.         fi
  59.  
  60.         #
  61.         # Mount usbfs/usbdevfs if /proc/bus/usb is present.
  62.         #
  63.         # Usbfs/usbdevfs is used for USB related binaries/libraries.
  64.         # "usbfs" and "usbdevfs" are the exact same filesystem.
  65.         # "usbdevfs" was renamed to "usbfs" by linux usb developers,
  66.         # because people sometimes mistook it as a part of devfs. Usbfs
  67.         # will be superseded by other filesystems (e.g. sysfs), and when
  68.         # it becomes obsolete the mount action below should be removed.
  69.         #
  70.         if [ -d /proc/bus/usb ]
  71.         then
  72.                 domount usbfs usbdevfs /proc/bus/usb usbfs -onodev,noexec,nosuid,devgid=1001,devmode=664
  73.         fi
  74. }
  75.  
  76. case "$1" in
  77.   "")
  78.         echo "Warning: mountkernfs should be called with the 'start' argument." >&2
  79.         do_start
  80.         ;;
  81.   start)
  82.         do_start
  83.         ;;
  84.   restart|reload|force-reload)
  85.         echo "Error: argument '$1' not supported" >&2
  86.         exit 3
  87.         ;;
  88.   stop)
  89.         # No-op
  90.         ;;
  91.   *)
  92.         echo "Usage: mountkernfs [start|stop]" >&2
  93.         exit 3
  94.         ;;
  95. esac

Quellcode

Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. PASTEBIN_DOWNLOAD_SNIPPET_EXPLAIN