|
|
@ -46,7 +46,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Validating installation parameters..."
|
|
|
|
ynh_print_info --message="Validating installation parameters..."
|
|
|
|
|
|
|
|
|
|
|
|
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
|
|
|
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
|
|
|
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
|
|
|
|
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
|
|
|
@ -54,25 +54,25 @@ final_path=/var/www/$app
|
|
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|
|
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|
|
|
|
|
|
|
|
|
|
|
# Register (book) web path
|
|
|
|
# Register (book) web path
|
|
|
|
ynh_webpath_register $app $domain $path_url
|
|
|
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Storing installation settings..."
|
|
|
|
ynh_print_info --message="Storing installation settings..."
|
|
|
|
|
|
|
|
|
|
|
|
ynh_app_setting_set $app domain $domain
|
|
|
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
|
|
|
ynh_app_setting_set $app path $path_url
|
|
|
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
|
|
|
ynh_app_setting_set $app admin $admin
|
|
|
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
|
|
|
ynh_app_setting_set $app is_public $is_public
|
|
|
|
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
|
|
|
ynh_app_setting_set $app language $language
|
|
|
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# FIND AND OPEN A PORT
|
|
|
|
# FIND AND OPEN A PORT
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Configuring firewall..."
|
|
|
|
ynh_print_info --message="Configuring firewall..."
|
|
|
|
|
|
|
|
|
|
|
|
### Use these lines if you have to open a port for the application
|
|
|
|
### Use these lines if you have to open a port for the application
|
|
|
|
### `ynh_find_port` will find the first available port starting from the given port.
|
|
|
|
### `ynh_find_port` will find the first available port starting from the given port.
|
|
|
@ -83,12 +83,12 @@ ynh_print_info "Configuring firewall..."
|
|
|
|
port=$(ynh_find_port 8095)
|
|
|
|
port=$(ynh_find_port 8095)
|
|
|
|
# Open this port
|
|
|
|
# Open this port
|
|
|
|
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
|
|
|
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
|
|
|
ynh_app_setting_set $app port $port
|
|
|
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Installing dependencies..."
|
|
|
|
ynh_print_info --message="Installing dependencies..."
|
|
|
|
|
|
|
|
|
|
|
|
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
|
|
|
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
|
|
|
### Those deb packages will be installed as dependencies of this package.
|
|
|
|
### Those deb packages will be installed as dependencies of this package.
|
|
|
@ -103,7 +103,7 @@ ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# CREATE A MYSQL DATABASE
|
|
|
|
# CREATE A MYSQL DATABASE
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Creating a MySQL database..."
|
|
|
|
ynh_print_info --message="Creating a MySQL database..."
|
|
|
|
|
|
|
|
|
|
|
|
### Use these lines if you need a database for the application.
|
|
|
|
### Use these lines if you need a database for the application.
|
|
|
|
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
|
|
|
|
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
|
|
|
@ -115,26 +115,26 @@ ynh_print_info "Creating a MySQL database..."
|
|
|
|
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
|
|
|
|
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
|
|
|
|
|
|
|
|
|
|
|
|
db_name=$(ynh_sanitize_dbid $app)
|
|
|
|
db_name=$(ynh_sanitize_dbid $app)
|
|
|
|
ynh_app_setting_set $app db_name $db_name
|
|
|
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
|
|
|
ynh_mysql_setup_db $db_name $db_name
|
|
|
|
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Setting up source files..."
|
|
|
|
ynh_print_info --message="Setting up source files..."
|
|
|
|
|
|
|
|
|
|
|
|
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
|
|
|
|
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
|
|
|
|
### downloaded from an upstream source, like a git repository.
|
|
|
|
### downloaded from an upstream source, like a git repository.
|
|
|
|
### `ynh_setup_source` use the file conf/app.src
|
|
|
|
### `ynh_setup_source` use the file conf/app.src
|
|
|
|
|
|
|
|
|
|
|
|
ynh_app_setting_set $app final_path $final_path
|
|
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source "$final_path"
|
|
|
|
ynh_setup_source --dest_dir="$final_path"
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Configuring nginx web server..."
|
|
|
|
ynh_print_info --message="Configuring nginx web server..."
|
|
|
|
|
|
|
|
|
|
|
|
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
|
|
|
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
|
|
|
|
|
|
|
|
|
|
@ -144,15 +144,15 @@ ynh_add_nginx_config
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Configuring system user..."
|
|
|
|
ynh_print_info --message="Configuring system user..."
|
|
|
|
|
|
|
|
|
|
|
|
# Create a system user
|
|
|
|
# Create a system user
|
|
|
|
ynh_system_user_create $app
|
|
|
|
ynh_system_user_create --username=$app
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Configuring php-fpm..."
|
|
|
|
ynh_print_info --message="Configuring php-fpm..."
|
|
|
|
|
|
|
|
|
|
|
|
### `ynh_add_fpm_config` is used to set up a PHP config.
|
|
|
|
### `ynh_add_fpm_config` is used to set up a PHP config.
|
|
|
|
### You can remove it if your app doesn't use PHP.
|
|
|
|
### You can remove it if your app doesn't use PHP.
|
|
|
@ -177,7 +177,7 @@ ynh_add_fpm_config
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Configuring a systemd service..."
|
|
|
|
ynh_print_info --message="Configuring a systemd service..."
|
|
|
|
|
|
|
|
|
|
|
|
### `ynh_systemd_config` is used to configure a systemd script for an app.
|
|
|
|
### `ynh_systemd_config` is used to configure a systemd script for an app.
|
|
|
|
### It can be used for apps that use sysvinit (with adaptation) or systemd.
|
|
|
|
### It can be used for apps that use sysvinit (with adaptation) or systemd.
|
|
|
@ -206,8 +206,8 @@ ynh_add_systemd_config
|
|
|
|
chown -R $app: $final_path
|
|
|
|
chown -R $app: $final_path
|
|
|
|
|
|
|
|
|
|
|
|
# Set the app as temporarily public for curl call
|
|
|
|
# Set the app as temporarily public for curl call
|
|
|
|
ynh_print_info "Configuring SSOwat..."
|
|
|
|
ynh_print_info --message="Configuring SSOwat..."
|
|
|
|
ynh_app_setting_set $app skipped_uris "/"
|
|
|
|
ynh_app_setting_set --app=$app --key=skipped_uris --value="/"
|
|
|
|
# Reload SSOwat config
|
|
|
|
# Reload SSOwat config
|
|
|
|
yunohost app ssowatconf
|
|
|
|
yunohost app ssowatconf
|
|
|
|
|
|
|
|
|
|
|
@ -215,13 +215,13 @@ yunohost app ssowatconf
|
|
|
|
systemctl reload nginx
|
|
|
|
systemctl reload nginx
|
|
|
|
|
|
|
|
|
|
|
|
# Installation with curl
|
|
|
|
# Installation with curl
|
|
|
|
ynh_print_info "Finalizing installation..."
|
|
|
|
ynh_print_info --message="Finalizing installation..."
|
|
|
|
ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
|
|
|
|
ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
|
|
|
|
|
|
|
|
|
|
|
|
# Remove the public access
|
|
|
|
# Remove the public access
|
|
|
|
if [ $is_public -eq 0 ]
|
|
|
|
if [ $is_public -eq 0 ]
|
|
|
|
then
|
|
|
|
then
|
|
|
|
ynh_app_setting_delete $app skipped_uris
|
|
|
|
ynh_app_setting_delete --app=$app --key=skipped_uris
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
@ -231,7 +231,7 @@ fi
|
|
|
|
### `ynh_replace_string` is used to replace a string in a file.
|
|
|
|
### `ynh_replace_string` is used to replace a string in a file.
|
|
|
|
### (It's compatible with sed regular expressions syntax)
|
|
|
|
### (It's compatible with sed regular expressions syntax)
|
|
|
|
|
|
|
|
|
|
|
|
ynh_replace_string "match_string" "replace_string" "$final_path/CONFIG_FILE"
|
|
|
|
ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/CONFIG_FILE"
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# STORE THE CONFIG FILE CHECKSUM
|
|
|
|
# STORE THE CONFIG FILE CHECKSUM
|
|
|
@ -242,7 +242,7 @@ ynh_replace_string "match_string" "replace_string" "$final_path/CONFIG_FILE"
|
|
|
|
### you can make a backup of this file before modifying it again if the admin had modified it.
|
|
|
|
### you can make a backup of this file before modifying it again if the admin had modified it.
|
|
|
|
|
|
|
|
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
|
|
|
ynh_store_file_checksum "$final_path/CONFIG_FILE"
|
|
|
|
ynh_store_file_checksum --file="$final_path/CONFIG_FILE"
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
# GENERIC FINALIZATION
|
|
|
@ -260,7 +260,7 @@ chown -R root: $final_path
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# SETUP LOGROTATE
|
|
|
|
# SETUP LOGROTATE
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Configuring log rotation..."
|
|
|
|
ynh_print_info --message="Configuring log rotation..."
|
|
|
|
|
|
|
|
|
|
|
|
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
|
|
|
|
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
|
|
|
|
### Use this helper only if there is effectively a log file for this app.
|
|
|
|
### Use this helper only if there is effectively a log file for this app.
|
|
|
@ -292,19 +292,19 @@ yunohost service add $app --log "/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Configuring SSOwat..."
|
|
|
|
ynh_print_info --message="Configuring SSOwat..."
|
|
|
|
|
|
|
|
|
|
|
|
# Make app public if necessary
|
|
|
|
# Make app public if necessary
|
|
|
|
if [ $is_public -eq 1 ]
|
|
|
|
if [ $is_public -eq 1 ]
|
|
|
|
then
|
|
|
|
then
|
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
|
|
|
ynh_app_setting_set $app unprotected_uris "/"
|
|
|
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
ynh_print_info "Reloading nginx web server..."
|
|
|
|
ynh_print_info --message="Reloading nginx web server..."
|
|
|
|
|
|
|
|
|
|
|
|
systemctl reload nginx
|
|
|
|
systemctl reload nginx
|
|
|
|
|
|
|
|
|
|
|
@ -312,4 +312,4 @@ systemctl reload nginx
|
|
|
|
# END OF SCRIPT
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
|
|
|
|
ynh_print_info "Installation of $app completed"
|
|
|
|
ynh_print_info --message="Installation of $app completed"
|
|
|
|