File tree Expand file tree Collapse file tree 1 file changed +23
-6
lines changed
src/tedge/services-init.d Expand file tree Collapse file tree 1 file changed +23
-6
lines changed Original file line number Diff line number Diff line change 11#! /bin/sh
22set -e
33
4- if [ -f @CONFIG_DIR@/env ]; then
4+ CONFIG_DIR=" @CONFIG_DIR@"
5+
6+ if [ -f " $CONFIG_DIR /env" ]; then
57 set -a
68 # shellcheck disable=SC1091
7- . @ CONFIG_DIR@ /env
9+ . " $ CONFIG_DIR /env"
810 set +a
911fi
1012
@@ -22,16 +24,31 @@ manage_initd() {
2224 ;;
2325 esac
2426
25- SOURCE_SCRIPT=$( find " @ CONFIG_DIR@ /services-init.d" -name " *$name " | head -n1)
27+ SOURCE_SCRIPT=$( find " $ CONFIG_DIR /services-init.d" -name " *$name " | head -n1)
2628 SERVICE_SCRIPT=$( find /etc/init.d -name " *$name " | head -n1)
29+ if [ -z " $SERVICE_SCRIPT " ]; then
30+ # use default location
31+ SERVICE_SCRIPT=" /etc/init.d/$( basename " $SOURCE_SCRIPT " ) "
32+ fi
2733
2834 case " $command " in
2935 is_available)
3036 exit 0
3137 ;;
32- start) " $SERVICE_SCRIPT " start ;;
33- stop) " $SERVICE_SCRIPT " stop ;;
34- restart) " $SERVICE_SCRIPT " restart ;;
38+ start)
39+ " $SERVICE_SCRIPT " start
40+ ;;
41+ stop)
42+ # don't stop a service that does not exist
43+ if [ -f " $SERVICE_SCRIPT " ]; then
44+ " $SERVICE_SCRIPT " stop
45+ fi
46+ ;;
47+ restart)
48+ # tedge connect will do a restart then enable the service
49+ manage_initd enable " $name " || :
50+ " $SERVICE_SCRIPT " restart
51+ ;;
3552 enable)
3653 ln -sf " $SOURCE_SCRIPT " " $SERVICE_SCRIPT "
3754 ;;
You can’t perform that action at this time.
0 commit comments