2022-08-30 19:10:45 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
2022-08-30 19:10:45 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
|
|
|
|
2024-04-01 00:21:38 +02:00
|
|
|
source_dir="$install_dir/source"
|
|
|
|
ynh_setup_source --source_id="main" --dest_dir="$source_dir"
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-07-29 13:12:32 +02:00
|
|
|
ffmpeg_static_dir="$install_dir/ffmpeg-static"
|
|
|
|
ynh_setup_source --source_id="ffmpeg-static" --dest_dir="$ffmpeg_static_dir"
|
|
|
|
|
2022-08-30 19:10:45 +02:00
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
# CHECK PYTHON VERSION AND COMPILE IF NEEDED
|
2022-08-30 19:10:45 +02:00
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_script_progression --message="Check Python version & compile the required one if needed..." --weight=1
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-04-01 00:21:38 +02:00
|
|
|
py_required_major=$(cat "$source_dir/machine-learning/Dockerfile" | grep "FROM python:" | head -n1 | cut -d':' -f2 | cut -d'-' -f1)
|
2024-03-26 06:53:38 +01:00
|
|
|
myynh_py_latest_from_major --python="$py_required_major"
|
|
|
|
myynh_install_python --python="$py_required_version"
|
2022-08-30 19:10:45 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
# INSTALL NODEJS
|
2022-08-30 19:10:45 +02:00
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_script_progression --message="Installing nodejs..." --weight=1
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
|
2022-08-30 19:10:45 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
# CREATE A POSTGRESQL DATABASE
|
2022-08-30 19:10:45 +02:00
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-03-26 06:53:38 +01:00
|
|
|
db_pwd=$(ynh_string_random)
|
|
|
|
myynh_create_psql_db
|
2024-07-14 23:29:50 +02:00
|
|
|
db_port=$(myynh_execute_psql_as_root --sql="\conninfo" | awk -F '"' '{ print $(NF-1) }')
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_app_setting_set --app="$app" --key=psql_pwd --value="$db_pwd"
|
2024-04-01 00:17:55 +02:00
|
|
|
ynh_app_setting_set --app="$app" --key=psql_version --value="$(postgresql_version)"
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_app_setting_set --app="$app" --key=psql_port --value="$db_port"
|
2022-08-30 19:10:45 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
# MAKE INSTALL
|
2022-08-30 19:10:45 +02:00
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_script_progression --message="Making install..." --weight=5
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-03-26 06:53:38 +01:00
|
|
|
myynh_install_immich
|
2022-08-30 19:10:45 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
# ADD A CONFIGURATION
|
2022-08-30 19:10:45 +02:00
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_script_progression --message="Adding a configuration file..."
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-06-14 13:59:30 +02:00
|
|
|
ynh_add_config --template="env-server" --destination="$install_dir/env-server"
|
|
|
|
chmod 600 "$install_dir/env-server"
|
|
|
|
chown $app:$app "$install_dir/env-server"
|
|
|
|
|
|
|
|
ynh_add_config --template="env-machine-learning" --destination="$install_dir/env-machine-learning"
|
|
|
|
chmod 600 "$install_dir/env-machine-learning"
|
|
|
|
chown $app:$app "$install_dir/env-machine-learning"
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-07-19 22:37:20 +02:00
|
|
|
ynh_add_config --template="build-lock.json" --destination="$install_dir/app/build-lock.json"
|
|
|
|
chmod 600 "$install_dir/app/build-lock.json"
|
|
|
|
chown $app:$app "$install_dir/app/build-lock.json"
|
|
|
|
|
2022-08-30 19:10:45 +02:00
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2022-08-30 19:10:45 +02:00
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_add_nginx_config
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_add_systemd_config --service="$app-server" --template="immich-server.service"
|
2024-06-15 13:39:04 +02:00
|
|
|
ynh_add_systemd_config --service="$app-microservices" --template="immich-microservices.service"
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_add_systemd_config --service="$app-machine-learning" --template="immich-machine-learning.service"
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-03-26 06:53:38 +01:00
|
|
|
yunohost service add "$app-server" --description="Immich Server" --log="/var/log/$app/$app-server.log"
|
2024-06-15 13:39:04 +02:00
|
|
|
yunohost service add "$app-microservices" --description="Immich Microservices" --log="/var/log/$app/$app-microservices.log"
|
2024-03-26 06:53:38 +01:00
|
|
|
yunohost service add "$app-machine-learning" --description="Immich Machine Learning" --log="/var/log/$app/$app-machine-learning.log"
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-05-04 21:58:35 +02:00
|
|
|
ynh_multimedia_build_main_dir
|
|
|
|
ynh_multimedia_addaccess --user_name=$app
|
|
|
|
|
2022-08-30 19:10:45 +02:00
|
|
|
ynh_use_logrotate
|
|
|
|
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_add_fail2ban_config --logpath="/var/log/$app/$app-server.log" --failregex="$failregex"
|
2022-08-30 19:10:45 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
2022-08-30 19:10:45 +02:00
|
|
|
|
2024-06-15 14:02:59 +02:00
|
|
|
ynh_systemd_action --service_name="$app-microservices" --action="start" --line_match="Immich Microservices is running" --log_path="/var/log/$app/$app-microservices.log"
|
2024-03-26 06:53:38 +01:00
|
|
|
ynh_systemd_action --service_name="$app-machine-learning" --action="start" --line_match="Application startup complete" --log_path="/var/log/$app/$app-machine-learning.log"
|
|
|
|
ynh_systemd_action --service_name="$app-server" --action="start" --line_match="Immich Server is listening" --log_path="/var/log/$app/$app-server.log"
|
2022-08-30 19:10:45 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|