Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ns-plug/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ define Package/ns-plug/install
$(INSTALL_DIR) $(1)/usr/libexec/mwan-hooks
$(INSTALL_BIN) ./files/ns-plug.init $(1)/etc/init.d/ns-plug
$(INSTALL_BIN) ./files/ns-plug $(1)/usr/sbin/ns-plug
$(INSTALL_BIN) ./files/restart-ns-plug $(1)/usr/sbin/restart-ns-plug
$(INSTALL_BIN) ./files/distfeed-setup $(1)/usr/sbin/distfeed-setup
$(INSTALL_BIN) ./files/remote-backup $(1)/usr/sbin
$(INSTALL_BIN) ./files/send-backup $(1)/usr/sbin
Expand Down
3 changes: 2 additions & 1 deletion packages/ns-plug/files/ns-plug
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ response=""
until [ "${valid}" -eq 1 ] || [ "${watchdog}" -ge "${max_attempts}" ]
do
response=$(curl ${curl_opts} -H "Content-Type: application/json" -H "RegistrationToken: ${token}" ${server}/api/units/register -X POST --data '{"unit_id": "'${unit_id}'", "username": "'${user}'", "password": "'${secret}'", "unit_name": "'${unit_name}'", "version": "'${VERSION_ID}'", "subscription_type": "'${subscription_type}'", "system_id": "'${system_id}'"}')
http_code=$(echo ${response} | jq -r .code)
http_code=$(echo ${response} | jq -r '.code // empty')
if [ "${http_code}" == "409" ]; then
# Duplicate entry, cleanup uci config
uci delete rpcd.controller
Expand Down Expand Up @@ -112,6 +112,7 @@ dev tun-nsplug
tls-client
script-security 2
route-up /usr/sbin/ns-controller-push-info
down "/usr/sbin/restart-ns-plug"
<ca>
${ca}
</ca>
Expand Down
21 changes: 21 additions & 0 deletions packages/ns-plug/files/restart-ns-plug
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

#
# Copyright (C) 2024 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-2.0-only
#

# Restart the ns-plug service when tun-nsplug goes down

# the service can take a while to stop
if /etc/init.d/ns-plug status ; then
sleep 30
fi

# Check if the service is NOT running
if ! /etc/init.d/ns-plug status ; then
exit 0
fi

# Restart the service
/etc/init.d/ns-plug restart
Loading