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

132 lines
4.4 KiB
Text
Raw Normal View History

2016-03-01 10:47:41 +01:00
#!/bin/bash
2018-11-30 14:47:44 +01:00
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE FAILURE OF THE SCRIPT
#=================================================
ynh_clean_setup () {
2021-02-08 09:32:10 +01:00
### Remove this function if there's nothing to clean before calling the remove script.
true
2018-11-30 14:47:44 +01:00
}
2021-02-08 09:32:10 +01:00
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
2018-11-30 14:47:44 +01:00
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME
2018-11-30 14:47:44 +01:00
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
2021-02-08 09:32:10 +01:00
ynh_script_progression --message="Validating installation parameters..."
2018-11-30 14:47:44 +01:00
final_path=/var/www/$app
2021-02-08 09:32:10 +01:00
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
2018-11-30 14:47:44 +01:00
# Register (book) web path
2021-02-08 09:32:10 +01:00
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
2018-11-30 14:47:44 +01:00
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2021-02-08 09:32:10 +01:00
ynh_script_progression --message="Storing installation settings..."
2018-11-30 14:47:44 +01:00
2021-02-08 09:45:08 +01:00
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
2018-11-30 14:47:44 +01:00
#=================================================
# STANDARD MODIFICATIONS
#=================================================
2019-02-26 23:56:20 +01:00
# INSTALL SOURCES
2018-11-30 14:47:44 +01:00
#=================================================
2019-02-26 23:56:20 +01:00
# To avoid a complete rebuild, I downloaded the gh-pages as explained here: https://github.com/keeweb/keeweb#self-hosting
# and put all files in "../sources/extra_files/app/", like that I can assure the version install in YunoHost is the version described in the manifest
mkdir -p "$final_path"
2019-02-26 23:58:19 +01:00
cp -r ../sources/extra_files/app/* "$final_path"
2018-11-30 14:47:44 +01:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2021-02-08 09:32:10 +01:00
ynh_script_progression --message="Configuring NGINX web server..."
2018-11-30 14:47:44 +01:00
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# USE THE CONFIG FILE
#=================================================
2019-02-26 23:56:20 +01:00
ynh_replace_string "(no-config)" "config.json" "$final_path/index.html"
2018-11-30 14:47:44 +01:00
#=================================================
# COPY THE CONFIG FILE
#=================================================
2021-02-08 09:32:10 +01:00
cp ../conf/config.json "$final_path/config.json"
2018-11-30 14:47:44 +01:00
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# Enregistre la somme de contrôle du fichier de config
2019-02-26 23:56:20 +01:00
ynh_store_file_checksum "$final_path/config.json"
2018-11-30 14:47:44 +01:00
#=================================================
# GENERIC FINALISATION
#=================================================
# SECURING FILES AND DIRECTORIES
#=================================================
# Les fichiers appartiennent à root
chown -R root: $final_path
#=================================================
# SETUP SSOWAT
#=================================================
2021-02-08 09:32:10 +01:00
ynh_script_progression --message="Configuring permissions..."
2018-11-30 14:47:44 +01:00
# Make app public if necessary
if [ $is_public -eq 1 ]
then
2021-02-08 09:32:10 +01:00
ynh_permission_update --permission="main" --add="visitors"
2018-11-30 14:47:44 +01:00
fi
#=================================================
# RELOAD NGINX
#=================================================
2021-02-08 09:32:10 +01:00
ynh_script_progression --message="Reloading NGINX web server..."
2018-11-30 14:47:44 +01:00
2021-02-08 09:32:10 +01:00
ynh_systemd_action --service_name=nginx --action=reload
2018-11-30 14:47:44 +01:00
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
message="If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/keeweb_ynh"
ynh_send_readme_to_admin --app_message="$message" --recipients="root"
2021-02-08 09:32:10 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last