#!/bin/sh ###################################################################### # file rc.common # version 2.0.0 # date 2017-10-11 # author liumingyuan # base on openwrt ###################################################################### . $IPKG_INSTROOT/lib/functions.sh . $IPKG_INSTROOT/lib/functions/service.sh initscript=$1 action=${2:-help} shift 2 start() { echo 'Not defined "start" functions!!!' } stop() { echo 'Not defined "stop" functions!!!' } restart() { trap '' TERM stop "$@" start "$@" } disable() { name="$(basename "${initscript}")" rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name } enable() { name="$(basename "${initscript}")" disable [ -n "$START" -o -n "$STOP" ] || { echo "/etc/init.d/$name does not have a START or STOP value" return 1 } [ "$START" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" [ "$STOP" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}" } list_contains() { local var="$1" local str="$2" local val eval "val=\" \${$var} \"" [ "${val%% $str *}" != "$val" ] } # for procd start_service() { echo 'Not defined "start_service" functions!!!' } stop_service() { echo 'Not defined "stop_service" functions!!!' } service_triggers() { echo 'Not defined "service_triggers" functions!!!' } service_running() { echo 'Not defined "service_running" functions!!!' } boot() { start "$@" } help() { cat <> /tmp/processlog RESPAWN_FLAG= fi exec $@ ;; esac } . "$initscript" [ -n "$USE_PROCD" ] && { start() { start_service "$@" } stop() { stop_service "$@" } } ALL_COMMANDS="start stop restart boot shutdown enable disable enabled" list_contains ALL_COMMANDS "$action" || action=help "$action" "$@" &