2023-08-04 22:12:34 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2023-08-24 17:03:22 +02:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
2023-08-29 05:53:09 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=host_server_distribution --value="YunoHost"
|
2023-08-24 17:03:22 +02:00
|
|
|
|
2023-08-04 22:12:34 +02:00
|
|
|
#=================================================
|
|
|
|
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
|
|
|
#=================================================
|
|
|
|
# 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
|
2023-08-08 10:25:19 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir/sources"
|
|
|
|
mkdir $install_dir/public
|
2024-01-10 22:44:12 +01:00
|
|
|
|
2023-09-03 23:49:38 +02:00
|
|
|
# Empty html page to fix the CI
|
|
|
|
echo "<html><body>ChatonsInfos</body></html>" > $install_dir/public/index.html
|
2023-08-04 22:12:34 +02:00
|
|
|
# $install_dir will automatically be initialized with some decent
|
|
|
|
# permission by default ... however, you may need to recursively reapply
|
|
|
|
# ownership to all files such as after the ynh_setup_source step
|
2023-08-29 05:53:09 +02:00
|
|
|
chown -R root:root "$install_dir"
|
|
|
|
chown $app:www-data "$install_dir"
|
2023-08-08 10:25:19 +02:00
|
|
|
chown -R $app:www-data "$install_dir/public"
|
2023-08-24 17:03:22 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
2023-08-04 22:12:34 +02:00
|
|
|
|
2023-08-29 05:53:09 +02:00
|
|
|
#=================================================
|
|
|
|
# SYSTEM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config using the conf/nginx.conf template
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2023-08-04 22:12:34 +02:00
|
|
|
#=================================================
|
|
|
|
# APP INITIAL CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
# ADD A CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
2023-08-24 17:03:22 +02:00
|
|
|
|
|
|
|
cp "$install_dir/sources/MODELES/organization.properties" "$install_dir/public/"
|
2023-08-29 03:44:51 +02:00
|
|
|
orga_path="$install_dir/public/organization.properties"
|
|
|
|
|
|
|
|
ynh_write_var_in_file --file="$orga_path" --key="file.datetime" --value="$(date '+%Y-%m-%dT%H:%M:%S')"
|
|
|
|
ynh_write_var_in_file --file="$orga_path" --key="file.generator" --value="chatonsinfos_ynh"
|
|
|
|
|
2023-08-24 17:03:22 +02:00
|
|
|
chown -R $app:www-data "$install_dir/public"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERATE CONFIG PANEL
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Generating configuration panel..." --weight=1
|
|
|
|
|
|
|
|
generate_config_panel
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ADD A CRON JOB
|
|
|
|
#=================================================
|
2023-08-29 05:53:09 +02:00
|
|
|
ynh_script_progression --message="Adding cron job to generate metrics..." --weight=1
|
2023-08-04 22:12:34 +02:00
|
|
|
|
2023-08-24 17:03:22 +02:00
|
|
|
cron_path="/etc/cron.daily/$app"
|
2024-01-10 22:44:12 +01:00
|
|
|
ynh_add_config --template="cron" --destination="$cron_path"
|
2023-08-24 17:03:22 +02:00
|
|
|
chown root: "$cron_path"
|
|
|
|
chmod 644 "$cron_path"
|
2023-08-04 22:12:34 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2024-01-10 22:44:12 +01:00
|
|
|
|
2023-08-04 22:12:34 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|