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 () {
|
|
|
|
# Nettoyage des résidus d'installation non pris en charge par le script remove.
|
|
|
|
# Pas de nettoyage supplémentaire nécessaire ici...
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
2016-12-06 03:09:15 +01:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2018-11-30 14:47:44 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
final_path=/var/www/$app
|
|
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|
|
|
|
|
|
|
# Normalize the url path syntax
|
|
|
|
path_url=$(ynh_normalize_url_path $path_url)
|
|
|
|
|
|
|
|
# Check web path availability
|
|
|
|
ynh_webpath_available $domain $path_url
|
|
|
|
# Register (book) web path
|
|
|
|
ynh_webpath_register $app $domain $path_url
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_app_setting_set $app domain $domain
|
|
|
|
ynh_app_setting_set $app path $path_url
|
|
|
|
ynh_app_setting_set $app is_public $is_public
|
2019-02-26 23:56:20 +01:00
|
|
|
ynh_app_setting_set $app final_path $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"
|
|
|
|
cp ../sources/extra_files/app/* "$final_path"
|
2018-11-30 14:47:44 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
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
|
|
|
|
#=================================================
|
|
|
|
|
2019-02-26 23:56:20 +01:00
|
|
|
cp ../conf/config.json "$final_path/"
|
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
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Make app public if necessary
|
|
|
|
if [ $is_public -eq 1 ]
|
|
|
|
then
|
|
|
|
ynh_app_setting_set $app skipped_uris "/"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_system_reload --service_name=nginx
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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"
|