Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ffp-bot committed Dec 21, 2024
1 parent e6408d2 commit 28f477f
Show file tree
Hide file tree
Showing 13 changed files with 252 additions and 144 deletions.
28 changes: 28 additions & 0 deletions sambanas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Changelog

## 12.3.2-nas1 [ 🚧 Unreleased ]

### 🎉 NEWS NEWS 🎉
Today, I'm excited to introduce SRAT, our new web interface designed to simplify SambaNAS configuration and management.

SRAT is a game-changer for SambaNAS administrators. It offers an intuitive interface that streamlines tasks, from setting up shares to monitoring system health.

SRAT is still under development, but we're excited about the future. We're actively seeking feedback and contributions from the community to make SRAT even better.

### ✨ Features
- [X] New UI (SRAT) to read and control the addon. (See [SRAT Repository](https://github.com/dianlight/srat) )
- [X] New option `update_srat_onstart`to manage SRAT Update (EXPERIMENTAL [DOCS](DOCS.md) )
###### __🚧 Work in progess__
- [ ] New Admin Panel ( SRAT ) **Experimantal**
- [ ] ACL For foleders [#208](https://github.com/dianlight/hassio-addons/issues/208)

### 🩹 BugFix
- [X] Build for armv7 arch Fix: [#288](https://github.com/dianlight/hassio-addons/issues/288)]
##### __🚧 Work in progess__
- [ ] MQTT Entities sometime are not deleted on close
- [ ] Volumes with whitespace in label [#285](https://github.com/dianlight/hassio-addons/issues/285)

### 🏗 Chore
- [X] Better CI and Change scripts
- [X] Remove HDDTEMP for deprecation [#265](https://github.com/dianlight/hassio-addons/issues/265)
- [X] Update Based Image to 16.3.6 (Alpine 3.21.0, Samba 4.20.6-r1)
- [X] WSDD2. Use patch from openwrt to compile on GCC14 and 64bit

## 12.3.2-nas

### ✨ Features
Expand Down
11 changes: 11 additions & 0 deletions sambanas/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,17 @@ Setting this option to `true` will disable the delete of MQTT discovery messages

Defaults to `false`.

### Options `update_srat_onstart` (optional) **_Exteprimental_**

SRAT (Samba REST Administration Tool) is a new system designed to provide a simplified user interface for configuring SAMBA. It has been developed to work within Home Assistant, specifically for this addon, but can also be used in other contexts.

Currently under development and in an alpha state, SRAT is set to become the preferred system for configuring and using this addon, eventually "retiring" the YAML configuration.

Setting this option to `release` or `prerelease` turn on the auto update of srat ( Samba Rest Adminitration Tool )
on the choosed channel.

Defaults to `no`

## Support

### Do you like the Addon?
Expand Down
65 changes: 32 additions & 33 deletions sambanas/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,44 @@ ARG BUILD_REF
ARG BUILD_REPOSITORY
ARG BUILD_VERSION

ARG HDDTEMP_VERSION
#ARG HDDTEMP_VERSION

# hadolint ignore=DL3006
FROM $BUILD_FROM as builder

SHELL ["/bin/bash", "-eo", "pipefail", "-c"]
RUN apk add --no-cache make \
gcc libc-dev linux-headers build-base autoconf automake git \
python3-dev musl-dev poetry
python3-dev musl-dev poetry go lsblk eudev

ARG BUILD_ARCH
ARG HDDTEMP_VERSION

RUN cd / && wget -q -O - "http://download.savannah.nongnu.org/releases/hddtemp/hddtemp-${HDDTEMP_VERSION}.tar.bz2" | tar jxvf - \
&& cd "hddtemp-${HDDTEMP_VERSION}" && ./configure --build=${BUILD_ARCH}-unknown-linux-gnu && make && find /hddtemp-${HDDTEMP_VERSION} -name "hddtemp"

RUN cd / && wget -q -O - "https://github.com/Netgear/wsdd2/archive/refs/heads/master.tar.gz" | tar zxvf - \
&& cd wsdd2-master && make
&& cd wsdd2-master \
&& wget -q -O - https://raw.githubusercontent.com/openwrt/packages/refs/heads/master/net/wsdd2/patches/010-gcc14.patch | patch -p1 \
&& make

COPY rootfs /
RUN cd /usr/local/bin/ && \
if [ "$BUILD_ARCH" == "armv7" ]; then \
export PIP_NO_BINARY="pyyaml" ; \
fi && \
poetry install

#RUN cd / && git clone https://github.com/linux-apfs/linux-apfs-rw.git \
# && cd linux-apfs-rw && make
# SRAT // DON'T ON ARMv7 WORK USE RELESES!
#COPY /Users/ltarantino/Documents/Source/srat/backend/dist/srat /srat
#RUN \
# if [ "$BUILD_ARCH" != "armv7" ]; then \
# cd / && git clone https://github.com/dianlight/srat.git \
# && GOBIN=/usr/local/bin/ go install github.com/swaggo/swag/cmd/swag@latest \
# && wget -q -O - https://bun.sh/install | bash \
# && export BUN_INSTALL="$HOME/.bun" \
# && export PATH="$BUN_INSTALL/bin:$PATH" \
# && cd srat && make AARGS="$(AARGS)" SUFFIX="$(SUFFIX)" VERSION=$(VERSION) \
# && pwd; \
# else \
# mkdir -p /srat/backend/dist && touch /srat/backend/dist/srat; \
# fi

# hadolint ignore=DL3006
FROM ${BUILD_FROM}
Expand Down Expand Up @@ -63,6 +76,7 @@ ENV S6_SYNC_DISKS=1
# Setup base
ARG BUILD_ARCH
ARG CLI_VERSION
ARG SRAT_VERSION
RUN apk add --no-cache \
samba-common-tools \
samba-server \
Expand Down Expand Up @@ -97,21 +111,21 @@ RUN apk add --no-cache \
fuse3 \
py3-pip \
pipx \
poetry
poetry \
lsblk

RUN if [ "$BUILD_ARCH" != "armv7" ]; then apk add --no-cache apfs-fuse;fi

# HDDTEMP
ARG HDDTEMP_VERSION
COPY --from=builder /hddtemp-${HDDTEMP_VERSION}/src/hddtemp /usr/sbin
RUN curl http://download.savannah.nongnu.org/releases/hddtemp/hddtemp.db -Lso /usr/share/misc/hddtemp.db

# WSDD2
COPY --from=builder /wsdd2-master/wsdd2 /usr/sbin

# SAMBANAS UTILS (POERTY VIRTUAL ENV)
COPY --from=builder /root/.cache/pypoetry /root/.cache/pypoetry

# HA API
RUN curl -Lso /usr/bin/ha "https://github.com/home-assistant/cli/releases/download/${CLI_VERSION}/ha_${BUILD_ARCH}" \
&& chmod a+x /usr/bin/ha

# SAMBA Config
RUN mkdir -p /var/lib/samba \
&& touch \
Expand All @@ -120,31 +134,16 @@ RUN mkdir -p /var/lib/samba \
/var/lib/samba/registry.tdb \
/var/lib/samba/winbindd_idmap.tdb

# HA API
RUN curl -Lso /usr/bin/ha "https://github.com/home-assistant/cli/releases/download/${CLI_VERSION}/ha_${BUILD_ARCH}" \
&& chmod a+x /usr/bin/ha


#RUN echo "devtmpfs /dev_ devtmpfs rw,relatime,size=1965288k,nr_inodes=182901,mode=755 0 0" >> /etc/fstab
# SRAT
RUN curl -Lso /usr/local/bin/srat "https://github.com/dianlight/srat/releases/download/${SRAT_VERSION}/srat_${BUILD_ARCH}" \
&& chmod a+x /usr/local/bin/srat && echo "https://github.com/dianlight/srat/releases/download/${SRAT_VERSION}/srat_${BUILD_ARCH}"

# ENABLE FUSE APFS
RUN ln -s /usr/sbin/apfs-fuse /usr/sbin/mount.apfs

# PYTHON ADDONS
#RUN pip install \
# pySMART==1.3.0 \
# psutil==5.9.8 \
# humanize==4.9.0 \
# diskinfo==3.1.1 \
# pydantic==1.10.14 \
# https://github.com/dianlight/ha-mqtt-discoverable/archive/refs/heads/main.zip#0.13.1

# Copy data
COPY rootfs /

#RUN cd /usr/local/bin/ && \
# poetry install

HEALTHCHECK \
CMD smbclient -L '\\localhost' -U '%' -m SMB3

Expand Down
12 changes: 11 additions & 1 deletion sambanas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@

Share your disks over the network using Windows file sharing.

![Supports aarch64 Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield] ![Supports i386 Architecture][i386-shield]
![Supports aarch64 Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armv7 Architecture][armv7-shield]

<!--
[![Stargazers repo roster for @dianlight/hassio-addons](https://raw.githubusercontent.com/dianlight/hassio-addons/master/.github/stars2.svg)](https://github.com/dianlight/hassio-addons/stargazers)
![downloads evolution](https://raw.githubusercontent.com/dianlight/hassio-addons/master/sambanas/stats.png)
-->

## Installations

![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fanalytics.home-assistant.io%2Faddons.json&query=%24.1a32f091_sambanas.total&label=SambaNas%20Installations&link=https%3A%2F%2Faddonstats.poeschl.xyz%2F%23)
![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fanalytics.home-assistant.io%2Faddons.json&query=%24.c9a35110_sambanas.total&label=SambaNas%20β%20Installations&link=https%3A%2F%2Faddonstats.poeschl.xyz%2F%23)

## Help Me!

[![](https://img.shields.io/github/sponsors/dianlight?label=Sponsor&logo=GitHub)](https://github.com/sponsors/dianlight)

<a href="https://www.buymeacoffee.com/ypKZ2I0"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=ypKZ2I0&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" /></a>


## About

This Add-on allows you to enable file sharing across different operating systems over a network.
Expand Down
21 changes: 11 additions & 10 deletions sambanas/build.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
build_from:
aarch64: ghcr.io/hassio-addons/base:16.3.6
amd64: ghcr.io/hassio-addons/base:16.3.6
armv7: ghcr.io/hassio-addons/base:16.3.6
codenotary:
signer: [email protected]
base_image: [email protected]
cosign:
# base_identity: https://github.com/home-assistant/builder/.*
identity: https://github.com/dianlight/hassio-addons/.*
aarch64: ghcr.io/hassio-addons/base:17.0.0
amd64: ghcr.io/hassio-addons/base:17.0.0
armv7: ghcr.io/hassio-addons/base:17.0.0
#codenotary:
# signer: [email protected]
# base_image: [email protected]
#cosign:
# #base_identity: https://github.com/home-assistant/builder/.*
# identity: https://github.com/dianlight/hassio-addons/.*
args:
HDDTEMP_VERSION: "0.3-beta15"
# HDDTEMP_VERSION: "0.3-beta15"
SRAT_VERSION: "v2024.12.0"
14 changes: 13 additions & 1 deletion sambanas/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Samba NAS-β
version: 12.3.2-nas.beta84
version: 12.3.2-nas1.beta92
slug: sambanas
description: Expose Home Assistant disc with SMB/CIFS
url: https://github.com/dianlight/hassio-addons/tree/master/sambanas
Expand All @@ -9,6 +9,17 @@ arch:
- aarch64
- amd64
startup: initialize
webui: http://[HOST]:[PORT:3000]/static/index.html
ports:
3000/tcp: 3000
ports_description:
3000/tcp: Web and API UI
ingress: true
ingress_port: 3000
ingress_entry: static/index.html
panel_icon: mdi:folder-network
panel_title: Samba NAS
panel_admin: true
boot: auto
init: false
hassio_api: true
Expand Down Expand Up @@ -103,6 +114,7 @@ schema:
- str?
timemachine: bool?
usage: list(media|backup|share)?
update_srat_onstart: list(no|release|prerelease)?
interfaces:
- str?
bind_all_interfaces: bool?
Expand Down
1 change: 1 addition & 0 deletions sambanas/rootfs/etc/s6-overlay/s6-rc.d/init-samba/run
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ if [[ ! -e /tmp/local_mount.json ]]; then
fi

jq ".shares = $(jq -c </tmp/local_mount.json) | .interfaces = $(jq -c -n '$ARGS.positional' --args -- "${interfaces[@]}") | .docker_interface = \"$(bashio::network 'network.info.docker.inerface' '.docker.interface')\" | .docker_net = \"$(bashio::network 'network.info.docker.network' '.docker.address')\" | .moredisks = $(jq -R -s -c 'split("\n") | map(select(length > 0)) | [ .[] | ltrimstr("/") ]' </tmp/local_mount) " /data/options.json |
tee /config/bootconfig.json |
tempio \
-template /usr/share/tempio/smb.gtpl \
-out /etc/samba/smb.conf
Expand Down
Empty file.
10 changes: 10 additions & 0 deletions sambanas/rootfs/etc/s6-overlay/s6-rc.d/srat/finish
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Take down the S6 supervision tree based on service exit code
# ==============================================================================
if [[ "${1}" -ne 0 ]] && [[ "${1}" -ne 256 ]]; then
bashio::log.warning "srat crashed, halting add-on"
exec /run/s6/basedir/bin/halt
fi

bashio::log.info "srat stopped"
27 changes: 27 additions & 0 deletions sambanas/rootfs/etc/s6-overlay/s6-rc.d/srat/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/command/with-contenv bashio
# ==============================================================================
# Start srat service
# ==============================================================================

PRERELEASE_TAG=$(curl -s https://api.github.com/repos/dianlight/srat/releases | jq -r 'map(select(.prerelease)) | .[0].tag_name')
RELEASE_TAG=$(curl -s https://api.github.com/repos/dianlight/srat/releases | jq -r 'map(select(.release)) | .[0].tag_name')

if bashio::config.has_value 'update_srat_onstart'; then
bashio::log.info "Update on start: $(bashio::config 'update_srat_onstart')"
if bashio::config.equals 'update_srat_onstart' 'release'; then
bashio::log.info "Updating to ${RELEASE_TAG}"
curl -L https://github.com/dianlight/srat/releases/download/${RELEASE_TAG}/srat_$(arch) >/usr/local/bin/srat
#gh -R dianlight/srat release download $RELEASE_TAG -p "srat_$(arch)" -O /usr/local/bin/srat --clobber
else
bashio::log.info "Updating to ${PRERELEASE_TAG}"
curl -L https://github.com/dianlight/srat/releases/download/${PRERELEASE_TAG}/srat_$(arch) >/usr/local/bin/srat
#gh -R dianlight/srat release download $PRERELEASE_TAG -p "srat_$(arch)" -O /usr/local/bin/srat --clobber
fi
chmod +x /usr/local/bin/srat
fi

# s6-svc -r /var/run/s6/services/<service name>
exec /usr/local/bin/srat \
-port 3000 \
-conf /config/bootconfig.json \
-ro true
1 change: 1 addition & 0 deletions sambanas/rootfs/etc/s6-overlay/s6-rc.d/srat/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Loading

0 comments on commit 28f477f

Please sign in to comment.