From d71fcdf7020f043406e4113d9e7ffde52f31618d Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 18 Jan 2023 01:56:13 +0100 Subject: [PATCH] Add linkding --- ressources/linkding/README.MD | 20 ++++++++ ressources/linkding/debmaker | 55 +++++++++++++++++++++ ressources/linkding/linkding.service | 16 ++++++ ressources/linkding/rootfs/DEBIAN/changelog | 0 ressources/linkding/rootfs/DEBIAN/conffiles | 1 + ressources/linkding/rootfs/DEBIAN/control | 8 +++ ressources/linkding/rootfs/DEBIAN/postinst | 19 +++++++ 7 files changed, 119 insertions(+) create mode 100644 ressources/linkding/README.MD create mode 100755 ressources/linkding/debmaker create mode 100644 ressources/linkding/linkding.service create mode 100644 ressources/linkding/rootfs/DEBIAN/changelog create mode 100644 ressources/linkding/rootfs/DEBIAN/conffiles create mode 100644 ressources/linkding/rootfs/DEBIAN/control create mode 100755 ressources/linkding/rootfs/DEBIAN/postinst diff --git a/ressources/linkding/README.MD b/ressources/linkding/README.MD new file mode 100644 index 0000000..9cbe132 --- /dev/null +++ b/ressources/linkding/README.MD @@ -0,0 +1,20 @@ +#### linkding + +##### Information +Site : https://github.com/sissbruecker/linkding + +Source : https://github.com/sissbruecker/linkding + +##### Install + +```bash +apt install -y wget ca-certificates +wget -qO - https://deb.lgy.fr/install.sh | bash +apt-get update +apt-get install -y linkding + +su - -s /usr/bin/bash linkding -c "export LD_SUPERUSER_NAME=thomas;export LD_SUPERUSER_PASSWORD=supertoto;python /usr/share/linkding/manage.py create_initial_superuser" + +systemctl enable --now linkding + +``` diff --git a/ressources/linkding/debmaker b/ressources/linkding/debmaker new file mode 100755 index 0000000..167d79a --- /dev/null +++ b/ressources/linkding/debmaker @@ -0,0 +1,55 @@ +#!/bin/bash + +VERSION=1.15.1 +APP=linkding +DEPOT=https://github.com/sissbruecker/linkding +GIT_VERSION=last +DEB_VERSION=${VERSION}-$(date +%Y%m%d%H%M) +DEBIAN_VERSION_CODENAME=bookworm +IMAGE_SIZE=6 +PACKAGE_DEPENDENCY="nodejs python-is-python3 python3-pip" + +main(){ + base_package_upgrade + envinit + get_git_source + build + makedeb +} + +envinit() { + configure_depot_nodejs + install_package_dependency +} + +build() { + cd /tmp/${APP}/ + pip3 install -r requirements.txt + npm install + npm run build + python manage.py compilescss + python manage.py collectstatic --ignore=*.scss +} + +makedeb(){ + PATH_DEB=/tmp/src/rootfs + + cd /tmp/${APP}/ + + mkdir -p ${PATH_DEB}/usr/share/linkding/ + cp -pfr bookmarks siteroot assets static node_modules manage.py requirements.prod.txt requirements.txt ${PATH_DEB}/usr/share/linkding/ + + mkdir -p ${PATH_DEB}/etc/default + cp -p .env.sample ${PATH_DEB}/etc/default/linkding + + mkdir -p ${PATH_DEB}/var/lib/linkding/data + ln -s /var/lib/linkding/data ${PATH_DEB}/usr/share/linkding/data + + cp version.txt ${PATH_DEB}/var/lib/linkding/ + + mkdir -p ${PATH_DEB}/usr/lib/systemd/system/ + cp -p /tmp/src//linkding.service ${PATH_DEB}/usr/lib/systemd/system/ + + sed -i "s/%VERSION%/$DEB_VERSION/" ${PATH_DEB}/DEBIAN/control + fakeroot dpkg-deb -Z gzip --build ${PATH_DEB} /tmp/dist +} diff --git a/ressources/linkding/linkding.service b/ressources/linkding/linkding.service new file mode 100644 index 0000000..820c506 --- /dev/null +++ b/ressources/linkding/linkding.service @@ -0,0 +1,16 @@ +[Unit] +Description=linkding +After=network.target + +[Service] +EnvironmentFile=/etc/default/linkding +ExecStart=/usr/bin/python3 /usr/share/linkding/manage.py runserver 0.0.0.0:8000 +WorkingDirectory=/var/lib/linkding +StandardOutput=inherit +StandardError=inherit +Restart=always +User=linkding +Group=linkding + +[Install] +WantedBy=multi-user.target diff --git a/ressources/linkding/rootfs/DEBIAN/changelog b/ressources/linkding/rootfs/DEBIAN/changelog new file mode 100644 index 0000000..e69de29 diff --git a/ressources/linkding/rootfs/DEBIAN/conffiles b/ressources/linkding/rootfs/DEBIAN/conffiles new file mode 100644 index 0000000..3900fa1 --- /dev/null +++ b/ressources/linkding/rootfs/DEBIAN/conffiles @@ -0,0 +1 @@ +/etc/default/linkding diff --git a/ressources/linkding/rootfs/DEBIAN/control b/ressources/linkding/rootfs/DEBIAN/control new file mode 100644 index 0000000..a9b9d95 --- /dev/null +++ b/ressources/linkding/rootfs/DEBIAN/control @@ -0,0 +1,8 @@ +Package: linkding +Version: %VERSION% +Section: contrib +Priority: optional +Architecture: all +Depends: python3 ( >= 3.10 ), python-is-python3, python3-pip, build-essential, python3-dev +Maintainer: Thomas Legay +Description: linkding diff --git a/ressources/linkding/rootfs/DEBIAN/postinst b/ressources/linkding/rootfs/DEBIAN/postinst new file mode 100755 index 0000000..87d0fa2 --- /dev/null +++ b/ressources/linkding/rootfs/DEBIAN/postinst @@ -0,0 +1,19 @@ +#!/bin/bash + +#Allready create on package then no -md +id linkding &> /dev/null || useradd linkding -r -s /bin/false -d /var/lib/linkding + +chown linkding:linkding /var/lib/linkding -R + +#Need to be remove because usr need to be in read only +chown linkding:linkding /usr/share/linkding/bookmarks/static -R + +su - -s /usr/bin/bash linkding -c "pip3 install -r /usr/share/linkding/requirements.txt --no-warn-script-location" + +#Upgrade Database +su - -s /usr/bin/bash linkding -c "python /usr/share/linkding/manage.py migrate" + +#Create secret +su - -s /usr/bin/bash linkding -c "python /usr/share/linkding/manage.py generate_secret_key" + +