mirror of
https://github.com/YunoHost-Apps/lutim_ynh.git
synced 2024-09-03 19:36:24 +02:00
Merge 9d01bb1591
into 319b7620e0
This commit is contained in:
commit
3de32dc48a
10 changed files with 120 additions and 370 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
|||
*.swp
|
||||
*~
|
||||
Notes
|
||||
*.sw[op]
|
||||
.DS_Store
|
||||
|
|
|
@ -17,7 +17,8 @@ userdoc = "https://framagit.org/luc/lutim/wikis/home"
|
|||
code = "https://framagit.org/fiat-tux/hat-softwares/lutim"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.1.17"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = false
|
||||
ldap = false
|
||||
|
|
|
@ -1,15 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
||||
ynh_maintenance_mode_ON () {
|
||||
|
@ -22,7 +14,7 @@ ynh_maintenance_mode_ON () {
|
|||
fi
|
||||
|
||||
mkdir -p /var/www/html/
|
||||
|
||||
|
||||
# Create an html to serve as maintenance notice
|
||||
echo "<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -90,5 +82,3 @@ ynh_maintenance_mode_OFF () {
|
|||
|
||||
systemctl reload nginx
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,31 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# 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 /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
ynh_print_info "Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$install_dir"
|
||||
ynh_backup "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
|
@ -33,22 +24,22 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
ynh_backup "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
ynh_backup "/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/cron.d/$app"
|
||||
ynh_backup "/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -18,21 +12,19 @@ domain=$old_domain
|
|||
|
||||
ynh_maintenance_mode_ON
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop"
|
||||
ynh_systemctl --service=$app --action="stop"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
|
@ -40,17 +32,15 @@ ynh_change_url_nginx_config
|
|||
# REPLACE THE PATH IN THE CONFIG OF LUTIM
|
||||
#=================================================
|
||||
|
||||
ynh_replace_string --match_string="\(^ *prefix.*=> '\).*" --replace_string="\1$new_path'," --target_file="$install_dir/lutim.conf"
|
||||
ynh_replace --match="\(^ *prefix.*=> '\).*" --replace="\1$new_path'," --file="$install_dir/lutim.conf"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
ynh_systemctl --service=$app --action="start" --wait_until="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
|
||||
#=================================================
|
||||
# DEACTIVE MAINTENANCE MODE
|
||||
|
@ -64,4 +54,4 @@ ynh_maintenance_mode_OFF
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
186
scripts/config
186
scripts/config
|
@ -1,186 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC CODE
|
||||
#=================================================
|
||||
# DECLARE GENERIC FUNCTION
|
||||
#=================================================
|
||||
|
||||
config_file="$final_path/lutim.conf"
|
||||
|
||||
get_config_value() {
|
||||
option_name="$1"
|
||||
# Get the value of this option in the config file
|
||||
grep "$option_name *=>" "$config_file" | cut -d'>' -f2 | sed s'/ //g' | cut -d',' -f1
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# LOAD VALUES
|
||||
#=================================================
|
||||
|
||||
# Load the real value from the app config or elsewhere.
|
||||
# Then get the value from the form.
|
||||
# If the form has a value for a variable, take the value from the form,
|
||||
# Otherwise, keep the value from the app config.
|
||||
|
||||
# always_encrypt
|
||||
old_always_encrypt="$(get_config_value always_encrypt)"
|
||||
always_encrypt="${YNH_CONFIG_MAIN_CONFIGURATION_ALWAYS_ENCRYPT:-$old_always_encrypt}"
|
||||
|
||||
# antiflood
|
||||
old_antiflood="$(get_config_value anti_flood_delay)"
|
||||
antiflood="${YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD:-$old_antiflood}"
|
||||
|
||||
# delay
|
||||
old_delay="$(get_config_value default_delay)"
|
||||
if [ $old_delay -eq 0 ]; then
|
||||
old_delay=None
|
||||
elif [ $old_delay -eq 1 ]; then
|
||||
old_delay=Day
|
||||
elif [ $old_delay -eq 7 ]; then
|
||||
old_delay=Week
|
||||
elif [ $old_delay -eq 30 ]; then
|
||||
old_delay=Month
|
||||
else
|
||||
old_delay=Year
|
||||
fi
|
||||
delay="${YNH_CONFIG_MAIN_CONFIGURATION_DELAY:-$old_delay}"
|
||||
|
||||
# Overwrite settings.json file
|
||||
old_overwrite_settings="$(ynh_app_setting_get --app=$app --key=overwrite_settings)"
|
||||
overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}"
|
||||
|
||||
# Overwrite nginx configuration
|
||||
old_overwrite_nginx="$(ynh_app_setting_get --app=$app --key=overwrite_nginx)"
|
||||
overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}"
|
||||
|
||||
# Overwrite systemd configuration
|
||||
old_overwrite_systemd="$(ynh_app_setting_get --app=$app --key=overwrite_systemd)"
|
||||
overwrite_systemd="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD:-$old_overwrite_systemd}"
|
||||
|
||||
# Type of admin mail configuration
|
||||
old_admin_mail_html="$(ynh_app_setting_get --app=$app --key=admin_mail_html)"
|
||||
admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}"
|
||||
|
||||
#=================================================
|
||||
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
|
||||
#=================================================
|
||||
|
||||
show_config() {
|
||||
# here you are supposed to read some config file/database/other then print the values
|
||||
# ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ALWAYS_ENCRYPT=$always_encrypt"
|
||||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD=$antiflood"
|
||||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_DELAY=$delay"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# MODIFY THE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
apply_config() {
|
||||
|
||||
#=================================================
|
||||
# MODIFY LUTIM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
restart_lutim=0
|
||||
|
||||
# Change configuration if needed
|
||||
# always_encrypt
|
||||
if [ "$always_encrypt" != "$old_always_encrypt" ]
|
||||
then
|
||||
ynh_replace_string --match_string=".*always_encrypt *=>.*" --replace_string=" always_encrypt => $always_encrypt," --target_file="$config_file"
|
||||
restart_lutim=1
|
||||
fi
|
||||
|
||||
# antiflood
|
||||
if [ "$antiflood" != "$old_antiflood" ]
|
||||
then
|
||||
ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$config_file"
|
||||
# Disable anti_flood_delay if the delay is 0
|
||||
if [ $antiflood = 0 ]; then
|
||||
ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$config_file"
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=antiflood --value="$antiflood"
|
||||
restart_lutim=1
|
||||
fi
|
||||
|
||||
# delay
|
||||
if [ "$delay" != "$old_delay" ]
|
||||
then
|
||||
if [ $delay = None ]; then
|
||||
delay=0
|
||||
elif [ $delay = Day ]; then
|
||||
delay=1
|
||||
elif [ $delay = Week ]; then
|
||||
delay=7
|
||||
elif [ $delay = Month ]; then
|
||||
delay=30
|
||||
else
|
||||
delay=360
|
||||
fi
|
||||
ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$config_file"
|
||||
ynh_app_setting_set --app=$app --key=delay --value="$delay"
|
||||
restart_lutim=1
|
||||
fi
|
||||
|
||||
if [ $restart_lutim -eq 1 ]
|
||||
then
|
||||
# Wait for lutim to be fully started
|
||||
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# MODIFY OVERWRITTING SETTINGS
|
||||
#=================================================
|
||||
|
||||
# Set overwrite_settings
|
||||
ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings"
|
||||
# Set overwrite_nginx
|
||||
ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx"
|
||||
# Set overwrite_systemd
|
||||
ynh_app_setting_set --app=$app --key=overwrite_systemd --value="$overwrite_systemd"
|
||||
|
||||
#=================================================
|
||||
# MODIFY EMAIL SETTING
|
||||
#=================================================
|
||||
|
||||
# Set admin_mail_html
|
||||
ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT
|
||||
#=================================================
|
||||
|
||||
case $1 in
|
||||
show) show_config;;
|
||||
apply) apply_config;;
|
||||
esac
|
|
@ -1,11 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -19,42 +13,41 @@ secret=$(ynh_string_random)
|
|||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set --app=$app --key=always_encrypt --value=$always_encrypt
|
||||
ynh_app_setting_set --app=$app --key=secret --value="$secret"
|
||||
ynh_app_setting_set --key=always_encrypt --value=$always_encrypt
|
||||
ynh_app_setting_set --key=secret --value="$secret"
|
||||
|
||||
ynh_app_setting_set --app=$app --key=overwrite_settings --value=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_systemd --value=1
|
||||
ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
|
||||
ynh_app_setting_set --key=overwrite_settings --value=1
|
||||
ynh_app_setting_set --key=overwrite_nginx --value=1
|
||||
ynh_app_setting_set --key=overwrite_systemd --value=1
|
||||
ynh_app_setting_set --key=admin_mail_html --value=1
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
ynh_script_progression "Setting up source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir"
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
|
||||
ynh_script_progression "Configuring NGINX web server..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=2
|
||||
ynh_script_progression "Adding $app's configuration..."
|
||||
|
||||
workers="$(( $(nproc) * 2 ))"
|
||||
ynh_add_config --template="../conf/lutim.conf.template" --destination="$install_dir/lutim.conf"
|
||||
ynh_config_add --template="lutim.conf.template" --destination="$install_dir/lutim.conf"
|
||||
|
||||
chmod 400 "$install_dir/lutim.conf"
|
||||
chown $app:$app "$install_dir/lutim.conf"
|
||||
|
@ -63,13 +56,13 @@ chown $app:$app "$install_dir/lutim.conf"
|
|||
# SETUP CRON
|
||||
#=================================================
|
||||
|
||||
ynh_add_config --template="../conf/cron_lutim" --destination="/etc/cron.d/$app"
|
||||
ynh_config_add --template="cron_lutim" --destination="/etc/cron.d/$app"
|
||||
chmod +x $install_dir/script/lutim
|
||||
|
||||
#=================================================
|
||||
# INSTALL LUTIM WITH CARTON
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing $app with Carton..." --weight=60
|
||||
ynh_script_progression "Installing $app with Carton..."
|
||||
|
||||
mkdir -p /var/log/$app/
|
||||
(cd $install_dir
|
||||
|
@ -79,9 +72,9 @@ carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log")
|
|||
arch_dir=$(ls -1 $install_dir/local/lib/perl5/ | grep linux-gnu)
|
||||
if [ "$?" -ne 0 ]
|
||||
then
|
||||
ynh_die --message="Unable to find the perl directory for your architecture."
|
||||
ynh_die "Unable to find the perl directory for your architecture."
|
||||
fi
|
||||
ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --target_file="$install_dir/script/lutim"
|
||||
ynh_replace --match="__ARCHDIR__" --replace="$arch_dir" --file="$install_dir/script/lutim"
|
||||
|
||||
#=================================================
|
||||
# SETUP LOG FILE
|
||||
|
@ -89,51 +82,48 @@ ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --t
|
|||
|
||||
# Making log a symbolic link to /var/log
|
||||
touch /var/log/$app/production.log
|
||||
chown $app -R /var/log/$app
|
||||
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app -R /var/log/$app
|
||||
ln -s /var/log/$app/production.log "$install_dir/log/production.log"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=2
|
||||
ynh_script_progression "Configuring $app's systemd service..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
ynh_config_add_systemd
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..." --weight=2
|
||||
ynh_script_progression "Configuring log rotation..."
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
ynh_config_add_logrotate
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
ynh_script_progression "Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log="$install_dir/log/production.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=6
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
# Wait for lutim to be fully started
|
||||
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
ynh_systemd_action --action=stop
|
||||
ynh_systemctl --action=restart --wait_until="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
ynh_systemctl --action=stop
|
||||
|
||||
# Set right permissions on new files created at first start
|
||||
chown -R $app:$app $install_dir
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app $install_dir
|
||||
# Wait for lutim to be fully started
|
||||
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
ynh_systemctl --action=restart --wait_until="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -16,48 +10,48 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
if ynh_hide_warnings yunohost service status $app >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..."
|
||||
ynh_script_progression "Removing $app service integration..."
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=6
|
||||
ynh_script_progression "Stopping and removing the systemd service..."
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
ynh_config_remove_systemd
|
||||
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..."
|
||||
ynh_script_progression "Removing logrotate configuration..."
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
ynh_config_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||
ynh_script_progression "Removing NGINX web server configuration..."
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
ynh_config_remove_nginx
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..."
|
||||
ynh_script_progression "Removing various files..."
|
||||
|
||||
# Remove a cron file
|
||||
ynh_secure_remove --file="/etc/cron.d/$app"
|
||||
ynh_safe_rm "/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# 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 /usr/share/yunohost/helpers
|
||||
|
@ -19,69 +13,66 @@ ynh_maintenance_mode_ON
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
ynh_script_progression "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
ynh_restore "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir"
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX configuration..."
|
||||
ynh_script_progression "Restoring the NGINX configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring various files..."
|
||||
ynh_script_progression "Restoring various files..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
ynh_restore "/etc/cron.d/$app"
|
||||
|
||||
# Making log a symbolic link to /var/log
|
||||
mkdir -p /var/log/$app/
|
||||
touch /var/log/$app/production.log
|
||||
chown $app -R /var/log/$app
|
||||
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app -R /var/log/$app
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
||||
ynh_script_progression "Restoring $app's systemd service..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
ynh_restore "/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..."
|
||||
ynh_script_progression "Restoring the logrotate configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
ynh_restore "/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
ynh_script_progression "Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log="$install_dir/log/production.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
ynh_systemctl --action=restart --wait_until="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
|
||||
ynh_script_progression "Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_systemctl --service=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# DEACTIVE MAINTENANCE MODE
|
||||
|
@ -93,4 +84,4 @@ ynh_maintenance_mode_OFF
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -1,89 +1,79 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Activating maintenance mode..." --weight=2
|
||||
ynh_script_progression "Activating maintenance mode..."
|
||||
|
||||
ynh_maintenance_mode_ON
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop"
|
||||
ynh_systemctl --service=$app --action="stop"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
|
||||
ynh_script_progression "Ensuring downward compatibility..."
|
||||
|
||||
# Fix always_encrypt as a boolean
|
||||
if [ "${always_encrypt:-}" = "Yes" ]; then
|
||||
ynh_app_setting_set --app=$app --key=always_encrypt --value=1
|
||||
ynh_app_setting_set --key=always_encrypt --value=1
|
||||
always_encrypt=1
|
||||
elif [ "${always_encrypt:-}" = "No" ]; then
|
||||
ynh_app_setting_set --app=$app --key=always_encrypt --value=0
|
||||
ynh_app_setting_set --key=always_encrypt --value=0
|
||||
always_encrypt=0
|
||||
fi
|
||||
|
||||
# If overwrite_settings doesn't exist, create it
|
||||
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=overwrite_settings --value=1
|
||||
if [ -z "${overwrite_settings:-}" ]; then
|
||||
overwrite_settings=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_settings --value=$overwrite_settings
|
||||
ynh_app_setting_set --key=overwrite_settings --value=$overwrite_settings
|
||||
fi
|
||||
|
||||
# If overwrite_nginx doesn't exist, create it
|
||||
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=overwrite_nginx --value=1
|
||||
if [ -z "${overwrite_nginx:-}" ]; then
|
||||
overwrite_nginx=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
|
||||
ynh_app_setting_set --key=overwrite_nginx --value=$overwrite_nginx
|
||||
fi
|
||||
|
||||
# If overwrite_systemd doesn't exist, create it
|
||||
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=overwrite_systemd --value=1
|
||||
if [ -z "${overwrite_systemd:-}" ]; then
|
||||
overwrite_systemd=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_systemd --value=$overwrite_systemd
|
||||
ynh_app_setting_set --key=overwrite_systemd --value=$overwrite_systemd
|
||||
fi
|
||||
|
||||
# If secret doesn't exist, create it
|
||||
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=secret --value=$(grep "secrets *=>" "$install_dir/lutim.conf" | cut -d\' -f2)
|
||||
if [ -z "${secret:-}" ]; then
|
||||
secret=$(grep "secrets *=>" "$install_dir/lutim.conf" | cut -d\' -f2)
|
||||
ynh_app_setting_set --app=$app --key=secret --value=$secret
|
||||
ynh_app_setting_set --key=secret --value=$secret
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
|
||||
if ynh_app_upstream_version_changed
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
ynh_script_progression "Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
fi
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -91,36 +81,34 @@ chown -R $app:www-data "$install_dir"
|
|||
# Overwrite the nginx configuration only if it's allowed
|
||||
if [ $overwrite_nginx -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
||||
ynh_add_nginx_config
|
||||
ynh_script_progression "Upgrading NGINX web server configuration..."
|
||||
ynh_config_add_nginx
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# SETUP LUTIM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reconfiguring $app..."
|
||||
ynh_script_progression "Reconfiguring $app..."
|
||||
|
||||
# Overwrite the settings config file only if it's allowed
|
||||
if [ $overwrite_settings -eq 1 ]
|
||||
then
|
||||
workers="$(( $(nproc) * 2 ))"
|
||||
ynh_add_config --template="../conf/lutim.conf.template" --destination="$install_dir/lutim.conf"
|
||||
ynh_config_add --template="lutim.conf.template" --destination="$install_dir/lutim.conf"
|
||||
|
||||
chmod 400 "$install_dir/lutim.conf"
|
||||
chown $app:$app "$install_dir/lutim.conf"
|
||||
|
||||
# Optional parameters from config-panel feature
|
||||
if [ -n "${antiflood:-}" ]; then
|
||||
ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$install_dir/lutim.conf"
|
||||
ynh_replace --match=".*anti_flood_delay *=>.*" --replace=" anti_flood_delay => $antiflood," --file="$install_dir/lutim.conf"
|
||||
# Disable anti_flood_delay if the delay is 0
|
||||
if [ $antiflood = 0 ]; then
|
||||
ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$install_dir/lutim.conf"
|
||||
ynh_replace --match="\(anti_flood_delay *=>.*\)" --replace="#\1" --file="$install_dir/lutim.conf"
|
||||
fi
|
||||
fi
|
||||
if [ -n "${delay:-}" ]; then
|
||||
ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$install_dir/lutim.conf"
|
||||
ynh_replace --match=".*default_delay *=>.*" --replace=" default_delay => $delay," --file="$install_dir/lutim.conf"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -128,17 +116,18 @@ fi
|
|||
# SETUP CRON
|
||||
#=================================================
|
||||
|
||||
ynh_add_config --template="../conf/cron_lutim" --destination="/etc/cron.d/$app"
|
||||
ynh_config_add --template="cron_lutim" --destination="/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# UPDATE LUTIM WITH CARTON
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
|
||||
if ynh_app_upstream_version_changed
|
||||
then
|
||||
ynh_script_progression --message="Upgrading $app with Carton..." --weight=4
|
||||
ynh_script_progression "Upgrading $app with Carton..."
|
||||
pushd "$install_dir"
|
||||
ynh_secure_remove --file="$install_dir/local"
|
||||
ynh_safe_rm "$install_dir/local"
|
||||
carton install --without=mysql --without=htpasswd --without=test
|
||||
popd
|
||||
fi
|
||||
|
@ -150,34 +139,32 @@ fi
|
|||
# Overwrite the systemd configuration only if it's allowed
|
||||
if [ $overwrite_systemd -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
|
||||
ynh_add_systemd_config
|
||||
ynh_script_progression "Upgrading systemd configuration..."
|
||||
ynh_config_add_systemd
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..."
|
||||
ynh_script_progression "Upgrading logrotate configuration..."
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
chown $app -R /var/log/$app
|
||||
ynh_config_add_logrotate
|
||||
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app -R /var/log/$app
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
ynh_script_progression "Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log="$install_dir/log/production.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=4
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
ynh_systemctl --service=$app --action="start" --wait_until="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
|
||||
#=================================================
|
||||
# DEACTIVE MAINTENANCE MODE
|
||||
|
@ -189,4 +176,4 @@ ynh_maintenance_mode_OFF
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue