2017-04-09 11:05:39 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-08-23 16:08:03 +02:00
|
|
|
source _common.sh
|
2017-04-09 11:05:39 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2019-08-23 16:08:03 +02:00
|
|
|
export secret=$(ynh_string_random 24)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2023-12-16 15:11:09 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..."
|
2019-08-23 16:08:03 +02:00
|
|
|
|
2023-12-16 15:11:09 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2019-08-23 16:08:03 +02:00
|
|
|
|
2023-12-16 15:11:09 +01:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2019-08-23 16:08:03 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
# PYTHON DEPENDENCIES
|
|
|
|
#=================================================
|
2023-12-16 15:11:09 +01:00
|
|
|
ynh_script_progression --message="Installing more dependencies..."
|
|
|
|
|
|
|
|
pushd "$install_dir"
|
|
|
|
python3 -m venv venv
|
|
|
|
venv/bin/pip install --upgrade pip
|
|
|
|
venv/bin/pip install gunicorn
|
|
|
|
#echo "django-auth-ldap<1.4" >> $install_dir/requirements.txt
|
|
|
|
venv/bin/pip install -r requirements.txt
|
2022-09-03 00:23:04 +02:00
|
|
|
popd
|
2017-07-31 13:52:05 +02:00
|
|
|
|
2019-08-23 16:08:03 +02:00
|
|
|
#=================================================
|
|
|
|
# CONFIGURATION DJANGO
|
|
|
|
#=================================================
|
2023-12-16 15:11:09 +01:00
|
|
|
ynh_script_progression --message="Configuring application..."
|
2020-06-30 20:40:31 +02:00
|
|
|
|
2023-12-16 15:11:09 +01:00
|
|
|
export prefix="${path#"/"}/"
|
2019-08-23 16:08:03 +02:00
|
|
|
prefix=${prefix%"/"}
|
2023-12-16 15:11:09 +01:00
|
|
|
ynh_render_template --template="local.py.j2" --destination="$install_dir/coin/settings_local.py"
|
|
|
|
ynh_store_file_checksum --file="$install_dir/coin/settings_local.py"
|
2017-04-09 11:05:39 +02:00
|
|
|
|
2019-08-23 16:08:03 +02:00
|
|
|
# SERVE STATIC FILES IN PRODUCTION MODE
|
2023-12-16 15:11:09 +01:00
|
|
|
ln -s $install_dir/$app/static $install_dir/static
|
2017-04-09 11:05:39 +02:00
|
|
|
|
2023-12-16 15:11:09 +01:00
|
|
|
pushd $install_dir
|
2022-09-03 00:23:04 +02:00
|
|
|
ynh_exec_warn_less $ynh_python manage.py migrate --noinput
|
|
|
|
ynh_exec_warn_less $ynh_python manage.py collectstatic --noinput
|
2022-03-14 20:39:33 +01:00
|
|
|
popd
|
2017-04-09 11:05:39 +02:00
|
|
|
|
2019-08-23 16:08:03 +02:00
|
|
|
# Set permissions to directory
|
2023-12-16 15:11:09 +01:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2022-03-13 23:43:18 +01:00
|
|
|
|
2023-12-16 15:11:09 +01:00
|
|
|
# Setup log permissions
|
2019-08-23 16:08:03 +02:00
|
|
|
mkdir -p /var/log/$app
|
|
|
|
chown -R $app /var/log/$app
|
2022-03-13 23:43:18 +01:00
|
|
|
chown -R $app:www-data "/var/log/$app"
|
2017-04-09 11:05:39 +02:00
|
|
|
|
2022-09-04 16:10:58 +02:00
|
|
|
#=================================================
|
2022-03-13 23:43:18 +01:00
|
|
|
# ADD A CONFIGURATION
|
|
|
|
#=================================================
|
2023-12-16 15:11:09 +01:00
|
|
|
ynh_script_progression --message="Adding a configuration file..."
|
2017-04-09 11:05:39 +02:00
|
|
|
|
2023-12-16 15:11:09 +01:00
|
|
|
ynh_add_config --template="gunicorn_config.py" --destination="$install_dir/gunicorn_config.py"
|
2022-03-13 23:43:18 +01:00
|
|
|
|
2023-12-16 15:11:09 +01:00
|
|
|
chown $app:www-data "$install_dir/gunicorn_config.py"
|
2017-04-09 11:05:39 +02:00
|
|
|
|
2019-08-23 16:08:03 +02:00
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
2023-12-16 15:11:09 +01:00
|
|
|
ynh_script_progression --message="Configuring system..."
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2017-04-09 11:05:39 +02:00
|
|
|
|
2019-08-23 16:08:03 +02:00
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_add_systemd_config
|
2017-04-09 11:05:39 +02:00
|
|
|
|
2023-12-16 15:11:09 +01:00
|
|
|
# Integrating service in YunoHost
|
2022-03-13 23:43:18 +01:00
|
|
|
yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.log"
|
2019-08-23 16:08:03 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2023-12-16 15:11:09 +01:00
|
|
|
ynh_script_progression --message="Starting systemd service..."
|
2019-08-23 16:08:03 +02:00
|
|
|
|
|
|
|
# Start a systemd service
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2017-04-09 11:05:39 +02:00
|
|
|
|
2022-09-03 00:23:04 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|