2 # Copyright (C) 2006-2012 OpenWrt.org
4 .
$IPKG_INSTROOT/lib
/functions.sh
5 .
$IPKG_INSTROOT/lib
/functions
/service.sh
39 name
="$(basename "${initscript}")"
40 rm -f "$IPKG_INSTROOT"/etc
/rc.d
/S??
$name
41 rm -f "$IPKG_INSTROOT"/etc
/rc.d
/K??
$name
46 name
="$(basename "${initscript}")"
48 ln -sf "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" && \
51 ln -sf "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}" && \
57 name
="$(basename "${initscript}")"
58 name
="${name##[SK][0-9][0-9]}"
60 [ -z "${START:-}" ] ||
[ -L "$IPKG_INSTROOT/etc/rc.d/S${START}$name" ]
62 [ -z "${STOP:-}" ] ||
[ -L "$IPKG_INSTROOT/etc/rc.d/K${STOP}$name" ]
71 ALL_COMMANDS
="boot shutdown depends"
76 local extra
="$(printf "%-16s%s
" "${cmd}" "${help}")"
77 ALL_HELP
="${ALL_HELP}\t${extra}\n"
78 ALL_COMMANDS
="${ALL_COMMANDS} ${cmd}"
83 Syntax: $initscript [command]
104 local instance
="${1:-*}"
106 procd_running
"$(basename $initscript)" "$instance"
109 ${INIT_TRACE:+set -x}
111 extra_command
"start" "Start the service"
112 extra_command
"stop" "Stop the service"
113 extra_command
"restart" "Restart the service"
114 extra_command
"reload" "Reload configuration files (or restart if service does not implement reload)"
115 extra_command
"enable" "Enable service autostart"
116 extra_command
"disable" "Disable service autostart"
117 extra_command
"enabled" "Check if service is started on boot"
121 [ -n "$USE_PROCD" ] && {
122 extra_command
"running" "Check if service is running"
123 extra_command
"status" "Service status"
124 extra_command
"trace" "Start with syscall trace"
125 extra_command
"info" "Dump procd service info"
127 .
$IPKG_INSTROOT/lib
/functions
/procd.sh
128 basescript
=$
(readlink
"$initscript")
131 [ -n "$2" ] && method
="add"
132 procd_open_service
"$(basename ${basescript:-$initscript})" "$initscript"
134 procd_close_service
"$method"
138 rc_procd start_service
"$@"
139 if eval "type service_started" 2>/dev
/null
>/dev
/null
; then
151 json_add_string name
"$(basename ${basescript:-$initscript})"
152 json_add_boolean verbose
"1"
153 _procd_ubus_call list
159 procd_kill
"$(basename ${basescript:-$initscript})" "$1"
160 if eval "type service_stopped" 2>/dev
/null
>/dev
/null
; then
166 if eval "type reload_service" 2>/dev
/null
>/dev
/null
; then
179 if eval "type status_service" 2>/dev
/null
>/dev
/null
; then
182 _procd_status
"$(basename ${basescript:-$initscript})" "$1"
187 ALL_COMMANDS
="${ALL_COMMANDS} ${EXTRA_COMMANDS}"
188 ALL_HELP
="${ALL_HELP}${EXTRA_HELP}"
189 list_contains ALL_COMMANDS
"$action" || action
=help