diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rwxr-xr-x | mkosi.build | 13 | ||||
-rw-r--r-- | mkosi.default | 28 | ||||
-rw-r--r-- | mkosi.nspawn | 15 | ||||
-rwxr-xr-x | mkosi.postinst | 16 | ||||
-rw-r--r-- | mkosi.skeleton/etc/systemd/system/filebin.service | 33 |
6 files changed, 107 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3dff6a2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# mkosi cache +mkosi.cache/* diff --git a/mkosi.build b/mkosi.build new file mode 100755 index 0000000..1956aa9 --- /dev/null +++ b/mkosi.build @@ -0,0 +1,13 @@ +#!/bin/sh + +cd $SRCDIR +mkdir src bin pkg +export GOPATH="${SRCDIR}" +export PATH="${PATH}:${GOPATH}/bin" +go get -d github.com/espebra/filebin +cd ${GOPATH}/src/github.com/espebra/filebin +make get-deps +make install + + +mv ${SRCDIR}/bin ${DESTDIR}/go diff --git a/mkosi.default b/mkosi.default new file mode 100644 index 0000000..ae33479 --- /dev/null +++ b/mkosi.default @@ -0,0 +1,28 @@ +[Distribution] +Distribution=ubuntu +Release=bionic +Repositories=main,universe +Mirror=http://no.archive.ubuntu.com + +[Output] +Format=directory +Output=/var/lib/machines/filebin + +[Packages] +WithNetwork=yes +BuildPackages= + git + golang + make +Packages= + iputils-ping + vim + curl + iproute2 + dnsutils + net-tools + ca-certificates + locales + openssl + vim + wget diff --git a/mkosi.nspawn b/mkosi.nspawn new file mode 100644 index 0000000..260f654 --- /dev/null +++ b/mkosi.nspawn @@ -0,0 +1,15 @@ +[Exec] +Hostname=filebin +ResolvConf=copy-host +Timezone=copy +PrivateUsers=pick +NoNewPrivileges=yes + +[Files] +PrivateUsersChown=yes +Bind=/var/log/filebin/access.log +Bind=/var/local/filebin/files:/var/lib/filebin/files + +[Network] +VirtualEthernet=no + diff --git a/mkosi.postinst b/mkosi.postinst new file mode 100755 index 0000000..942ccb4 --- /dev/null +++ b/mkosi.postinst @@ -0,0 +1,16 @@ +#!/bin/sh +set -ex + +export DEBIAN_FRONTEND=noninteractive + +# locales +sed -i 's/# en_IE.UTF-8 UTF-8/en_IE.UTF-8 UTF-8/' /etc/locale.gen +locale-gen + +useradd --system --shell /usr/sbin/nologin --home-dir /var/lib/filebin --create-home --user-group filebin + +mkdir /tmp/filebin /var/log/filebin +chown filebin: /tmp/filebin /var/log/filebin +chmod 700 /tmp/filebin /var/log/filebin + +systemctl enable filebin.service diff --git a/mkosi.skeleton/etc/systemd/system/filebin.service b/mkosi.skeleton/etc/systemd/system/filebin.service new file mode 100644 index 0000000..b7c557f --- /dev/null +++ b/mkosi.skeleton/etc/systemd/system/filebin.service @@ -0,0 +1,33 @@ +# From https://github.com/espebra/filebin/blob/master/etc/systemd/filebin.service.example + +[Unit] +Description=Filebin +Requires=network.target +After=network.target + +[Service] +ExecStart=/go/filebin \ + --filedir /var/lib/filebin/files \ + --tempdir /tmp \ + --baseurl https://f.dnns.no \ + --port 8304 \ + --access-log /var/log/filebin/access.log \ + --expiration 604800 +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=filebin +PrivateTmp=true +ProtectSystem=strict +ProtectHome=true +ProtectKernelTunables=true +ProtectControlGroups=true +ProtectKernelModules=true +InaccessiblePaths=/etc /home /opt /srv /var/local /var/mail +BindPaths=/var/log/filebin /var/lib/filebin +RemoveIPC=true +User=filebin +Group=filebin +Restart=on-failure + +[Install] +WantedBy=multi-user.target |