Skip to content

Commit

Permalink
Merge pull request #34 from thin-edge/feat-s6-overlay-disable-flag
Browse files Browse the repository at this point in the history
feat(s6-overlay): support enabling/disabling a service via env variables
  • Loading branch information
reubenmiller authored Oct 12, 2023
2 parents 3c3cf74 + bfac5ad commit 4ee87c3
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 0 deletions.
2 changes: 2 additions & 0 deletions services/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ execute_template() {
-e "s|\\\$COMMAND_ARGS|${COMMAND_ARGS:-}|g" \
-e "s|\\\$COMMAND_USER|${COMMAND_USER:-}|g" \
-e "s|\\\$COMMAND|${COMMAND:-}|g" \
-e "s|\\\$ENV_ENABLE_SERVICE|${ENV_ENABLE_SERVICE:-}|g" \
-e "s|\\\$SHORTNAME|${SHORTNAME:-}|g" \
-e "s|\\\$DESCRIPTION|${DESCRIPTION:-}|g" \
"$input_file"
Expand All @@ -27,6 +28,7 @@ execute_template_inplace() {
-e "s|\\\$COMMAND_ARGS|${COMMAND_ARGS:-}|g" \
-e "s|\\\$COMMAND_USER|${COMMAND_USER:-}|g" \
-e "s|\\\$COMMAND|${COMMAND:-}|g" \
-e "s|\\\$ENV_ENABLE_SERVICE|${ENV_ENABLE_SERVICE:-}|g" \
-e "s|\\\$SHORTNAME|${SHORTNAME:-}|g" \
-e "s|\\\$DESCRIPTION|${DESCRIPTION:-}|g" \
"$input_file"
Expand Down
7 changes: 7 additions & 0 deletions services/s6-overlay/s6-rc.d/c8y-configuration-plugin/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/command/with-contenv sh
if [ "${SERVICE_C8Y_CONFIGURATION_PLUGIN:-1}" -eq 0 ]; then
# Disable service and don't start again
# https://github.com/just-containers/s6-overlay/issues/394
s6-svc -O .
exit 0
fi

exec 2>&1
exec /usr/bin/c8y-configuration-plugin
7 changes: 7 additions & 0 deletions services/s6-overlay/s6-rc.d/c8y-firmware-plugin/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/command/with-contenv sh
if [ "${SERVICE_C8Y_FIRMWARE_PLUGIN:-1}" -eq 0 ]; then
# Disable service and don't start again
# https://github.com/just-containers/s6-overlay/issues/394
s6-svc -O .
exit 0
fi

exec 2>&1
exec /usr/bin/c8y-firmware-plugin
7 changes: 7 additions & 0 deletions services/s6-overlay/s6-rc.d/mosquitto/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/command/with-contenv sh
if [ "${SERVICE_MOSQUITTO:-1}" -eq 0 ]; then
# Disable service and don't start again
# https://github.com/just-containers/s6-overlay/issues/394
s6-svc -O .
exit 0
fi

exec 2>&1
exec /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
7 changes: 7 additions & 0 deletions services/s6-overlay/s6-rc.d/tedge-agent/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/command/with-contenv sh
if [ "${SERVICE_TEDGE_AGENT:-1}" -eq 0 ]; then
# Disable service and don't start again
# https://github.com/just-containers/s6-overlay/issues/394
s6-svc -O .
exit 0
fi

exec 2>&1
exec /usr/bin/tedge-agent
7 changes: 7 additions & 0 deletions services/s6-overlay/s6-rc.d/tedge-log-plugin/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/command/with-contenv sh
if [ "${SERVICE_TEDGE_LOG_PLUGIN:-1}" -eq 0 ]; then
# Disable service and don't start again
# https://github.com/just-containers/s6-overlay/issues/394
s6-svc -O .
exit 0
fi

exec 2>&1
exec /usr/bin/tedge-log-plugin
7 changes: 7 additions & 0 deletions services/s6-overlay/s6-rc.d/tedge-mapper-aws/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/command/with-contenv sh
if [ "${SERVICE_TEDGE_MAPPER_AWS:-1}" -eq 0 ]; then
# Disable service and don't start again
# https://github.com/just-containers/s6-overlay/issues/394
s6-svc -O .
exit 0
fi

exec 2>&1
exec /usr/bin/tedge-mapper aws
7 changes: 7 additions & 0 deletions services/s6-overlay/s6-rc.d/tedge-mapper-az/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/command/with-contenv sh
if [ "${SERVICE_TEDGE_MAPPER_AZ:-1}" -eq 0 ]; then
# Disable service and don't start again
# https://github.com/just-containers/s6-overlay/issues/394
s6-svc -O .
exit 0
fi

exec 2>&1
exec /usr/bin/tedge-mapper az
7 changes: 7 additions & 0 deletions services/s6-overlay/s6-rc.d/tedge-mapper-c8y/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/command/with-contenv sh
if [ "${SERVICE_TEDGE_MAPPER_C8Y:-1}" -eq 0 ]; then
# Disable service and don't start again
# https://github.com/just-containers/s6-overlay/issues/394
s6-svc -O .
exit 0
fi

exec 2>&1
exec /usr/bin/tedge-mapper c8y
7 changes: 7 additions & 0 deletions services/s6-overlay/s6-rc.d/tedge-mapper-collectd/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/command/with-contenv sh
if [ "${SERVICE_TEDGE_MAPPER_COLLECTD:-1}" -eq 0 ]; then
# Disable service and don't start again
# https://github.com/just-containers/s6-overlay/issues/394
s6-svc -O .
exit 0
fi

exec 2>&1
exec /usr/bin/tedge-mapper collectd
7 changes: 7 additions & 0 deletions services/s6-overlay/templates/service/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/command/with-contenv sh
if [ "${$ENV_ENABLE_SERVICE:-1}" -eq 0 ]; then
# Disable service and don't start again
# https://github.com/just-containers/s6-overlay/issues/394
s6-svc -O .
exit 0
fi

exec 2>&1
exec $COMMAND $COMMAND_ARGS
1 change: 1 addition & 0 deletions services/template-input/mosquitto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ NAME=mosquitto
COMMAND=/usr/sbin/mosquitto
COMMAND_ARGS="-c /etc/mosquitto/mosquitto.conf"
COMMAND_USER=root
ENV_ENABLE_SERVICE=SERVICE_MOSQUITTO
DESCRIPTION="MQTT broker"
SHORTNAME=mosquitto

Expand Down
1 change: 1 addition & 0 deletions services/template-input/tedge-agent
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ COMMAND=/usr/bin/tedge-agent
COMMAND_USER=
COMMAND_ARGS=
COMMAND_USER=tedge
ENV_ENABLE_SERVICE=SERVICE_TEDGE_AGENT
DESCRIPTION="tedge-agent is a thin-edge.io component to support operations"
1 change: 1 addition & 0 deletions services/template-input/tedge-configuration-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ NAME=c8y-configuration-plugin
COMMAND=/usr/bin/c8y-configuration-plugin
#COMMAND_ARGS=
COMMAND_USER=root
ENV_ENABLE_SERVICE=SERVICE_C8Y_CONFIGURATION_PLUGIN
DESCRIPTION="Thin-edge device configuration management for Cumulocity"
1 change: 1 addition & 0 deletions services/template-input/tedge-firmware-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ NAME=c8y-firmware-plugin
COMMAND=/usr/bin/c8y-firmware-plugin
#COMMAND_ARGS=
COMMAND_USER=tedge
ENV_ENABLE_SERVICE=SERVICE_C8Y_FIRMWARE_PLUGIN
DESCRIPTION="Thin-edge device firmware management for Cumulocity"
1 change: 1 addition & 0 deletions services/template-input/tedge-log-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ NAME=tedge-log-plugin
COMMAND=/usr/bin/tedge-log-plugin
#COMMAND_ARGS=
COMMAND_USER=root
ENV_ENABLE_SERVICE=SERVICE_TEDGE_LOG_PLUGIN
DESCRIPTION="thin-edge.io log file retriever"
1 change: 1 addition & 0 deletions services/template-input/tedge-mapper-aws
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ NAME=tedge-mapper-aws
COMMAND=/usr/bin/tedge-mapper
COMMAND_ARGS=aws
COMMAND_USER=tedge
ENV_ENABLE_SERVICE=SERVICE_TEDGE_MAPPER_AWS
DESCRIPTION="tedge-mapper-aws checks Thin Edge JSON measurements and forwards to AWS IoT Hub"
SHORTNAME=mapper-aws
1 change: 1 addition & 0 deletions services/template-input/tedge-mapper-az
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ NAME=tedge-mapper-az
COMMAND=/usr/bin/tedge-mapper
COMMAND_ARGS=az
COMMAND_USER=tedge
ENV_ENABLE_SERVICE=SERVICE_TEDGE_MAPPER_AZ
DESCRIPTION="tedge-mapper-az checks Thin Edge JSON measurements and forwards to Azure IoT Hub"
SHORTNAME=mapper-az
1 change: 1 addition & 0 deletions services/template-input/tedge-mapper-c8y
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ NAME=tedge-mapper-c8y
COMMAND=/usr/bin/tedge-mapper
COMMAND_ARGS=c8y
COMMAND_USER=tedge
ENV_ENABLE_SERVICE=SERVICE_TEDGE_MAPPER_C8Y
DESCRIPTION="tedge-mapper-c8y converts Thin Edge JSON measurements to Cumulocity JSON format"
SHORTNAME=mapper-c8y
1 change: 1 addition & 0 deletions services/template-input/tedge-mapper-collectd
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ NAME=tedge-mapper-collectd
COMMAND=/usr/bin/tedge-mapper
COMMAND_ARGS=collectd
COMMAND_USER=tedge
ENV_ENABLE_SERVICE=SERVICE_TEDGE_MAPPER_COLLECTD
DESCRIPTION="tedge-mapper-collectd converts Thin Edge JSON measurements to Cumulocity JSON format"
SHORTNAME=mapper-collectd

0 comments on commit 4ee87c3

Please sign in to comment.