2023-01-14 16:41:14 +01:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
|
# GENERIC START
|
|
|
|
|
#=================================================
|
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
2023-05-03 21:55:34 +02:00
|
|
|
|
ynh_install_nodejs --nodejs_version=16.13.0 # TODO : need to decide of a better version
|
2023-05-03 18:31:22 +02:00
|
|
|
|
ynh_use_nodejs
|
|
|
|
|
|
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
|
|
|
|
|
#=================================================
|
2023-08-14 15:01:32 +02:00
|
|
|
|
## Generate secrets and other config values
|
2023-08-13 19:49:08 +02:00
|
|
|
|
secret_key_base=$(ynh_string_random --length=24)
|
|
|
|
|
signing_salt=$(ynh_string_random --length=24)
|
2023-08-13 19:51:47 +02:00
|
|
|
|
encryption_salt=$(ynh_string_random --length=24)
|
2023-08-14 15:01:32 +02:00
|
|
|
|
# search
|
|
|
|
|
meili_master_key=$(ynh_string_random --length=24)
|
2023-08-13 19:49:08 +02:00
|
|
|
|
# max file upload size
|
|
|
|
|
MEDIA_UPLOAD_SIZE="${media_upload_size//[!0-9]/}000000"
|
|
|
|
|
|
2023-04-30 15:10:42 +02:00
|
|
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
|
|
|
|
|
|
|
|
|
ynh_add_config --template="../conf/.env" --destination="$install_dir/.env"
|
2023-08-13 19:49:08 +02:00
|
|
|
|
ynh_store_file_checksum --file="$install_dir/.env"
|
2023-04-30 15:10:42 +02:00
|
|
|
|
|
|
|
|
|
chmod 400 "$install_dir/.env"
|
|
|
|
|
chown $app:$app "$install_dir/.env"
|
|
|
|
|
|
2023-04-30 15:21:49 +02:00
|
|
|
|
#=================================================
|
|
|
|
|
# SPECIFIC SETUP
|
2023-05-03 00:03:21 +02:00
|
|
|
|
#=================================================
|
2023-05-02 11:29:51 +02:00
|
|
|
|
|
2023-05-02 16:50:07 +02:00
|
|
|
|
source $install_dir/.env
|
2023-08-13 12:11:01 +02:00
|
|
|
|
export WITH_DOCKER=no # or source .env ? # Using this for now
|
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-08-13 12:11:01 +02:00
|
|
|
|
ynh_exec_warn ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no mix local.hex --force" # install Hex in non-interractive way
|
2023-08-13 12:40:56 +02:00
|
|
|
|
ynh_exec_warn ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no just config-basic"
|
2023-08-13 12:11:01 +02:00
|
|
|
|
#ynh_exec_warn ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no just mix bonfire.deps .update"
|
2023-08-12 13:00:26 +02:00
|
|
|
|
|
2023-05-02 13:57:17 +02:00
|
|
|
|
#=================================================
|
|
|
|
|
# Building the release
|
|
|
|
|
#=================================================
|
|
|
|
|
ynh_script_progression --message="Building Bonfire release..." --weight=1
|
2023-05-03 14:38:23 +02:00
|
|
|
|
export TERM=linux # why is that not defined ?
|
2023-05-03 14:17:04 +02:00
|
|
|
|
export TERMINFO=/etc/terminfo
|
2023-08-13 13:05:57 +02:00
|
|
|
|
### DONT USE GLOBAL NPM INSTALL
|
|
|
|
|
ynh_replace_string --match_string="npm install --global" --replace_string="npm install" --target_file="$install_dir/justfile"
|
2023-08-13 12:11:01 +02:00
|
|
|
|
ynh_exec_warn ynh_exec_as $app $ynh_node_load_PATH -s $SHELL -lc "WITH_DOCKER=no just rel-build"
|
2023-05-03 18:31:22 +02:00
|
|
|
|
#ynh_exec_warn just rel-build # node needs (root) access to /usr/local/lib/node_modules
|
2023-01-14 16:41:14 +01:00
|
|
|
|
|
|
|
|
|
#=================================================
|
2023-08-15 12:03:28 +02:00
|
|
|
|
# START SYSTEMD SERVICE - Run the release
|
2023-01-14 16:41:14 +01:00
|
|
|
|
#=================================================
|
2023-05-02 13:49:56 +02:00
|
|
|
|
release_folder="_build/prod/rel/bonfire"
|
2023-05-02 13:32:45 +02:00
|
|
|
|
|
2023-08-15 11:42:50 +02:00
|
|
|
|
### Not running the migration, they are done on startup anyway
|
|
|
|
|
#ynh_script_progression --message="Running database migrations..." --weight=1
|
|
|
|
|
## Database created before, let's run the migrations
|
|
|
|
|
#ynh_exec_warn ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no just cmd $release_folder/bin/bonfire eval 'EctoSparkles.Migrator.migrate()'"
|
2023-01-14 16:41:14 +01:00
|
|
|
|
|
2023-08-15 12:03:28 +02:00
|
|
|
|
#ynh_script_progression --message="Starting Bonfire..." --weight=1
|
|
|
|
|
#ynh_exec_warn ynh_exec_as $app -s $SHELL -lc "WITH_DOCKER=no just cmd $release_folder/bin/bonfire start"
|
2023-05-02 17:52:11 +02:00
|
|
|
|
|
2023-08-15 12:03:28 +02:00
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
|
ynh_add_systemd_config
|
|
|
|
|
|
|
|
|
|
yunohost service add $app --description="Bonfire daemon" --log="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ynh_script_progression --message="Starting Bonfire daemon service..." --weight=1
|
|
|
|
|
|
|
|
|
|
# Start a systemd service
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
2023-01-14 16:41:14 +01:00
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
|
# END OF SCRIPT
|
|
|
|
|
#=================================================
|
|
|
|
|
|
2023-05-02 17:52:11 +02:00
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --weight=1
|
|
|
|
|
ynh_script_progression --message="Now you need to sign-up, the first account will automatically be admin." --last
|