mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-06 07:35:56 +02:00
initial build
This commit is contained in:
46
seafile/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh
Normal file
46
seafile/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh
Normal 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
|
||||
60
seafile/rootfs/etc/cont-init.d/99-run.sh
Normal file
60
seafile/rootfs/etc/cont-init.d/99-run.sh
Normal 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
|
||||
95
seafile/rootfs/etc/cont-init.d/99-run2.sh
Normal file
95
seafile/rootfs/etc/cont-init.d/99-run2.sh
Normal 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
|
||||
Reference in New Issue
Block a user