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]
108 local instance
="${1:-*}"
110 procd_running
"$(basename $initscript)" "$instance"
113 ${INIT_TRACE:+set -x}
115 extra_command
"start" "Start the service"
116 extra_command
"stop" "Stop the service"
117 extra_command
"restart" "Restart the service"
118 extra_command
"reload" "Reload configuration files (or restart if service does not implement reload)"
119 extra_command
"enable" "Enable service autostart"
120 extra_command
"disable" "Disable service autostart"
121 extra_command
"enabled" "Check if service is started on boot"
125 [ -n "$USE_PROCD" ] && {
126 extra_command
"running" "Check if service is running"
127 extra_command
"status" "Service status"
128 extra_command
"trace" "Start with syscall trace"
129 extra_command
"info" "Dump procd service info"
131 .
$IPKG_INSTROOT/lib
/functions
/procd.sh
132 basescript
=$
(readlink
"$initscript")
135 [ -n "$2" ] && method
="add"
136 procd_open_service
"$(basename ${basescript:-$initscript})" "$initscript"
138 procd_close_service
"$method"
142 rc_procd start_service
"$@"
143 if eval "type service_started" 2>/dev
/null
>/dev
/null
; then
155 json_add_string name
"$(basename ${basescript:-$initscript})"
156 json_add_boolean verbose
"1"
157 _procd_ubus_call list
163 procd_kill
"$(basename ${basescript:-$initscript})" "$1"
164 if eval "type service_stopped" 2>/dev
/null
>/dev
/null
; then
170 if eval "type reload_service" 2>/dev
/null
>/dev
/null
; then
183 if eval "type status_service" 2>/dev
/null
>/dev
/null
; then
186 _procd_status
"$(basename ${basescript:-$initscript})" "$1"
191 ALL_COMMANDS
="${ALL_COMMANDS} ${EXTRA_COMMANDS}"
192 ALL_HELP
="${ALL_HELP}${EXTRA_HELP}"
193 list_contains ALL_COMMANDS
"$action" || action
=help