initial build

This commit is contained in:
Alexandre
2022-06-09 21:20:10 +02:00
parent 842eac071e
commit fba7c37de6
13 changed files with 571 additions and 0 deletions

1
seafile/CHANGELOG.md Normal file
View File

@@ -0,0 +1 @@
- Initial release

92
seafile/Dockerfile Normal file
View File

@@ -0,0 +1,92 @@
#============================#
# ALEXBELGIUM'S DOCKERFILE #
#============================#
# _.------.
# _.-` ('>.-`"""-.
# '.--'` _'` _ .--.)
# -' '-.-';` `
# ' - _.' ``'--.
# '---` .-'""`
# /`
#=== Home Assistant Addon ===#
#################
# 1 Build Image #
#################
ARG BUILD_FROM
ARG BUILD_VERSION
FROM ${BUILD_FROM}
ENV BASHIO_VERSION=1.29.1
##################
# 2 Modify Image #
##################
ENV LANG C.UTF-8
##################
# 3 Install apps #
##################
# Copy local files
COPY rootfs/ /
# Modules
ARG MODULES="00-banner.sh 00-global_var.sh 92-local_mounts.sh 92-smb_mounts.sh"
# Automatic modules download
RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
&& mkdir -p /etc/cont-init.d \
&& for scripts in $MODULES; do echo "$scripts" && curl -k -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \
&& chmod -R 755 /etc/cont-init.d || printf '%s\n' "${MODULES}" >/MODULESFILE
# Manual apps
ENV PACKAGES=""
# Automatic apps & bashio
RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
&& curl -k -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \
&& chmod 777 /automatic_packages.sh \
&& eval /./automatic_packages.sh "${PACKAGES:-}" \
&& rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE
################
# 4 Entrypoint #
################
RUN chmod 777 /entrypoint.sh
ENTRYPOINT [ "/usr/bin/env" ]
CMD [ "/entrypoint.sh" ]
############
# 5 Labels #
############
ARG BUILD_ARCH
ARG BUILD_DATE
ARG BUILD_DESCRIPTION
ARG BUILD_NAME
ARG BUILD_REF
ARG BUILD_REPOSITORY
ARG BUILD_VERSION
LABEL \
io.hass.name="${BUILD_NAME}" \
io.hass.description="${BUILD_DESCRIPTION}" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="alexbelgium (https://github.com/alexbelgium)" \
org.opencontainers.image.title="${BUILD_NAME}" \
org.opencontainers.image.description="${BUILD_DESCRIPTION}" \
org.opencontainers.image.vendor="Home Assistant Add-ons" \
org.opencontainers.image.authors="alexbelgium (https://github.com/alexbelgium)" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.url="https://github.com/alexbelgium" \
org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \
org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}

77
seafile/README.md Normal file
View File

@@ -0,0 +1,77 @@
# Home assistant add-on: seafile
[![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium)
![Version](https://img.shields.io/badge/dynamic/json?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fseafile%2Fconfig.json)
![Ingress](https://img.shields.io/badge/dynamic/json?label=Ingress&query=%24.ingress&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fseafile%2Fconfig.json)
![Arch](https://img.shields.io/badge/dynamic/json?color=success&label=Arch&query=%24.arch&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Fseafile%2Fconfig.json)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9c6cf10bdbba45ecb202d7f579b5be0e)](https://www.codacy.com/gh/alexbelgium/hassio-addons/dashboard?utm_source=github.com&utm_medium=referral&utm_content=alexbelgium/hassio-addons&utm_campaign=Badge_Grade)
[![GitHub Super-Linter](https://github.com/alexbelgium/hassio-addons/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter)
[![Builder](https://github.com/alexbelgium/hassio-addons/workflows/Builder/badge.svg)](https://github.com/alexbelgium/hassio-addons/actions/workflows/builder.yaml)
[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white
_Thanks to everyone having starred my repo! To star it click on the image below, then it will be on top right. Thanks!_
[![Stargazers repo roster for @alexbelgium/hassio-addons](https://reporoster.com/stars/alexbelgium/hassio-addons)](https://github.com/alexbelgium/hassio-addons/stargazers)
## About
---
High performance file syncing and sharing, with also Markdown WYSIWYG editing, Wiki, file label and other knowledge management features.
This addon is based on the docker image [https://hub.docker.com/r/franchetti/seafile-arm](https://hub.docker.com/r/franchetti/seafile-arm)
## Installation
---
The installation of this add-on is pretty straightforward and not different in comparison to installing any other add-on.
1. Add my add-ons repository to your home assistant instance (in supervisor addons store at top right, or click button below if you have configured my HA)
[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Falexbelgium%2Fhassio-addons)
1. Install this add-on.
1. Click the `Save` button to store your configuration.
1. Set the add-on options to your preferences
1. Start the add-on.
1. Check the logs of the add-on to see if everything went well.
1. Open the webUI and adapt the software options
## Configuration
---
Webui can be found at <http://your-ip:PORT>.
The default username/password : described in the startup log.
Configurations can be done through the app webUI, except for the following options
Default name : admin
Default password : admin123
```yaml
GUID: user
GPID: user
TZ: timezone
PASSWORD: Optionally set a password for the gui
CLI_ARGS: Optionally pass cli start arguments to seafile
localdisks: sda1 #put the hardware name of your drive to mount separated by commas, or its label. Ex: sda1, sdb1, MYNAS...
networkdisks: "//SERVER/SHARE" # optional, list of smb servers to mount, separated by commas
cifsusername: "username" # optional, smb username, same for all smb shares
cifspassword: "password" # optional, smb password
force_scheme_https: if you have issues accessing ingress with https, check this box to force https
force_external_port: if you have issues accessing ingress with https, note here your external port used to access HA
```
## Support
Create an issue on github
## Illustration
---
![illustration](https://seafile.com/img/slider/artistdetails.png)
[repository]: https://github.com/alexbelgium/hassio-addons

56
seafile/apparmor.txt Normal file
View File

@@ -0,0 +1,56 @@
#include <tunables/global>
profile seafile_addon flags=(attach_disconnected,mediate_deleted) {
#include <abstractions/base>
capability,
file,
signal,
mount,
umount,
remount,
network udp,
network tcp,
network dgram,
network stream,
network inet,
network inet6,
network netlink raw,
capability setgid,
capability setuid,
capability sys_admin,
capability dac_read_search,
# capability dac_override,
# capability sys_rawio,
# S6-Overlay
/bin/** ix,
/usr/bin/** ix,
/usr/lib/bashio/** ix,
/etc/s6/** rix,
/run/s6/** rix,
/etc/services.d/** rwix,
/etc/cont-init.d/** rwix,
/etc/cont-finish.d/** rwix,
/init rix,
/var/run/** mrwkl,
/var/run/ mrwkl,
/dev/i2c-1 mrwkl,
# Files required
/dev/sda1 mrwkl,
/dev/sdb1 mrwkl,
/dev/mmcblk0p1 mrwkl,
/dev/* mrwkl,
/tmp/** mrkwl,
# Data access
/data/** rw,
# suppress ptrace denials when using 'docker ps' or using 'ps' inside a container
ptrace (trace,read) peer=docker-default,
# docker daemon confinement requires explict allow rule for signal
signal (receive) set=(kill,term) peer=/usr/bin/docker,
}

10
seafile/build.json Normal file
View File

@@ -0,0 +1,10 @@
{
"build_from": {
"aarch64": "franchetti/seafile-arm:latest",
"amd64": "franchetti/seafile-arm:latest",
"armv7": "franchetti/seafile-arm:latest"
},
"codenotary": {
"signer": "alexandrep.github@gmail.com"
}
}

97
seafile/config.json Normal file
View File

@@ -0,0 +1,97 @@
{
"arch": [
"aarch64",
"amd64",
"armv7"
],
"codenotary": "alexandrep.github@gmail.com",
"description": "High performance file syncing and sharing, with also Markdown WYSIWYG editing, Wiki, file label and other knowledge management features",
"devices": [
"/dev/sda",
"/dev/sdb",
"/dev/sdc",
"/dev/sdd",
"/dev/sde",
"/dev/sdf",
"/dev/sdg",
"/dev/nvme",
"/dev/mmcblk",
"/dev/sda1",
"/dev/sdb1",
"/dev/sdc1",
"/dev/sdd1",
"/dev/sde1",
"/dev/sdf1",
"/dev/sdg1",
"/dev/sda2",
"/dev/sdb2",
"/dev/sdc2",
"/dev/sdd2",
"/dev/sde2",
"/dev/sdf2",
"/dev/sdg2",
"/dev/sda3",
"/dev/sdb3",
"/dev/sda4",
"/dev/sdb4",
"/dev/nvme0",
"/dev/nvme1",
"/dev/nvme2"
],
"environment": {
"NOSWAG": "1"
},
"image": "ghcr.io/alexbelgium/seafile-{arch}",
"map": [
"media:rw",
"share:rw",
"config:rw",
"ssl"
],
"name": "Seafile",
"options": {
"database": "sqlite",
"data_location": "/share/seafile",
"seafile_server_letsencrypt": false,
"seafile_server_hostname": "seafile.example.com",
"seafile_admin_email": "me@example.com",
"seafile_admin_password": "a_very_secret_password",
"PUID": 0,
"GUID": 0,
"TZ": "Europe/Paris"
},
"panel_icon": "mdi:library",
"ports": {
"80/tcp": 8077
},
"ports_description": {
"80/tcp": "seafile webui"
},
"privileged": [
"SYS_ADMIN",
"DAC_READ_SEARCH",
"NET_ADMIN"
],
"schema": {
"PUID": "int",
"GUID": "int",
"TZ": "str",
"database": "list(sqlite|mariadb_addon)",
"data_location": "str",
"seafile_server_letsencrypt": "bool?",
"seafile_server_hostname": "str",
"seafile_admin_email": "email",
"seafile_admin_password": "str",
"cifspassword": "str?",
"cifsusername": "str?",
"localdisks": "str?",
"networkdisks": "str?"
},
"services": [
"mysql:want"
],
"slug": "seafile",
"url": "https://github.com/alexbelgium/hassio-addons/tree/master/seafile",
"version": "1.0",
"webui": "http://[HOST]:[PORT:80]"
}

BIN
seafile/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
seafile/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -0,0 +1,27 @@
#!/bin/bash
echo "Starting..."
############################
# Backup Dockerfile Script #
############################
if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then
chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh
chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh
/./etc/cont-init.d/00-aaa_dockerfile_backup.sh
rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh
fi
####################
# Starting scripts #
####################
for SCRIPTS in /etc/cont-init.d/*; do
[ -e "$SCRIPTS" ] || continue
echo "$SCRIPTS: executing"
chown "$(id -u)":"$(id -g)" "$SCRIPTS"
chmod a+x "$SCRIPTS"
# Change shebang if no s6 supervision
sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS"
/."$SCRIPTS" || echo "$SCRIPTS: exiting $?"
done

View File

@@ -0,0 +1,46 @@
#!/bin/bash
# If dockerfile failed install manually
echo "forced pause"
sleep 30000000
##############################
# Automatic modules download #
##############################
if [ -e "/MODULESFILE" ]; then
MODULES=$(</MODULESFILE)
MODULES="${MODULES:-00-banner.sh}"
echo "Executing modules script : $MODULES"
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
&& mkdir -p /etc/cont-init.d \
&& for scripts in $MODULES; do echo "$scripts" && curl -k -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \
&& chmod -R 755 /etc/cont-init.d
fi
#######################
# Automatic installer #
#######################
if [ -e "/ENVFILE" ]; then
PACKAGES=$(</ENVFILE)
echo "Executing dependency script with custom elements : $PACKAGES"
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
&& curl -k -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \
&& chmod 777 /automatic_packages.sh \
&& eval /./automatic_packages.sh "${PACKAGES:-}" \
&& rm /automatic_packages.sh
fi
if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then
for scripts in $MODULES; do
echo "$scripts : executing"
chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts"
chmod a+x /etc/cont-init.d/"$scripts"
/./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?"
rm /etc/cont-init.d/"$scripts"
done | tac
fi

View File

@@ -0,0 +1,60 @@
#!/usr/bin/env bashio
cd /opt/seafile
cp /opt/seafile/.env.example /opt/seafile/.env
####################
# GLOBAL VARIABLES #
####################
sed -i "s|NOSWAG=0|NOSWAG=1|g" .env
sed -i "s|USE_HTTPS=1|USE_HTTPS=0|g" .env
sed -i "s|PUID=1000|PUID=$(bashio::config 'PUID')|g" .env
sed -i "s|PGID=1000|PGID=$(bashio::config 'PGID')|g" .env
sed -i "s|TZ=Europe/Zurich|TZ=$(bashio::config 'TZ')|g" .env
sed -i "s|URL=your.domain|URL=$(bashio::config 'SEAFILE_SERVER_HOSTNAME')|g" .env
sed -i "s|SEAFILE_ADMIN_EMAIL=you@your.email|SEAFILE_ADMIN_EMAIL=$(bashio::config 'SEAFILE_ADMIN_EMAIL')|g" .env
sed -i "s|SEAFILE_CONF_DIR=./seafile/conf|SEAFILE_CONF_DIR=$(bashio::config 'data_location')/conf|g" .env
sed -i "s|SEAFILE_LOGS_DIR=./seafile/logs|SEAFILE_LOGS_DIR=$(bashio::config 'data_location')/logs|g" .env
sed -i "s|SEAFILE_DATA_DIR=./seafile/seafile-data|SEAFILE_DATA_DIR=$(bashio::config 'data_location')/seafile-data|g" .env
sed -i "s|SEAFILE_SEAHUB_DIR=./seafile/seahub-data|SEAFILE_SEAHUB_DIR=$(bashio::config 'data_location'/seahub-data)|g" .env
sed -i "s|SEAFILE_SQLITE_DIR=./seafile/sqlite|SSEAFILE_SQLITE_DIR=$(bashio::config 'data_location'/sqlite)|g" .env
sed -i "s|DATABASE_DIR=./db|DATABASE_DIR=$(bashio::config 'data_location'/db)|g" .env
###################
# Define database #
###################
bashio::log.info "Defining database"
case $(bashio::config 'database') in
# Use sqlite
sed -i "s|SQLITE=0|SQLITE=1|g" .env
sqlite)
# Use mariadb
mariadb_addon)
bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Discovering values..."
if ! bashio::services.available 'mysql'; then
bashio::log.fatal \
"Local database access should be provided by the MariaDB addon"
bashio::exit.nok \
"Please ensure it is installed and started"
fi
# Use values
sed -i "s|MYSQL_HOST=db|MYSQL_HOST=$(bashio::services "mysql" "host")|g" .env
sed -i "s|MYSQL_USER_PASSWD=secret|MYSQL_USER_PASSWD=$(bashio::services "mysql" "username")|g" .env
sed -i "s|MYSQL_ROOT_PASSWD=secret|MYSQL_USER_PASSWD=$(bashio::services "mysql" "password")|g" .env
bashio::log.warning "This addon is using the Maria DB addon"
bashio::log.warning "Please ensure this is included in your backups"
bashio::log.warning "Uninstalling the MariaDB addon will remove any data"
;;
esac
##############
# LAUNCH APP #
##############
bashio::log.info "Starting app"
#/sbin/my_init -- /scripts/enterpoint.sh
/./docker_entrypoint.sh

View File

@@ -0,0 +1,95 @@
#!/usr/bin/env bashio
exit 0
#################
# DATA LOCATION #
#################
DATA_LOCATION="$(bashio::config 'data_location')"
# Chack Seafile dir
bashio::log.info "Making data folder $DATA_LOCATION"
# Make dir
echo "Checking location exists"
mkdir -p "$DATA_LOCATION"
# Make dir
echo "Checking permissions"
chown -R "$(id -u)":"$(id -g)" "$DATA_LOCATION"
chmod -R 755 "$DATA_LOCATION"
# Create symlink
echo "Checking symlink"
ln -fs "$DATA_LOCATION" /shared
####################
# GLOBAL VARIABLES #
####################
echo "Exporting variables"
export SEAFILE_SERVER_LETSENCRYPT="$(bashio::config 'seafile_server_letsencrypt')"
export SEAFILE_SERVER_HOSTNAME="$(bashio::config 'seafile_server_hostname')"
export SEAFILE_ADMIN_EMAIL="$(bashio::config 'seafile_admin_email')"
export SEAFILE_ADMIN_PASSWORD="$(bashio::config 'seafile_admin_password')"
bashio::log.blue "SEAFILE_SERVER_LETSENCRYPT=$SEAFILE_SERVER_LETSENCRYPT"
bashio::log.blue "SEAFILE_SERVER_HOSTNAME=$SEAFILE_SERVER_HOSTNAME"
bashio::log.blue "SEAFILE_ADMIN_EMAIL=$SEAFILE_ADMIN_EMAIL"
bashio::log.blue "SEAFILE_ADMIN_PASSWORD=$SEAFILE_ADMIN_PASSWORD"
###################
# Define database #
###################
bashio::log.info "Defining database"
case $(bashio::config 'database') in
# Use sqlite
sqlite)
bashio::log.info "Using a local sqlite database"
ehco "Installing sqlite"
apt-get update &>/dev/null \
apt-get install -y sqlite3 &>/dev/null \
apt-get clean &>/dev/null
echo "Configuring sqlite"
sed -i 's/setup-seafile-mysql\.sh/setup-seafile.sh/g' /scripts/bootstrap.py \
&& sed -i '/def wait_for_mysql()/a\\ return' /scripts/utils.py \
&& touch $DATA_LOCATION/seahub.db \
&& ln -fs "$DATA_LOCATION/seahub.db" /opt/seafile
export SEAFILE_ADMIN_EMAIL=test@test.test
export SEAFILE_ADMIN_PASSWORD=gf7Ads¤f#B2G
export SEAFILE_SERVER_HOSTNAME=seafile.test
;;
# Use mariadb
mariadb_addon)
bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Discovering values..."
if ! bashio::services.available 'mysql'; then
bashio::log.fatal \
"Local database access should be provided by the MariaDB addon"
bashio::exit.nok \
"Please ensure it is installed and started"
fi
# Use values
export MYSQL_SERVER=$(bashio::services "mysql" "host") && bashio::log.blue "MYSQL_SERVER=$MYSQL_SERVER"
export MYSQL_PORT=$(bashio::services "mysql" "port") && bashio::log.blue "MYSQL_PORT=$MYSQL_PORT"
export MYSQL_USER=$(bashio::services "mysql" "username") && bashio::log.blue "MYSQL_USER=$MYSQL_USER"
export MYSQL_PORT=$(bashio::services "mysql" "password") && bashio::log.blue "MYSQL_PORT=$MYSQL_PORT"
bashio::log.warning "This addon is using the Maria DB addon"
bashio::log.warning "Please ensure this is included in your backups"
bashio::log.warning "Uninstalling the MariaDB addon will remove any data"
;;
esac
##############
# LAUNCH APP #
##############
bashio::log.info "Starting app"
#/sbin/my_init -- /scripts/enterpoint.sh
/./docker_entrypoint.sh

10
seafile/updater.json Normal file
View File

@@ -0,0 +1,10 @@
{
"github_fulltag": "true",
"last_update": "09-06-2022",
"paused": false,
"repository": "alexbelgium/hassio-addons",
"slug": "seafile",
"source": "github",
"upstream_repo": "haiwen/seahub",
"upstream_version": "0.6.18-ls164"
}