2023-01-14 16:41:14 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2023-04-30 15:21:49 +02:00
|
|
|
secret_key_base=$(ynh_string_random --length=24)
|
|
|
|
signing_salt=$(ynh_string_random --length=24)
|
|
|
|
encryption_salt=$(ynh_string_random --length=24)
|
|
|
|
|
2023-01-14 16:41:14 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-02-05 18:14:48 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2023-01-14 16:41:14 +01:00
|
|
|
|
2023-02-05 18:14:48 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2023-01-14 16:41:14 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2023-04-30 15:10:42 +02:00
|
|
|
#=================================================
|
|
|
|
# ADD A CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
|
|
|
|
2023-05-02 13:42:26 +02:00
|
|
|
# max file upload size
|
2023-05-02 13:58:15 +02:00
|
|
|
# TODO : unbound variable ? #MEDIA_UPLOAD_SIZE="${MEDIA_UPLOAD_SIZE:0:2}000000" # convert the MB argument in bytes
|
2023-05-02 13:42:26 +02:00
|
|
|
|
2023-04-30 15:10:42 +02:00
|
|
|
ynh_add_config --template="../conf/.env" --destination="$install_dir/.env"
|
|
|
|
|
|
|
|
chmod 400 "$install_dir/.env"
|
|
|
|
chown $app:$app "$install_dir/.env"
|
|
|
|
|
2023-04-30 15:21:49 +02:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
2023-05-02 12:54:03 +02:00
|
|
|
# Just dependency
|
2023-04-30 15:21:49 +02:00
|
|
|
#=================================================
|
2023-05-01 23:24:05 +02:00
|
|
|
ynh_script_progression --message="Managing special dependencies..." --weight=1
|
2023-05-01 17:59:48 +02:00
|
|
|
### Add just dependency
|
2023-05-01 17:52:00 +02:00
|
|
|
# TODO : this is unsafe and should be dealt with in a better way.
|
|
|
|
# There is currently no proper way to install it simply on Debian 11 https://github.com/casey/just#packages
|
|
|
|
|
2023-05-02 12:34:24 +02:00
|
|
|
# only works for x86, we need to switch to the other option with makedeb package ?
|
2023-05-02 12:10:27 +02:00
|
|
|
ynh_install_extra_app_dependencies --repo="https://proget.makedeb.org prebuilt-mpr bullseye" --package="just" --key='https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub'
|
2023-05-02 11:29:51 +02:00
|
|
|
|
2023-05-02 13:39:09 +02:00
|
|
|
#ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="https://proget.makedeb.org makedeb main" --package="makedeb" --key='https://proget.makedeb.org/debian-feeds/makedeb.pub'
|
2023-05-02 12:10:27 +02:00
|
|
|
#git clone 'https://mpr.makedeb.org/just'
|
|
|
|
#cd just
|
|
|
|
#makedeb -si
|
|
|
|
#cd ..
|
2023-05-01 17:52:00 +02:00
|
|
|
|
2023-05-02 12:54:03 +02:00
|
|
|
export WITH_DOCKER=no # or source .env ?
|
|
|
|
source "$install_dir/.env"
|
2023-05-02 13:57:17 +02:00
|
|
|
|
|
|
|
ynh_script_progression --message="Configuring Bonfire release..." --weight=1
|
2023-05-02 13:06:34 +02:00
|
|
|
cd $install_dir
|
2023-05-02 13:57:17 +02:00
|
|
|
ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc just config
|
2023-05-02 14:36:42 +02:00
|
|
|
ynh_exec_warn grep -m 1 'version:' mix.exs
|
|
|
|
ynh_exec_warn cat .env
|
2023-05-02 13:57:17 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# Building the release
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Building Bonfire release..." --weight=1
|
2023-05-02 12:54:03 +02:00
|
|
|
ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc just rel-build
|
2023-01-14 16:41:14 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# Run the release
|
|
|
|
#=================================================
|
2023-05-02 13:49:56 +02:00
|
|
|
release_folder="_build/prod/rel/bonfire"
|
2023-05-02 13:32:45 +02:00
|
|
|
|
2023-05-02 14:36:42 +02:00
|
|
|
ynh_script_progression --message="Running database migrations..." --weight=1
|
2023-01-14 16:41:14 +01:00
|
|
|
# Database created before, let's run the migrations
|
2023-05-02 12:54:03 +02:00
|
|
|
ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "just cmd $release_folder/bin/bonfire eval 'EctoSparkles.Migrator.migrate()'"
|
2023-01-14 16:41:14 +01:00
|
|
|
|
2023-05-02 14:36:42 +02:00
|
|
|
ynh_script_progression --message="Starting Bonfire..." --weight=1
|
2023-01-14 16:41:14 +01:00
|
|
|
# start bonfire as a daemon
|
2023-05-02 12:54:03 +02:00
|
|
|
ynh_exec_warn_less ynh_exec_as $app -s $SHELL -lc "just cmd $release_folder/bin/bonfire start daemon"
|
2023-01-14 16:41:14 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|