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

120 lines
4.4 KiB
Text
Raw Normal View History

2016-09-09 11:07:28 +02:00
#!/bin/bash
2018-04-14 22:02:50 +02:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2016-09-09 11:07:28 +02:00
2018-04-14 22:02:50 +02:00
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
2022-02-09 00:51:15 +01:00
#=================================================
2016-09-09 11:07:28 +02:00
2022-06-15 01:48:45 +02:00
salt=$(ynh_string_random --length=40)
ynh_app_setting_set --app=$app --key=salt --value=$salt
2019-07-14 18:42:38 +02:00
2018-04-14 22:02:50 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2022-10-03 08:37:22 +02:00
ynh_script_progression --message="Installing dependencies..." --weight=1
2020-12-13 21:40:17 +01:00
2022-02-09 00:51:15 +01:00
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
2018-04-14 22:02:50 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2022-10-03 08:37:22 +02:00
ynh_script_progression --message="Setting up source files..." --weight=1
2018-04-14 22:02:50 +02:00
# Download, check integrity, uncompress and patch the source from app.src
2023-05-22 23:31:46 +02:00
ynh_setup_source --dest_dir="$install_dir"
2016-09-09 11:07:28 +02:00
2023-05-22 23:31:46 +02:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2022-02-09 00:51:15 +01:00
2018-04-14 22:02:50 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2022-10-03 08:37:22 +02:00
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
2016-09-09 11:07:28 +02:00
2022-02-09 00:51:15 +01:00
# Create a dedicated NGINX config
2018-04-14 22:02:50 +02:00
ynh_add_nginx_config
2023-05-22 23:31:46 +02:00
# 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"
2018-04-14 22:02:50 +02:00
#=================================================
# SPECIFIC SETUP
#=================================================
2022-02-09 00:51:15 +01:00
# INSTALL WOOB WITH PIP
2018-04-14 22:02:50 +02:00
#=================================================
2022-10-03 08:37:22 +02:00
ynh_script_progression --message="Installing woob..." --weight=1
2020-12-13 21:40:17 +01:00
2022-10-03 08:37:22 +02:00
locale-gen C.UTF-8
update-locale C.UTF-8
2023-05-22 23:31:46 +02:00
ynh_exec_as $app virtualenv --python=python3 --system-site-packages "${install_dir}/venv"
2018-04-14 23:11:53 +02:00
(
set +o nounset
2023-05-22 23:31:46 +02:00
source "${install_dir}/venv/bin/activate"
2018-04-14 23:11:53 +02:00
set -o nounset
2018-04-14 22:02:50 +02:00
2023-05-22 23:31:46 +02:00
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"
2022-10-03 08:37:22 +02:00
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
2023-05-22 23:31:46 +02:00
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"
2018-04-14 23:11:53 +02:00
)
2018-04-14 22:02:50 +02:00
#=================================================
2022-10-03 08:37:22 +02:00
# INSTALL KRESUS WITH NPM
2018-04-14 22:02:50 +02:00
#=================================================
2023-05-22 23:31:46 +02:00
ynh_script_progression --message="Installing $app..." --weight=1
2020-12-13 21:40:17 +01:00
2023-05-22 23:31:46 +02:00
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
2022-10-03 08:37:22 +02:00
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean --all
2023-05-22 23:31:46 +02:00
ynh_secure_remove --file="$install_dir/.cache"
ynh_secure_remove --file="$install_dir/.yarn"
popd
2018-04-14 22:02:50 +02:00
#=================================================
2022-02-09 00:51:15 +01:00
# ADD A CONFIGURATION
2018-04-14 22:02:50 +02:00
#=================================================
2022-10-03 08:37:22 +02:00
ynh_script_progression --message="Adding a configuration file..." --weight=1
2018-04-14 22:02:50 +02:00
2023-05-22 23:31:46 +02:00
ynh_add_config --template="../conf/config.ini" --destination="$install_dir/config.ini"
2018-04-14 22:02:50 +02:00
2023-05-22 23:31:46 +02:00
chmod 400 "$install_dir/config.ini"
chown $app:$app "$install_dir/config.ini"
2018-04-14 23:11:53 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-10-03 08:37:22 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
2022-02-09 00:51:15 +01:00
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready"
2020-12-13 21:40:17 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2022-10-03 08:37:22 +02:00
ynh_script_progression --message="Installation of $app completed" --last