1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00
ihatemoney_ynh/scripts/install

76 lines
2.9 KiB
Bash
Executable file

#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# SPECIFIC SETUP
#=================================================
# BUILD VENV
#=================================================
ynh_script_progression "Building venv..."
__ynh_python_venv_setup --venv_dir="$install_dir/venv" --packages "${pip_dependencies[*]}"
python_venv_site_packages=$(__ynh_python_venv_get_site_packages_dir -d "$install_dir/venv")
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression "Configuring NGINX web server..."
# Create a dedicated NGINX config
## Needs $python_venv_site_packages
ynh_config_add_nginx
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression "Adding $app's configuration..."
# Secret key for cookies encryption.
secret_key=$(ynh_string_random --length=32)
ynh_app_setting_set --key=secret_key --value="$secret_key"
hashed_password=$(_hash_password "$password")
ynh_app_setting_set --key=hashed_password --value="$hashed_password"
# Allows to comment some config lines if not using sub path
sub_path_only="$(if [[ "$path" == "/" ]]; then echo '# ' ; else echo ''; fi)"
ynh_config_add --template="gunicorn.conf.py" --destination="$install_dir/gunicorn.conf.py"
ynh_config_add --template="ihatemoney.cfg" --destination="$install_dir/ihatemoney.cfg"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
# Configure log directory
mkdir -p "/var/log/$app"
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "/var/log/$app"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression "Configuring $app's systemd service..."
# Create a dedicated systemd config
ynh_config_add_systemd
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression "Integrating service in YunoHost..."
yunohost service add "$app" --description="$app daemon for IHateMoney" --log=systemd
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemctl --service="$app" --action="start" --wait_until="Listening at"
wait_gunicorn_start
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Installation of $app completed"