mirror of
https://github.com/YunoHost-Apps/plume_ynh.git
synced 2024-09-03 20:15:54 +02:00
commit
e99273dfb8
8 changed files with 85 additions and 54 deletions
|
@ -42,7 +42,6 @@ There is **No LDAP** support for Plume yet but the app can be used by multiple u
|
||||||
|
|
||||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/plume/)
|
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/plume/)
|
||||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/plume/)
|
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/plume/)
|
||||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/plume/)
|
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
source ../settings/scripts/ynh_systemd_action
|
source ../settings/scripts/ynh_systemd_action
|
||||||
|
@ -13,6 +14,7 @@ source ../settings/scripts/ynh_systemd_action
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Managing script failure..."
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
|
|
|
@ -35,6 +35,23 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
#db_user=$db_name
|
#db_user=$db_name
|
||||||
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Backing up the app before changing its url (may take a while)..."
|
||||||
|
|
||||||
|
# Backup the current version of the app
|
||||||
|
ynh_backup_before_upgrade
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||||
|
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
|
|
||||||
|
# restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -54,7 +71,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Stopping a systemd service..."
|
ynh_print_info --message="Stopping a systemd service..."
|
||||||
|
|
||||||
|
@ -96,16 +113,17 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Modifying a config file..."
|
ynh_print_info --message="Modifying a config file..."
|
||||||
|
|
||||||
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$final_path/$app/.env"
|
config_file="$final_path/$app/.env"
|
||||||
|
ynh_backup_if_checksum_is_different --file=$config_file
|
||||||
|
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file=$config_file
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CONFIG FILE CHECKSUM
|
# STORE THE CONFIG FILE CHECKSUM
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Soring the config file checksum..."
|
ynh_print_info --message="Soring the config file checksum..."
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/$app/.env"
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
ynh_store_file_checksum --file="$final_path/$app/.env"
|
ynh_store_file_checksum --file=$config_file
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
|
|
@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Managing script failure..."
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
|
@ -23,6 +24,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Retrieving arguments from the manifest..."
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url="/"
|
path_url="/"
|
||||||
|
@ -32,7 +34,7 @@ password=$YNH_APP_ARG_PASSWORD
|
||||||
instance_name=$YNH_APP_ARG_NAME
|
instance_name=$YNH_APP_ARG_NAME
|
||||||
registration=$YNH_APP_ARG_REGISTRATION
|
registration=$YNH_APP_ARG_REGISTRATION
|
||||||
admin_email=$(ynh_user_get_info $admin 'mail')
|
admin_email=$(ynh_user_get_info $admin 'mail')
|
||||||
secret_key=$(ynh_string_random 32 | base64)
|
secret_key=$(ynh_string_random --length=32 | base64)
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -76,9 +78,8 @@ ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Configuring firewall ..."
|
ynh_print_info --message="Configuring firewall ..."
|
||||||
|
|
||||||
# Find a free port
|
# Find an available port
|
||||||
port=$(ynh_find_port --port=8095)
|
port=$(ynh_find_port --port=8095)
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -94,9 +95,9 @@ ynh_install_app_dependencies $pkg_dependencies
|
||||||
ynh_print_info --message="Creating a PostgreSQL database..."
|
ynh_print_info --message="Creating a PostgreSQL database..."
|
||||||
|
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
db_name=$(ynh_sanitize_dbid $app)
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
db_pwd=$(ynh_string_random 30)
|
db_pwd=$(ynh_string_random --length=30)
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||||
|
@ -151,18 +152,21 @@ chown -R "$app":"$app" "/var/log/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Modifying a config file..."
|
||||||
|
|
||||||
# setup application config
|
# setup application config
|
||||||
cp "../conf/.env" "$final_path/$app/.env"
|
config_file="$final_path/$app/.env"
|
||||||
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/$app/.env"
|
cp "../conf/.env" $config_file
|
||||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/$app/.env"
|
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file=$config_file
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/$app/.env"
|
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file=$config_file
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/$app/.env"
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file=$config_file
|
||||||
ynh_replace_string --match_string="__SECRET_KEY__" --replace_string="$secret_key" --target_file="$final_path/$app/.env"
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file=$config_file
|
||||||
|
ynh_replace_string --match_string="__SECRET_KEY__" --replace_string="$secret_key" --target_file=$config_file
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MAKE SETUP
|
# MAKE SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Making setup..."
|
||||||
|
|
||||||
# Set right permissions
|
# Set right permissions
|
||||||
chown -R "$app":"$app" $final_path
|
chown -R "$app":"$app" $final_path
|
||||||
|
@ -198,15 +202,17 @@ ynh_add_systemd_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE THE CONFIG FILE CHECKSUM
|
# STORE THE CONFIG FILE CHECKSUM
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Storing the config file checksum..."
|
||||||
|
|
||||||
# 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 --file="$final_path/$app/.env"
|
ynh_store_file_checksum --file=$config_file
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SECURE FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Securing files and directories..."
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R $app: $final_path
|
chown -R $app: $final_path
|
||||||
|
@ -220,10 +226,11 @@ ynh_print_info --message="Configuring log rotation..."
|
||||||
ynh_use_logrotate
|
ynh_use_logrotate
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
yunohost service add $app --description "$app daemon for XXX" --log "/var/log/$app/$app.log"
|
yunohost service add $app --description "$app daemon for Plume" --log "/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
|
|
|
@ -25,11 +25,12 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SERVICE FROM ADMIN PANEL
|
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Removing service integration in YunoHost..."
|
||||||
|
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
|
||||||
if yunohost service status $app >/dev/null 2>&1
|
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||||
then
|
then
|
||||||
ynh_print_info --message="Removing $app service..."
|
ynh_print_info --message="Removing $app service..."
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
|
@ -96,7 +97,7 @@ ynh_remove_logrotate
|
||||||
#=================================================
|
#=================================================
|
||||||
# CLOSE A PORT
|
# CLOSE A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Close ports"
|
ynh_print_info --message="Closing a port..."
|
||||||
|
|
||||||
if yunohost firewall list | grep -q "\- $port$"
|
if yunohost firewall list | grep -q "\- $port$"
|
||||||
then
|
then
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source ../settings/scripts/ynh_detect_arch__2
|
source ../settings/scripts/ynh_detect_arch__2
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
@ -13,6 +14,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Managing script failure..."
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
|
@ -32,7 +34,6 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
@ -49,6 +50,7 @@ test ! -d $final_path \
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Restoring the nginx configuration..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
@ -70,6 +72,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Restoring user rights..."
|
||||||
|
|
||||||
# Restore permissions on app files
|
# Restore permissions on app files
|
||||||
chown -R "$app":"$app" $final_path
|
chown -R "$app":"$app" $final_path
|
||||||
|
@ -90,7 +93,7 @@ ynh_install_app_dependencies $pkg_dependencies
|
||||||
ynh_print_info --message="Restoring the PostgreSQL database..."
|
ynh_print_info --message="Restoring the PostgreSQL database..."
|
||||||
|
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
|
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||||
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
||||||
|
|
||||||
|
@ -111,25 +114,25 @@ mkdir -p "/var/log/$app"
|
||||||
chown -R "$app":"$app" "/var/log/$app"
|
chown -R "$app":"$app" "/var/log/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SSTART SYSTEMD SERVICE
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
|
yunohost service add $app --description "$app daemon for Plume" --log "/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Starting a systemd service..."
|
ynh_print_info --message="Starting a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --action=start --service_name=$app
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started plume"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Advertising service in admin panel..."
|
|
||||||
|
|
||||||
yunohost service add $app --log "/var/log/$app/$app.log"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Restoring the logrotate configuration..."
|
ynh_print_info --message="Restoring the logrotate configuration..."
|
||||||
|
|
||||||
ynh_restore_file "/etc/logrotate.d/$app"
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -31,6 +31,7 @@ architecture=$(ynh_detect_arch)
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_print_info --message="Checking version..."
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
@ -88,7 +89,6 @@ ynh_print_info --message="Backing up the app before upgrading (may take a while)
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
read -p "key"
|
|
||||||
# restore it if the upgrade fails
|
# restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
|
@ -121,7 +121,7 @@ then
|
||||||
ynh_print_info --message="Upgrading source files..."
|
ynh_print_info --message="Upgrading source files..."
|
||||||
|
|
||||||
# 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/$app" $architecture
|
ynh_setup_source --dest_dir="$final_path/$app" --source_id=$architecture
|
||||||
|
|
||||||
# Move binaries
|
# Move binaries
|
||||||
mv $final_path/$app/bin/* $final_path/.cargo/bin/
|
mv $final_path/$app/bin/* $final_path/.cargo/bin/
|
||||||
|
@ -183,9 +183,10 @@ popd
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Storing the config file checksum..."
|
ynh_print_info --message="Storing the config file checksum..."
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/.env"
|
config_file="$final_path/$app/.env"
|
||||||
|
ynh_backup_if_checksum_is_different --file=$config_file
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
ynh_store_file_checksum --file="$final_path/$app/.env"
|
ynh_store_file_checksum --file=$config_file
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
|
|
Loading…
Add table
Reference in a new issue