From 9d46828c9d91767d3f13685600a19ae9526b3c9d Mon Sep 17 00:00:00 2001 From: Kai Date: Thu, 23 Nov 2023 15:13:04 -0500 Subject: [PATCH] build .deb --- DEBIAN/control | 5 +++++ DEBIAN/postinst | 6 ++++++ DEBIAN/postrm | 9 +++++++++ DEBIAN/preinst | 5 +++++ DEBIAN/prerm | 3 +++ DebianDockerfile | 11 +++++++++++ README.md | 8 +++++--- buildDebian.bat | 18 ++++++++++++++++++ buildDebian.sh | 5 +++++ buildTestDebian.bat | 14 ++++++++++++++ buildTest.bat => buildTestRPM.bat | 0 leek-duck.spec | 1 + 12 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 DEBIAN/control create mode 100644 DEBIAN/postinst create mode 100644 DEBIAN/postrm create mode 100644 DEBIAN/preinst create mode 100644 DEBIAN/prerm create mode 100644 DebianDockerfile create mode 100644 buildDebian.bat create mode 100644 buildDebian.sh create mode 100644 buildTestDebian.bat rename buildTest.bat => buildTestRPM.bat (100%) diff --git a/DEBIAN/control b/DEBIAN/control new file mode 100644 index 0000000..be2235e --- /dev/null +++ b/DEBIAN/control @@ -0,0 +1,5 @@ +Package: leek-duck +Version: 0.0.1 +Architecture: all +Maintainer: Kai G Vilbig +Description: LeekDuck scraper diff --git a/DEBIAN/postinst b/DEBIAN/postinst new file mode 100644 index 0000000..f749448 --- /dev/null +++ b/DEBIAN/postinst @@ -0,0 +1,6 @@ +#!/bin/bash + +apt-get update +apt-get install -y nodejs npm + +npm install -g ts-node \ No newline at end of file diff --git a/DEBIAN/postrm b/DEBIAN/postrm new file mode 100644 index 0000000..9868a52 --- /dev/null +++ b/DEBIAN/postrm @@ -0,0 +1,9 @@ +#!/bin/bash + +userdel -r leek-duck +if [ "$1" = "0" ]; then + rm -rf /opt/auto/LeekDuck + rm -f /etc/systemd/system/leek-duck.service +fi +systemctl daemon-reload +userdel leek-duck \ No newline at end of file diff --git a/DEBIAN/preinst b/DEBIAN/preinst new file mode 100644 index 0000000..8dc5e11 --- /dev/null +++ b/DEBIAN/preinst @@ -0,0 +1,5 @@ +#!/bin/bash + +useradd --system leek-duck +groupadd auto-services +usermod -a -G auto-services leek-duck diff --git a/DEBIAN/prerm b/DEBIAN/prerm new file mode 100644 index 0000000..cc92720 --- /dev/null +++ b/DEBIAN/prerm @@ -0,0 +1,3 @@ +#!/bin/bash +systemctl stop leek-duck +systemctl disable leek-duck diff --git a/DebianDockerfile b/DebianDockerfile new file mode 100644 index 0000000..e400526 --- /dev/null +++ b/DebianDockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:latest + +ARG DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + sudo \ + && rm -rf /var/lib/apt/lists/* + +COPY /buildDebian.sh / + +ENTRYPOINT /buildDebian.sh \ No newline at end of file diff --git a/README.md b/README.md index b33e833..3d612fa 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,12 @@ - Uses a [Cronjob](https://en.wikipedia.org/wiki/Cron) to execute once every day - Only fetch once a day as to not overwhelm [LeekDuck](https://leekduck.com) - Only checking once a day is necessary since events aren't being announced every minute -- Can be built as an [RPM](https://en.wikipedia.org/wiki/RPM_Package_Manager) to install to Linux -- RPMs will be built as a [Linux Service](https://www.imaginelinux.com/service-in-linux/) and will run on boot and restart on failure +- Can be built as an [RPM](https://en.wikipedia.org/wiki/RPM_Package_Manager) to install to RPM based Linux distributions +- Can also be build as a [Debian package](https://en.wikipedia.org/wiki/Deb_(file_format)) to install on debian based distributions +- RPMs and Deb packages will be built as a [Linux Service](https://www.imaginelinux.com/service-in-linux/) and will run on boot and restart on failure - Uses [Docker](https://aws.amazon.com/docker/) and [CentOS](https://www.redhat.com/en/topics/linux/what-is-centos) to build the RPM -- The /tests directory contains a test index.ts file for testing the building, installing, running and unsinstalling the RPM package as a service +- Uses Docker and [Ubuntu](https://en.wikipedia.org/wiki/Ubuntu) to build the .deb +- The /tests directory contains a test index.ts file for testing the building, installing, running and unsinstalling the RPM and Debian packages as a service --- diff --git a/buildDebian.bat b/buildDebian.bat new file mode 100644 index 0000000..8ce8006 --- /dev/null +++ b/buildDebian.bat @@ -0,0 +1,18 @@ +docker build -f DebianDockerfile --cache-from debianbuilder -t debianbuilder . +rmdir shared /s /q +mkdir shared\opt\auto\LeekDuck\node_modules +mkdir shared\etc\systemd\system + +xcopy /s node_modules shared\opt\auto\LeekDuck\node_modules +xcopy /s /I DEBIAN shared\DEBIAN +copy connectMango.tsx shared\opt\auto\LeekDuck +copy dbOps.ts shared\opt\auto\LeekDuck +copy duckInferface.ts shared\opt\auto\LeekDuck +copy duckModel.tsx shared\opt\auto\LeekDuck +copy index.ts shared\opt\auto\LeekDuck +copy package-lock.json shared\opt\auto\LeekDuck +copy package.json shared\opt\auto\LeekDuck +copy tsconfig.json shared\opt\auto\LeekDuck +copy leek-duck.service shared\etc\systemd\system\ + +docker run --rm -it -v E:\Projects\Home_auto\checkLeekDuck\shared:/leek-duck_0.0.1_all debianbuilder diff --git a/buildDebian.sh b/buildDebian.sh new file mode 100644 index 0000000..caf82a5 --- /dev/null +++ b/buildDebian.sh @@ -0,0 +1,5 @@ +chmod -R 755 leek-duck_0.0.1_all/DEBIAN + +dpkg-deb --build leek-duck_0.0.1_all + +mv leek-duck_0.0.1_all.deb leek-duck_0.0.1_all/leek-duck_0.0.1_all.deb \ No newline at end of file diff --git a/buildTestDebian.bat b/buildTestDebian.bat new file mode 100644 index 0000000..1d1cf95 --- /dev/null +++ b/buildTestDebian.bat @@ -0,0 +1,14 @@ +docker build -f DebianDockerfile --cache-from debianbuilder -t debianbuilder . +rmdir shared /s /q +mkdir shared\opt\auto\LeekDuck\node_modules +mkdir shared\etc\systemd\system + +xcopy /s node_modules shared\opt\auto\LeekDuck\node_modules +xcopy /s /I DEBIAN shared\DEBIAN +copy tests\index.ts shared\opt\auto\LeekDuck +copy package-lock.json shared\opt\auto\LeekDuck +copy package.json shared\opt\auto\LeekDuck +copy tsconfig.json shared\opt\auto\LeekDuck +copy leek-duck.service shared\etc\systemd\system\ + +docker run --rm -it -v E:\Projects\Home_auto\checkLeekDuck\shared:/leek-duck_0.0.1_all debianbuilder diff --git a/buildTest.bat b/buildTestRPM.bat similarity index 100% rename from buildTest.bat rename to buildTestRPM.bat diff --git a/leek-duck.spec b/leek-duck.spec index 8df5c05..afcaa97 100644 --- a/leek-duck.spec +++ b/leek-duck.spec @@ -50,6 +50,7 @@ systemctl stop leek-duck systemctl disable leek-duck %postun +userdel -r leek-duck if [ "$1" = "0" ]; then rm -rf /opt/auto/LeekDuck rm -f /etc/systemd/system/leek-duck.service