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

101 lines
3.1 KiB
Text
Raw Normal View History

2015-09-14 17:12:17 +02:00
#!/bin/bash
2022-02-13 22:09:18 +01:00
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2016-07-05 15:22:12 +02:00
2017-05-18 23:28:18 +02:00
source _common.sh
2022-02-13 22:09:18 +01:00
source /usr/share/yunohost/helpers
#=================================================
2024-03-20 19:36:05 +01:00
# INITIALIZE AND STORE SETTINGS
2022-02-13 22:09:18 +01:00
#=================================================
2024-03-20 20:49:39 +01:00
preinstall=0
2022-02-17 01:23:35 +01:00
2022-02-13 22:09:18 +01:00
#=================================================
2024-03-20 19:36:05 +01:00
# ADD SWAP
2022-02-13 22:09:18 +01:00
#=================================================
# if ! ynh_in_ci_tests; then
# ynh_script_progression "Adding swap..."
2024-03-20 22:52:21 +01:00
# ynh_add_swap --size=$swap_needed
# fi
2022-02-13 22:09:18 +01:00
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression "Configuring $app's PostgreSQL database..."
2022-02-17 01:23:35 +01:00
# Make sure that its encoding is UTF-8
ynh_psql_db_shell <<< "update pg_database set encoding = pg_char_to_encoding('UTF8') where datname = '$db_name'"
2022-02-13 22:09:18 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression "Setting up source files..."
2022-02-13 22:09:18 +01:00
# Download, check integrity, uncompress and patch the source from app.src
setup_files
#=================================================
# BUILD APP
#=================================================
ynh_script_progression "Building app..."
2022-02-13 22:09:18 +01:00
2024-03-20 19:36:05 +01:00
pushd "$install_dir"
ynh_hide_warnings ynh_exec_as_app \
2024-03-20 19:36:05 +01:00
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'
export PATH="$PATH:$install_dir/.cargo/bin:$install_dir/.local/bin:/usr/local/sbin"
if grep "python3" "$install_dir/$appname/$FORKNAME-bin" ; then
python3 -m venv venv
venv/bin/pip3 install --upgrade pip
venv/bin/pip3 install wheel
2024-03-20 20:49:39 +01:00
venv/bin/pip3 install -r "$appname/requirements.txt"
2024-03-20 19:36:05 +01:00
else
virtualenv venv
venv/bin/pip3 install --upgrade pip
venv/bin/pip install wheel
2024-03-20 20:49:39 +01:00
venv/bin/pip install -r "$appname/requirements.txt"
2024-03-20 19:36:05 +01:00
fi
ynh_safe_rm "$install_dir/.cargo"
ynh_safe_rm "$install_dir/.rustup"
2022-02-13 22:09:18 +01:00
popd
#=================================================
# SETUP DATABASE
#=================================================
ynh_script_progression "Setting up the database..."
2022-02-13 22:09:18 +01:00
2017-05-18 23:28:18 +02:00
setup_database
2016-12-14 21:45:41 +01:00
2022-02-13 22:09:18 +01:00
#=================================================
2024-03-20 19:36:05 +01:00
# SYSTEM CONFIGURATION
2022-02-13 22:09:18 +01:00
#=================================================
ynh_script_progression "Adding system configurations related to $app..."
2022-02-13 22:09:18 +01:00
2024-03-20 19:36:05 +01:00
# Create a dedicated NGINX config
ynh_config_add_nginx
2024-03-20 19:36:05 +01:00
# Create a dedicated systemd config
ynh_config_add_systemd
2024-03-20 19:36:05 +01:00
yunohost service add "$app" --log="/var/log/$app.log"
2022-02-13 22:09:18 +01:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
2022-02-13 22:09:18 +01:00
# Start a systemd service
ynh_systemctl --service="$app" --action="start" --log_path="/var/log/$app.log"
2022-02-13 22:09:18 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Installation of $app completed"