From 0b2d809cc8bbd5fea2ea1690ae502cece30dfca7 Mon Sep 17 00:00:00 2001 From: leafee98 Date: Tue, 1 Nov 2022 03:08:44 -0400 Subject: [PATCH] add filebrowser build script --- filebrowser/filebrowser.sh | 70 +++++++++++++++++++++++ filebrowser/materials/filebrowser.service | 15 +++++ 2 files changed, 85 insertions(+) create mode 100644 filebrowser/filebrowser.sh create mode 100644 filebrowser/materials/filebrowser.service diff --git a/filebrowser/filebrowser.sh b/filebrowser/filebrowser.sh new file mode 100644 index 0000000..bcc3330 --- /dev/null +++ b/filebrowser/filebrowser.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +version="${1:?You need to specific a version, eg: v1.22.2}" +version_num="${version##v}" + +# must occur dirs +material_dir="./materials" + +# optional dirs (created during build) +download_dir="./downloads" +package_dir="./packages" +extract_dir="./extracted" +rootfs="./rootfs" + +package_name=filebrowser-${version_num}.tar.gz + + +function copy_file { + local src="$1" + local dst="$2" + + # if ends with a splash + if [[ "$dst" == */ ]] ; then + mkdir -p $dst + cp --target-directory $dst $src + else + local dst_dir=$(dirname $dst) + + mkdir -p $dst_dir + cp --no-target-directory $src $dst + fi + +} + + +# don't re-download if already downloaded +if [ ! -f "${download_dir}/${package_name}" ] ; then + mkdir -p ${download_dir} + wget --output-document ${download_dir}/${package_name} https://github.com/filebrowser/filebrowser/releases/download/${version}/linux-amd64-filebrowser.tar.gz +fi + +rm -rf ${extract_dir} +mkdir -p ${extract_dir} +tar -xf ${download_dir}/${package_name} -C ${extract_dir} + +# clean rootfs +rm -rf ${rootfs} + +# move files +copy_file ${extract_dir}/filebrowser ${rootfs}/usr/bin/filebrowser + +copy_file ${extract_dir}/CHANGELOG.md ${rootfs}/usr/share/filebrowser/ +copy_file ${extract_dir}/LICENSE ${rootfs}/usr/share/filebrowser/ +copy_file ${extract_dir}/README.md ${rootfs}/usr/share/filebrowser/ + +copy_file ${material_dir}/filebrowser.service ${rootfs}/usr/lib/systemd/system/filebrowser.service + +# debian packages meta file +mkdir -p $rootfs/DEBIAN +sed "s/+++VERSION+++/${version_num}/" > $rootfs/DEBIAN/control << EOF +Package: filebrowser +Version: +++VERSION+++ +Priority: optional +Architecture: all +Maintainer: leafee98 +Description: Web File Browser +EOF + +mkdir -p $package_dir +dpkg-deb --build --root-owner-group $rootfs $package_dir/filebrowser-${version}.deb diff --git a/filebrowser/materials/filebrowser.service b/filebrowser/materials/filebrowser.service new file mode 100644 index 0000000..a880b4b --- /dev/null +++ b/filebrowser/materials/filebrowser.service @@ -0,0 +1,15 @@ +[Unit] +Description=Filebrowser is a Web File Browser +After=network.target apache2.service + +[Service] +# User=filebrowser +# Group=filebrowser + +WorkingDirectory=/var/lib/filebrowser + +ExecStart=/usr/bin/filebrowser -r /path/to/your/storage +Restart=on-failure + +[Install] +WantedBy=multi-user.target