#!/bin/sh## udev This is a minimal non-LSB version of a UDEV startup script. It# was derived by stripping down the udev-058 LSB version for use# with buildroot on embedded hardware using Linux 2.6.34+ kernels.## You may need to customize this for your system's resource limits# (including startup time!) and administration. For example, if# your early userspace has a custom initramfs or initrd you might# need /dev much earlier; or without hotpluggable busses (like USB,# PCMCIA, MMC/SD, and so on) your /dev might be static after boot.## This script assumes your system boots right into the eventual root# filesystem, and that init runs this udev script before any programs# needing more device nodes than the bare-bones set -- /dev/console,# /dev/zero, /dev/null -- that's needed to boot and run this script.# # Check for missing binariesUDEV_BIN=/sbin/udevdtest -x $UDEV_BIN || exit 5 #文件不可执行则退出,退出码:5 # Check for config file and read itUDEV_CONFIG=/etc/udev/udev.conftest -r $UDEV_CONFIG || exit 6 #文件不可读则退出,退出码:6. $UDEV_CONFIG case "$1" in start) #设备开机时 printf "Populating ${udev_root:-/dev} using udev: " printf '\000\000\000\000' > /proc/sys/kernel/hotplug $UDEV_BIN -d || (echo "FAIL" && exit 1) #执行失败打印“FAIL”并退出 udevadm trigger --type=subsystems --action=add udevadm trigger --type=devices --action=add udevadm settle --timeout=30 || echo "udevadm settle failed" echo "done" ;; stop) #设备关机或重启 # Stop execution of events udevadm control --stop-exec-queue killall udevd ;; *) echo "Usage: $0 {start|stop}" exit 1 ;;esac exit 0
#! /bin/sh## urandom This script saves the random seed between reboots.# It is called from the boot, halt and reboot scripts.## Version: @(#)urandom 1.33 22-Jun-1998 miquels@cistron.nl# [ -c /dev/urandom ] || exit 0 #不存在字符设备urandom就退出#. /etc/default/rcS case "$1" in start|"") # check for read only file system if ! touch /etc/random-seed 2>/dev/null #如果无法创建random-seed文件 then echo "read-only file system detected...done" #检测到只读文件系统 exit #退出 fi if [ "$VERBOSE" != no ] then echo -n "Initializing random number generator... " fi # Load and then save 512 bytes, # which is the size of the entropy pool cat /etc/random-seed >/dev/urandom rm -f /etc/random-seed umask 077 #配置文件夹默认权限 dd if=/dev/urandom of=/etc/random-seed count=1 \ >/dev/null 2>&1 || echo "urandom start: failed." umask 022 [ "$VERBOSE" != no ] && echo "done." ;; stop) if ! touch /etc/random-seed 2>/dev/null then exit fi # Carry a random seed from shut-down to start-up; # see documentation in linux/drivers/char/random.c [ "$VERBOSE" != no ] && echo -n "Saving random seed... " umask 077 dd if=/dev/urandom of=/etc/random-seed count=1 \ >/dev/null 2>&1 || echo "urandom stop: failed." [ "$VERBOSE" != no ] && echo "done." ;; *) echo "Usage: urandom {start|stop}" >&2 exit 1 ;;esac
file:S30dbus
1 2 3 4 5 6 7 8 9
#!/bin/sh## messagebus: The D-BUS systemwide message bus## chkconfig: 345 97 03# description: This is a daemon which broadcasts notifications of system events \# and other messages. See http://www.freedesktop.org/software/dbus/## processname: dbus-daemon# pidfile: /var/run/messagebus.pid# # Sanity checks.[ -x /usr/bin/dbus-daemon ] || exit 0 #非可执行文件则退出 # Create needed directories.[ -d /var/run/dbus ] || mkdir -p /var/run/dbus #无此目录则创建, -p 循环创建,多层目录结构[ -d /var/lock/subsys ] || mkdir -p /var/lock/subsys[ -d /tmp/dbus ] || mkdir -p /tmp/dbus RETVAL=0 start() { echo -n "Starting system message bus: " dbus-uuidgen --ensure dbus-daemon --system RETVAL=$? echo "done" [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dbus-daemon #dbus-daemon命令执行正常,锁定} stop() { echo -n "Stopping system message bus: " ## we don't want to kill all the per-user $processname, we want ## to use the pid file *only*; because we use the fake nonexistent ## program name "$servicename" that should be safe-ish killall dbus-daemon RETVAL=$? echo "done" if [ $RETVAL -eq 0 ]; then rm -f /var/lock/subsys/dbus-daemon rm -f /var/run/messagebus.pid fi} # See how we were called.case "$1" in start) start ;; stop) stop ;; status) status $processname RETVAL=$? ;; restart) stop start ;; condrestart) if [ -f /var/lock/subsys/$servicename ]; then stop start fi ;; reload) echo "Message bus can't reload its configuration, you have to restart it" RETVAL=$? ;; *) echo "Usage: $0 {start|stop|status|restart|condrestart|reload}" ;;esacexit $RETVAL
#!/bin/sh## Starts dropbear sshd.# # Allow a few customizations from a config filetest -r /etc/default/dropbear && . /etc/default/dropbear #为可读文件则执行 start() { DROPBEAR_ARGS="$DROPBEAR_ARGS -R" # If /etc/dropbear is a symlink to /var/run/dropbear, and # - the filesystem is RO (i.e. we can not rm the symlink), # create the directory pointed to by the symlink. # - the filesystem is RW (i.e. we can rm the symlink), # replace the symlink with an actual directory if [ -L /etc/dropbear \ #是一个符号链接 -a "$(readlink /etc/dropbear)" = "/var/run/dropbear" ] #文件存在 then if rm -f /etc/dropbear >/dev/null 2>&1; then #错误输出重定向到标准输出,标准输出重定向到空文件(不打印任何东西) mkdir -p /etc/dropbear #成功删除则创建此目录 else echo "No persistent location to store SSH host keys. New keys will be" echo "generated at each boot. Are you sure this is what you want to do?" mkdir -p "$(readlink /etc/dropbear)" fi fi echo -n "Starting dropbear sshd: " umask 077 start-stop-daemon -S -q -p /var/run/dropbear.pid \ --exec /usr/sbin/dropbear -- $DROPBEAR_ARGS [ $? = 0 ] && echo "OK" || echo "FAIL"}stop() { echo -n "Stopping dropbear sshd: " start-stop-daemon -K -q -p /var/run/dropbear.pid [ $? = 0 ] && echo "OK" || echo "FAIL"}restart() { stop start} case "$1" in start) start ;; stop) stop ;; restart|reload) restart ;; *) echo "Usage: $0 {start|stop|restart}" exit 1esac exit $?
ubiattach-m, --mtdn=<number>此选项是必须的MTD device number to attach (alternative method, e.g if the character device node does not exist) 。附加的MTD设备编号(替代方法,e.g 如果字符设备节点不存在)注意:是从0开始的。-d, --devn=<number>the number to assign to the newly created UBI device (assigned automatically if this is not specified)分配给新创建的UBI设备的号码(如果没有指定,则自动分配)ubidetach-p, --dev-path=<path>要附加的MTD设备节点的路径。ubiformat格式化MTD设备,擦除Flash,保存擦除计数,写入UBI镜像到Flash。flash_erase命令有类似的效果。ubimkvol从UBI设备上创建UBI卷。-N, --name=<name>卷名 。-m, --maxavsize将卷大小设置为最大可用大小。
file:S81web.sh
1 2
#!/bin/sh /usr/local/webs/bin/webs &
file:S90start_userapp.sh
1 2 3 4 5
#!/bin/sh # set ipifconfig eth0 192.168.1.131 #配置eth0接口网络ifconfig eth1 192.168.2.136 # disable rtc clk_out pins defaultecho 0 > /sys/class/rtc/rtc0/device/clk_out_ctl #禁用RTC clk_out引脚 # if test function in sd card then execif [ -f "/media/mmcblk0p1/function/functiontest.sh" ]; then #内存卡自定义程序 echo "Start functiontest.sh" cd /media/mmcblk0p1/function ./functiontest.sh &fi # you can add your app start_command here
file:socketcand
1 2 3 4 5 6
#! /bin/sh ### BEGIN INIT INFO# Provides: socketcand# Required-Start: $remote_fs# Required-Stop: $remote_fs# Default-Start: 2 3 4 5# Default-Stop:# Short-Description: socketcand# Description: daemon that provides network access to local CAN busses### END INIT INFO [ -f /etc/default/rcS ] && . /etc/default/rcS #一般文件(非目录或设备文件)PATH=/bin:/usr/bin:/sbin:/usr/sbinprefix=/usrexec_prefix=/usrDAEMON=${exec_prefix}/bin/socketcandDESC="SocketCAN daemon"NAME="socketcand"PIDFILE=/var/run/socketcand.pid test -x $DAEMON || exit 0 #/usr/bin/socketcand文件非可执行文件则退出 case "$1" in start) echo "Starting $DESC" "$NAME" start-stop-daemon --start --quiet --background --pidfile $PIDFILE --startas $DAEMON -m -- --daemon ;; stop) echo "Stopping $DESC" "$NAME" start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --startas $DAEMON rm -f $PIDFILE ;; restart) $0 stop sleep 1 $0 start ;; force-reload) if start-stop-daemon --stop --test --quiet --pidfile $PIDFILE --startas $DAEMON ; then $0 restart fi ;; *) echo "Usage: /etc/init.d/socketcand {start|stop|restart|force-reload}" exit 1 ;;esac exit 0
Start the food daemon, unless one is already running (a process named food, running as user food, with pid in food.pid).启动food守护进程,除非它已经在运行(一个名为food的进程,以用户food的身份运行,在foo.pid中使用pid):