Skip to content

Commit

Permalink
build .deb
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiGVilbig committed Nov 23, 2023
1 parent 636e1a1 commit 9d46828
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 3 deletions.
5 changes: 5 additions & 0 deletions DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Package: leek-duck
Version: 0.0.1
Architecture: all
Maintainer: Kai G Vilbig
Description: LeekDuck scraper
6 changes: 6 additions & 0 deletions DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

apt-get update
apt-get install -y nodejs npm

npm install -g ts-node
9 changes: 9 additions & 0 deletions DEBIAN/postrm
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions DEBIAN/preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

useradd --system leek-duck
groupadd auto-services
usermod -a -G auto-services leek-duck
3 changes: 3 additions & 0 deletions DEBIAN/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
systemctl stop leek-duck
systemctl disable leek-duck
11 changes: 11 additions & 0 deletions DebianDockerfile
Original file line number Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

---

Expand Down
18 changes: 18 additions & 0 deletions buildDebian.bat
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions buildDebian.sh
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions buildTestDebian.bat
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
1 change: 1 addition & 0 deletions leek-duck.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9d46828

Please sign in to comment.