From ca1f99908e6d726397b416c1e171b492f7105d3d Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 4 Mar 2022 21:47:14 +0100 Subject: [PATCH] Add gitea --- ressources/authelia/authelia | 13 ++--- ressources/element-web/element-web | 13 ++--- ressources/gitea/gitea | 51 +++++++++++++++++++ ressources/gitea/rootfs/DEBIAN/changelog | 0 ressources/gitea/rootfs/DEBIAN/conffiles | 1 + ressources/gitea/rootfs/DEBIAN/control | 7 +++ ressources/gitea/rootfs/DEBIAN/postinst | 5 ++ ressources/gitea/rootfs/etc/gitea/.gitkeep | 0 .../rootfs/etc/systemd/system/gitea.service | 37 ++++++++++++++ ressources/gitea/rootfs/usr/bin/.gitkeep | 0 .../rootfs/var/lib/gitea/work_dir/.gitkeep | 0 11 files changed, 115 insertions(+), 12 deletions(-) create mode 100755 ressources/gitea/gitea create mode 100644 ressources/gitea/rootfs/DEBIAN/changelog create mode 100644 ressources/gitea/rootfs/DEBIAN/conffiles create mode 100644 ressources/gitea/rootfs/DEBIAN/control create mode 100755 ressources/gitea/rootfs/DEBIAN/postinst create mode 100644 ressources/gitea/rootfs/etc/gitea/.gitkeep create mode 100644 ressources/gitea/rootfs/etc/systemd/system/gitea.service create mode 100644 ressources/gitea/rootfs/usr/bin/.gitkeep create mode 100644 ressources/gitea/rootfs/var/lib/gitea/work_dir/.gitkeep diff --git a/ressources/authelia/authelia b/ressources/authelia/authelia index ea79119..770cef8 100755 --- a/ressources/authelia/authelia +++ b/ressources/authelia/authelia @@ -6,6 +6,7 @@ RELEASE=1 [ -e ./lib/function.sh ] && source ./lib/function.sh APP=authelia +DEPOT=https://github.com/authelia/authelia.git GIT_VERSION=v${VERSION} DEB_VERSION=${VERSION}-${RELEASE} DEBIAN_VERSION_CODENAME=bullseye @@ -30,13 +31,13 @@ envinit() { prebuild(){ [ -e /tmp/git ] && rm -fr /tmp/git - [ -e /tmp/element-web ] || mkdir /tmp/element-web - git clone --depth 1 -b ${GIT_VERSION} https://github.com/authelia/authelia.git /tmp/git - cp -r /tmp/git/. /tmp/authelia + [ -e /tmp/element-web ] || mkdir /tmp/${APP} + git clone --depth 1 -b ${GIT_VERSION} ${DEPOT} /tmp/git + cp -r /tmp/git/. /tmp/${APP} } build() { - cd /tmp/authelia/ + cd /tmp/${APP}/ PATH=$PATH:/usr/local/go/bin:/root/.local/share/pnpm ./cmd/authelia-scripts/authelia-scripts build } @@ -44,8 +45,8 @@ build() { makedeb(){ PATH_DEB=/tmp/src/rootfs - cp /tmp/authelia/dist/authelia ${PATH_DEB}/usr/bin/authelia - cp /tmp/authelia/config.template.yml ${PATH_DEB}/etc/authelia/configuration.yml + cp /tmp/${APP}/dist/authelia ${PATH_DEB}/usr/bin/authelia + cp /tmp/${APP}/config.template.yml ${PATH_DEB}/etc/authelia/configuration.yml sed -i "s/%VERSION%/$DEB_VERSION/" ${PATH_DEB}/DEBIAN/control fakeroot dpkg-deb -Z gzip --build ${PATH_DEB} /tmp/dist } diff --git a/ressources/element-web/element-web b/ressources/element-web/element-web index 9c82884..555201b 100755 --- a/ressources/element-web/element-web +++ b/ressources/element-web/element-web @@ -6,6 +6,7 @@ RELEASE=3 [ -e ./lib/function.sh ] && source ./lib/function.sh APP=element-web +DEPOT=https://github.com/vector-im/element-web.git /tmp/git GIT_VERSION=v${VERSION} DEB_VERSION=${VERSION}-${RELEASE} DEBIAN_VERSION_CODENAME=bullseye @@ -30,13 +31,13 @@ envinit() { prebuild(){ [ -e /tmp/git ] && rm -fr /tmp/git - [ -e /tmp/element-web ] || mkdir /tmp/element-web - git clone --depth 1 -b ${GIT_VERSION} https://github.com/vector-im/element-web.git /tmp/git - cp -r /tmp/git/. /tmp/element-web + [ -e /tmp/element-web ] || mkdir /tmp/${APP} + git clone --depth 1 -b ${GIT_VERSION} ${DEPOT} /tmp/git + cp -r /tmp/git/. /tmp/${APP} } build() { - cd /tmp/element-web + cd /tmp/${APP} yarn install yarn dist } @@ -44,8 +45,8 @@ build() { makedeb(){ PATH_DEB=/tmp/src/rootfs - tar -zxf /tmp/element-web/dist/element-${GIT_VERSION}-dirty.tar.gz --strip-components=1 -C ${PATH_DEB}/usr/share/element-web/ - cp /tmp/element-web/config.sample.json ${PATH_DEB}/etc/element-web/config.json + tar -zxf /tmp/${APP}/dist/element-${GIT_VERSION}-dirty.tar.gz --strip-components=1 -C ${PATH_DEB}/usr/share/element-web/ + cp /tmp/${APP}/config.sample.json ${PATH_DEB}/etc/element-web/config.json sed -i "s/%VERSION%/$DEB_VERSION/" ${PATH_DEB}/DEBIAN/control fakeroot dpkg-deb -Z gzip --build ${PATH_DEB} /tmp/dist } diff --git a/ressources/gitea/gitea b/ressources/gitea/gitea new file mode 100755 index 0000000..9107705 --- /dev/null +++ b/ressources/gitea/gitea @@ -0,0 +1,51 @@ +#!/bin/bash + +VERSION=1.16.3 +RELEASE=1 + +[ -e ./lib/function.sh ] && source ./lib/function.sh + +APP=gitea +DEPOT=https://github.com/go-gitea/gitea.git +GIT_VERSION=v${VERSION} +DEB_VERSION=${VERSION}-${RELEASE} +DEBIAN_VERSION_CODENAME=bullseye +IMAGE_SIZE=4 + +STEP="envinit prebuild build makedeb" + +envinit() { + if [ $(dpkg -l | grep -e 'ii nodejs ' | wc -l) -eq 1 ]; + then + apt-get update + apt-get dist-upgrade -y + else + apt install -y --no-install-recommends git wget ca-certificates dpkg fakeroot make gcc + wget -qO - https://deb.nodesource.com/setup_16.x | bash + apt-get update + apt-get install -y nodejs + wget -qO - https://go.dev/dl/go1.17.7.linux-amd64.tar.gz | tar -C /usr/local -xz + fi +} + +prebuild(){ + [ -e /tmp/git ] && rm -fr /tmp/git + [ -e /tmp/element-web ] || mkdir /tmp/${APP} + git clone --depth 1 -b ${GIT_VERSION} ${DEPOT} /tmp/git + cp -r /tmp/git/. /tmp/${APP} +} + +build() { + cd /tmp/${APP}/ + PATH=$PATH:/usr/local/go/bin + make +} + +makedeb(){ + PATH_DEB=/tmp/src/rootfs + + cp /tmp/${APP}/gitea ${PATH_DEB}/usr/bin/ + cp /tmp/${APP}/custom/conf/app.example.ini ${PATH_DEB}/etc/gitea/app.ini + sed -i "s/%VERSION%/$DEB_VERSION/" ${PATH_DEB}/DEBIAN/control + fakeroot dpkg-deb -Z gzip --build ${PATH_DEB} /tmp/dist +} diff --git a/ressources/gitea/rootfs/DEBIAN/changelog b/ressources/gitea/rootfs/DEBIAN/changelog new file mode 100644 index 0000000..e69de29 diff --git a/ressources/gitea/rootfs/DEBIAN/conffiles b/ressources/gitea/rootfs/DEBIAN/conffiles new file mode 100644 index 0000000..cce5639 --- /dev/null +++ b/ressources/gitea/rootfs/DEBIAN/conffiles @@ -0,0 +1 @@ +/etc/gitea/app.ini diff --git a/ressources/gitea/rootfs/DEBIAN/control b/ressources/gitea/rootfs/DEBIAN/control new file mode 100644 index 0000000..4b40b3e --- /dev/null +++ b/ressources/gitea/rootfs/DEBIAN/control @@ -0,0 +1,7 @@ +Package: gitea +Version: %VERSION% +Section: base +Priority: optional +Architecture: all +Maintainer: Thomas Legay +Description: gitea diff --git a/ressources/gitea/rootfs/DEBIAN/postinst b/ressources/gitea/rootfs/DEBIAN/postinst new file mode 100755 index 0000000..7c45414 --- /dev/null +++ b/ressources/gitea/rootfs/DEBIAN/postinst @@ -0,0 +1,5 @@ +#!/bin/bash + +id gitea &> /dev/null || useradd gitea -r -s /bin/false -d /var/lib/gitea/ + +chown -R gitea:gitea /var/lib/gitea/ diff --git a/ressources/gitea/rootfs/etc/gitea/.gitkeep b/ressources/gitea/rootfs/etc/gitea/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/ressources/gitea/rootfs/etc/systemd/system/gitea.service b/ressources/gitea/rootfs/etc/systemd/system/gitea.service new file mode 100644 index 0000000..ffd6d06 --- /dev/null +++ b/ressources/gitea/rootfs/etc/systemd/system/gitea.service @@ -0,0 +1,37 @@ +[Unit] +Description=Gitea (Git with a cup of tea) +After=syslog.target +After=network.target + +[Service] +# Modify these two values and uncomment them if you have +# repos with lots of files and get an HTTP error 500 because +# of that +### +#LimitMEMLOCK=infinity +#LimitNOFILE=65535 +RestartSec=2s +Type=simple +User=git +Group=git +WorkingDirectory=/var/lib/gitea/work_dir +# If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file +# (manually creating /run/gitea doesn't work, because it would not persist across reboots) +#RuntimeDirectory=gitea +ExecStart=/usr/bin/gitea web --config /etc/gitea/app.ini +Restart=always +Environment=USER=git HOME=/var/lib/gitea/ GITEA_WORK_DIR=/var/lib/gitea/work_dir +# If you install Git to directory prefix other than default PATH (which happens +# for example if you install other versions of Git side-to-side with +# distribution version), uncomment below line and add that prefix to PATH +# Don't forget to place git-lfs binary on the PATH below if you want to enable +# Git LFS support +# If you want to bind Gitea to a port below 1024, uncomment +# the two values below, or use socket activation to pass Gitea its ports as above +### +#CapabilityBoundingSet=CAP_NET_BIND_SERVICE +#AmbientCapabilities=CAP_NET_BIND_SERVICE +### + +[Install] +WantedBy=multi-user.target diff --git a/ressources/gitea/rootfs/usr/bin/.gitkeep b/ressources/gitea/rootfs/usr/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/ressources/gitea/rootfs/var/lib/gitea/work_dir/.gitkeep b/ressources/gitea/rootfs/var/lib/gitea/work_dir/.gitkeep new file mode 100644 index 0000000..e69de29