-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
87 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,7 @@ jobs: | |
# with: | ||
# name: test-results | ||
# path: pytest-report.xml | ||
# | ||
- name: Build deb | ||
run: | | ||
make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,3 @@ | ||
# Byte-compiled files | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
__pycache__/ | ||
|
||
# Virtual environment | ||
/venv/ | ||
/.env/ | ||
|
||
# Distribution files | ||
/build/ | ||
/dist/ | ||
/*.egg-info/ | ||
|
||
# System-specific files (can appear anywhere) | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# IDE and editor files | ||
/.vscode/ | ||
/.idea/ | ||
*.swp | ||
*.swo | ||
|
||
# Test artifacts (can appear anywhere) | ||
*.coverage | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.pytest_cache/ | ||
.cache/ | ||
.mypy_cache/ | ||
.pyre/ | ||
dmypy.json | ||
|
||
# Uploaded files (specific to this project) | ||
*.deb | ||
/uploads/ | ||
/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
default: build-deb | ||
|
||
.PHONY: run | ||
run: pypltagent-eth.py | ||
python3 ./pypltagent-eth.py | ||
|
||
|
||
# See the rootless-builds.txt in dpkg-dev. | ||
.PHONY: build-deb | ||
build-deb: | ||
mkdir -p build/pypltagent/usr/bin | ||
cp pypltagent-eth.py build/pypltagent/usr/bin/pypltagent-eth | ||
chmod +x build/pypltagent/usr/bin/pypltagent-eth | ||
|
||
mkdir -p build/pypltagent/DEBIAN | ||
cp debian/control build/pypltagent/DEBIAN/ | ||
cp debian/postinst build/pypltagent/DEBIAN/ | ||
cp debian/prerm build/pypltagent/DEBIAN/ | ||
|
||
mkdir -p build/pypltagent/lib/systemd/system | ||
cp debian/pypltagent.service build/pypltagent/lib/systemd/system/ | ||
dpkg-deb --build --root-owner-group build/pypltagent | ||
mv build/pypltagent.deb pypltagent.noarch.deb | ||
rm -rf build | ||
|
||
.PHONY: stub | ||
stub: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Package: pypltagent | ||
Version: 1.0 | ||
Section: utils | ||
Priority: optional | ||
Architecture: all | ||
Maintainer: Blue Clover <support@bcdevices.com> | ||
Depends: python3, systemd | ||
Description: A Python script for PLT agent | ||
This script helps manage PLT agent operations via ethernet.his script helps manage PLT agent operations via ethernet. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Ensure the 'pltagent' user exists | ||
if ! id -u pltagent > /dev/null 2>&1; then | ||
useradd -r -s /usr/sbin/nologin -G plugdev pltagent | ||
echo "User 'pltagent' created and added to 'plugdev' group." | ||
fi | ||
|
||
mkdir -p /var/run/pltagent/uploads | ||
chown -R pltagent:plugdev /var/run/pltagent/uploads | ||
|
||
# Reload systemd to recognize the new service | ||
systemctl daemon-reload | ||
|
||
# Enable and start the service | ||
systemctl enable pypltagent.service | ||
systemctl start pypltagent.service | ||
|
||
echo "pypltagent service installed and started." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Stop and disable the service | ||
systemctl stop pypltagent.service || true | ||
systemctl disable pypltagent.service || true | ||
|
||
echo "pypltagent service stopped and disabled." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[Unit] | ||
Description=PLT Agent Ethernet Service | ||
After=network.target | ||
|
||
[Service] | ||
ExecStart=/usr/bin/pypltagent-eth | ||
Restart=always | ||
User=pltagent | ||
Group=plugdev | ||
Environment=PYTHONUNBUFFERED=1 | ||
#WorkingDirectory=/usr/bin | ||
WorkingDirectory=/var/run/pltagent | ||
ExecStartPre=/bin/mkdir -p /var/run/pltagent/uploads | ||
ExecStartPre=/bin/chown -R pltagent:plugdev /var/run/pltagent/uploads | ||
|
||
[Install] | ||
WantedBy=multi-user.target |