commit 1a988f6e78684e024a19fd45c521ddcd8e7b76a7 Author: 이수준 Date: Mon Sep 11 10:56:25 2023 +0900 first commit diff --git a/bwc-init b/bwc-init new file mode 100755 index 0000000..d4c527e Binary files /dev/null and b/bwc-init differ diff --git a/device-control/config.yaml b/device-control/config.yaml new file mode 100644 index 0000000..37eb2aa --- /dev/null +++ b/device-control/config.yaml @@ -0,0 +1,3 @@ +assetcode: acode +devicetype: typecode +mqtturl: tcp://13.209.39.139:32259 \ No newline at end of file diff --git a/device-control/device-control b/device-control/device-control new file mode 100755 index 0000000..606e4b9 Binary files /dev/null and b/device-control/device-control differ diff --git a/device-control/device-control.service b/device-control/device-control.service new file mode 100644 index 0000000..cba4599 --- /dev/null +++ b/device-control/device-control.service @@ -0,0 +1,10 @@ +[Unit] +Description=device-control + +[Service] +ExecStart=/usr/local/bin/device-control +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target diff --git a/device-control/install.sh b/device-control/install.sh new file mode 100755 index 0000000..c2738d8 --- /dev/null +++ b/device-control/install.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +sudo mkdir -p /etc/sdt/device-control +sudo cp config.yaml /etc/sdt/device-control +sudo sed -i "s/acode/$1/g" /etc/sdt/device-control/config.yaml +sudo sed -i "s/typecode/$2/g" /etc/sdt/device-control/config.yaml +sudo cp device-control /usr/local/bin/ +sudo cp device-control.service /etc/systemd/system/ +sudo systemctl start device-control +sudo systemctl enable device-control \ No newline at end of file diff --git a/device-health/config.yaml b/device-health/config.yaml new file mode 100644 index 0000000..6f4d35d --- /dev/null +++ b/device-health/config.yaml @@ -0,0 +1,2 @@ +assetcode: acode +mqtturl: tcp://13.209.39.139:32259 \ No newline at end of file diff --git a/device-health/device-health b/device-health/device-health new file mode 100755 index 0000000..ad204bc Binary files /dev/null and b/device-health/device-health differ diff --git a/device-health/device-health.service b/device-health/device-health.service new file mode 100644 index 0000000..993b7f0 --- /dev/null +++ b/device-health/device-health.service @@ -0,0 +1,11 @@ +[Unit] +Description=DeviceHealth + +[Service] +User=root +ExecStart=/usr/local/bin/device-health +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target diff --git a/device-health/install.sh b/device-health/install.sh new file mode 100755 index 0000000..4f9a835 --- /dev/null +++ b/device-health/install.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +sudo mkdir -p /etc/sdt/device-health +sudo cp config.yaml /etc/sdt/device-health/ +sudo sed -i "s/acode/$1/g" /etc/sdt/device-health/config.yaml +sudo cp device-health /usr/local/bin/ +sudo cp device-health.service /etc/systemd/system/ +sudo systemctl start device-health +sudo systemctl enable device-health diff --git a/heartbeat/device-heartbeat b/heartbeat/device-heartbeat new file mode 100755 index 0000000..547a1f3 Binary files /dev/null and b/heartbeat/device-heartbeat differ diff --git a/heartbeat/device-heartbeat.service b/heartbeat/device-heartbeat.service new file mode 100644 index 0000000..f0dd8fd --- /dev/null +++ b/heartbeat/device-heartbeat.service @@ -0,0 +1,11 @@ +[Unit] +Description=DeviceHearthBeat + +[Service] +User=root +ExecStart=/usr/local/bin/device-heartbeat +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target diff --git a/heartbeat/install.sh b/heartbeat/install.sh new file mode 100755 index 0000000..3feb880 --- /dev/null +++ b/heartbeat/install.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +sudo cp device-heartbeat /usr/local/bin/ +sudo cp device-heartbeat.service /etc/systemd/system/ +sudo systemctl start device-heartbeat +sudo systemctl enable device-heartbeat diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..ce2fd67 --- /dev/null +++ b/init.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +set -e + +if [ $(id -u) -ne 0 ]; then + echo "Please run as root. - sudo su" + exit +elif [ $1 == "help" ]; then + echo "Please input parameter. follow as:" + echo "Example) Organzation ID=58a311aa-f52a-40e3-af44-cdec82b9d0b7 SerialNumbe=ECN-SJ-TEST-001 Type=ecn" + exit +fi + +echo "If you need help, please enter follow as:" +echo "./init.sh help" +read -p "Organzation ID(58a311aa-f52a-40e3-af44-cdec82b9d0b7): " oid +read -p "Serial Number(ECN-SJ-TEST-001): " acode +read -p "Type(ecn or nodeq): " etype + +echo "[INIT] [1] Start equipment registration" +./bwc-init -oid=$oid -acode=$acode +echo "[INIT] [1] Finish equipment registration" + +echo "[INIT] [2] Start install device-control" +cd device-control +./install.sh $acode $etype +echo "[INIT] [2] Finish install device-control" + +echo "[INIT] [3] Start install device-health" +cd ../device-health +./install.sh $acode +echo "[INIT] [3] Finish install device-health" + +echo "[INIT] [4] Start install device-heartbeat" +cd ../heartbeat +./install.sh +echo "[INIT] [4] Finish install device-heartbeat" + +echo "[INIT] [5] Start install process-checker" +cd ../process-checker +./install.sh +echo "[INIT] [5] Stop install process-checker" \ No newline at end of file diff --git a/process-checker/install.sh b/process-checker/install.sh new file mode 100755 index 0000000..185a56a --- /dev/null +++ b/process-checker/install.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +sudo cp process-checker /usr/local/bin/ +sudo cp process-checker.service /etc/systemd/system/ +sudo systemctl start process-checker +sudo systemctl enable process-checker diff --git a/process-checker/process-checker b/process-checker/process-checker new file mode 100755 index 0000000..0c31d74 Binary files /dev/null and b/process-checker/process-checker differ diff --git a/process-checker/process-checker.service b/process-checker/process-checker.service new file mode 100644 index 0000000..4f29de4 --- /dev/null +++ b/process-checker/process-checker.service @@ -0,0 +1,11 @@ +[Unit] +Description=processchecker + +[Service] +User=root +ExecStart=/usr/local/bin/process-checker +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target diff --git a/uninstall.sh b/uninstall.sh new file mode 100755 index 0000000..8186425 --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +set -e + +if [ $(id -u) -ne 0 ]; then + echo "Please run as root. - sudo su" + exit +fi + +echo "[INIT] Start uninstall device-control" +systemctl disable device-control +systemctl stop device-control +rm /etc/systemd/system/device-control.service +rm /usr/local/bin/device-control +rm -rf /etc/sdt/device-control +echo "[INIT] Finish uninstall device-control" + +echo "[INIT] Start uninstall device-health" +systemctl disable device-health +systemctl stop device-health +rm /etc/systemd/system/device-health.service +rm /usr/local/bin/device-health +rm -rf /etc/sdt/device-health +echo "[INIT] Finish uninstall device-health" + +echo "[INIT] Start uninstall device-heartbeat" +systemctl disable device-heartbeat +systemctl stop device-heartbeat +rm /etc/systemd/system/device-heartbeat.service +rm /usr/local/bin/device-heartbeat +echo "[INIT] Finish uninstall device-heartbeat" + +echo "[INIT] Start uninstall process-checker" +systemctl disable process-checker +systemctl stop process-checker +rm /etc/systemd/system/process-checker.service +rm /usr/local/bin/process-checker +echo "[INIT] Finish uninstall process-checker" + +echo "[INIT] Delete Cert Data" +rm -rf /etc/sdt/cert \ No newline at end of file