1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cac-proxy_ynh.git synced 2024-09-03 18:16:07 +02:00
cac-proxy_ynh/scripts/install

95 lines
3.2 KiB
Text
Raw Normal View History

2023-01-11 18:59:44 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
2024-01-05 16:20:44 +01:00
# INSTALL NODEJS
2023-01-11 18:59:44 +01:00
#=================================================
2024-01-05 16:20:44 +01:00
ynh_script_progression --message="Installing NodeJS..." --weight=3
2023-01-11 18:59:44 +01:00
ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_use_nodejs
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=6
# Download, check integrity, uncompress and patch the source from amd64.src
2024-01-05 16:20:44 +01:00
ynh_setup_source --dest_dir="$install_dir/package"
2023-01-14 10:17:35 +01:00
2024-01-05 16:20:44 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
2023-01-14 10:17:35 +01:00
2024-01-05 16:20:44 +01:00
#=================================================
# ADD SSH ACCESS
#=================================================
2023-01-14 10:17:35 +01:00
2024-01-05 16:20:44 +01:00
if [ -n "$public_key" ]; then
ynh_script_progression --message="Enabling ssh access for dev..." --weight=1
# enable ssh access to the files for updates
# todo: Secure it more with https://github.com/YunoHost-Apps/ssh_chroot_dir_ynh
mkdir --parents "$install_dir/.ssh"
ynh_add_config --template="authorized_keys" --destination="$install_dir/.ssh/authorized_keys"
2023-01-14 10:17:35 +01:00
2024-01-05 16:20:44 +01:00
chown -R "$app:$app" "$install_dir/.ssh"
chmod 700 "$install_dir/.ssh"
chmod 600 "$install_dir/.ssh/authorized_keys"
2023-01-14 10:17:35 +01:00
2024-01-05 16:20:44 +01:00
_install_restart_script_and_sudoers
2023-01-14 10:17:35 +01:00
fi
2023-02-26 15:36:39 +01:00
#=================================================
# Install chromium
#=================================================
2024-01-05 16:20:44 +01:00
if [ $install_chromium -eq 1 ]; then
ynh_script_progression --message="Installing Chromium..." --weight=8
2023-02-26 15:36:39 +01:00
2024-01-05 16:20:44 +01:00
pushd "$install_dir/package"
ynh_exec_as "$app" $ynh_node_load_PATH $ynh_node "./node_modules/puppeteer/install.js"
popd
2023-02-26 15:36:39 +01:00
fi
2023-01-11 18:59:44 +01:00
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
2024-01-05 16:20:44 +01:00
_generate_env_file
2023-01-11 18:59:44 +01:00
#=================================================
2024-01-05 16:20:44 +01:00
# SYSTEM CONFIGURATION
2023-01-11 18:59:44 +01:00
#=================================================
2024-01-05 16:20:44 +01:00
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
2023-01-11 18:59:44 +01:00
2024-01-05 16:20:44 +01:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2023-01-11 18:59:44 +01:00
# Create a dedicated systemd config
ynh_add_systemd_config
2024-01-05 16:20:44 +01:00
yunohost service add $app --description="A Cors proxy letting the browser manages cookies and redirects." --log="/var/log/$app/$app.log"
2023-01-11 18:59:44 +01:00
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# 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="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last