mirror of
https://github.com/YunoHost-Apps/kresus_ynh.git
synced 2024-09-03 19:36:10 +02:00
119 lines
4.4 KiB
Bash
119 lines
4.4 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
#=================================================
|
|
|
|
salt=$(ynh_string_random --length=40)
|
|
ynh_app_setting_set --app=$app --key=salt --value=$salt
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing dependencies..." --weight=1
|
|
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
|
|
|
#=================================================
|
|
# 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
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
# Create a dedicated systemd config
|
|
ynh_add_systemd_config
|
|
|
|
mkdir -p "/var/log/$app/"
|
|
touch "/var/log/$app/$app.log"
|
|
chown -R $app:$app "/var/log/$app/"
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
ynh_use_logrotate
|
|
|
|
yunohost service add $app --description="Personal finance manager" --log="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# SPECIFIC SETUP
|
|
#=================================================
|
|
# INSTALL WOOB WITH PIP
|
|
#=================================================
|
|
ynh_script_progression --message="Installing woob..." --weight=1
|
|
|
|
locale-gen C.UTF-8
|
|
update-locale C.UTF-8
|
|
ynh_exec_as $app virtualenv --python=python3 --system-site-packages "${install_dir}/venv"
|
|
(
|
|
set +o nounset
|
|
source "${install_dir}/venv/bin/activate"
|
|
set -o nounset
|
|
|
|
ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y --default-toolchain=stable --profile=minimal'
|
|
export PATH="$install_dir/.cargo/bin:$PATH"
|
|
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade pip
|
|
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade setuptools
|
|
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install woob simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six Pillow --ignore-installed
|
|
ynh_secure_remove --file="$install_dir/.cargo"
|
|
ynh_secure_remove --file="$install_dir/.rustup"
|
|
ynh_secure_remove --file="$install_dir/.cache"
|
|
ynh_secure_remove --file="$install_dir/.local"
|
|
)
|
|
|
|
#=================================================
|
|
# INSTALL KRESUS WITH NPM
|
|
#=================================================
|
|
ynh_script_progression --message="Installing $app..." --weight=1
|
|
|
|
pushd $install_dir
|
|
ynh_use_nodejs
|
|
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn config set network-timeout 300000
|
|
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production
|
|
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean --all
|
|
ynh_secure_remove --file="$install_dir/.cache"
|
|
ynh_secure_remove --file="$install_dir/.yarn"
|
|
popd
|
|
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
|
|
|
ynh_add_config --template="../conf/config.ini" --destination="$install_dir/config.ini"
|
|
|
|
chmod 400 "$install_dir/config.ini"
|
|
chown $app:$app "$install_dir/config.ini"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|