mirror of
https://github.com/YunoHost-Apps/coin_ynh.git
synced 2024-09-03 18:16:26 +02:00
97 lines
3 KiB
Bash
97 lines
3 KiB
Bash
#!/bin/bash
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
secret=$(ynh_string_random 24)
|
|
ynh_app_setting_set --app=$app --key=secret --value=$secret
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..."
|
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# SPECIFIC SETUP
|
|
#=================================================
|
|
# PYTHON DEPENDENCIES
|
|
#=================================================
|
|
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
|
|
popd
|
|
|
|
#=================================================
|
|
# CONFIGURATION DJANGO
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring application..."
|
|
|
|
ynh_add_config --jinja --template=local.py.j2 --destination="$install_dir/coin/settings_local.py"
|
|
chmod 400 "$install_dir/coin/settings_local.py"
|
|
chown $app "$install_dir/coin/settings_local.py"
|
|
|
|
# SERVE STATIC FILES IN PRODUCTION MODE
|
|
ln -s $install_dir/$app/static $install_dir/static
|
|
|
|
pushd $install_dir
|
|
ynh_exec_warn_less venv/bin/python3 manage.py migrate --noinput
|
|
ynh_exec_warn_less venv/bin/python3 manage.py collectstatic --noinput
|
|
popd
|
|
|
|
# Set permissions to directory
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
# Setup log permissions
|
|
mkdir -p /var/log/$app
|
|
chown -R $app /var/log/$app
|
|
chown -R $app:www-data "/var/log/$app"
|
|
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding a configuration file..."
|
|
|
|
ynh_add_config --template="gunicorn_config.py" --destination="$install_dir/gunicorn_config.py"
|
|
|
|
chown $app:www-data "$install_dir/gunicorn_config.py"
|
|
|
|
#=================================================
|
|
# SETUP SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring system..."
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config
|
|
|
|
# Integrating service in YunoHost
|
|
yunohost service add $app --description "$app daemon" --log="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting systemd service..."
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|