mirror of
https://github.com/YunoHost-Apps/simplytranslate_ynh.git
synced 2024-09-03 20:16:26 +02:00
Merge 253ff67cda
into 7ad8bc4a39
This commit is contained in:
commit
9bd4588ba1
10 changed files with 101 additions and 166 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
*~
|
*~
|
||||||
*.sw[op]
|
*.sw[op]
|
||||||
|
.DS_Store
|
||||||
|
|
|
@ -16,7 +16,8 @@ website = "https://simplytranslate.org/"
|
||||||
code = "https://codeberg.org/SimpleWeb/SimplyTranslate-Web"
|
code = "https://codeberg.org/SimpleWeb/SimplyTranslate-Web"
|
||||||
|
|
||||||
[integration]
|
[integration]
|
||||||
yunohost = ">= 11.2"
|
yunohost = ">= 11.2.18"
|
||||||
|
helpers_version = "2.1"
|
||||||
architectures = "all"
|
architectures = "all"
|
||||||
multi_instance = true
|
multi_instance = true
|
||||||
ldap = false
|
ldap = false
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# PERSONAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# EXPERIMENTAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# FUTURE OFFICIAL HELPERS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,30 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
ynh_print_info "Declaring files to be backed up..."
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$install_dir"
|
ynh_backup "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# 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
|
# SPECIFIC BACKUP
|
||||||
|
@ -32,10 +23,10 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
# BACKUP SYSTEMD
|
# BACKUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
ynh_backup "/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# 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,29 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD MODIFICATIONS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
ynh_script_progression "Stopping $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service=$app --action="stop"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
ynh_script_progression "Updating NGINX web server configuration..."
|
||||||
|
|
||||||
ynh_change_url_nginx_config
|
ynh_config_change_url_nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
|
@ -45,28 +37,26 @@ then
|
||||||
new_st_path=$new_path
|
new_st_path=$new_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_replace_string -m "\"$old_st_path/?engine" -r "\"$new_st_path/?engine" -f "$install_dir/simplytranslate/templates/index.html"
|
ynh_replace -m "\"$old_st_path/?engine" -r "\"$new_st_path/?engine" -f "$install_dir/simplytranslate/templates/index.html"
|
||||||
ynh_replace_string -m "$old_st_path/prefs" -r "$new_st_path/prefs" -f "$install_dir/simplytranslate/templates/index.html"
|
ynh_replace -m "$old_st_path/prefs" -r "$new_st_path/prefs" -f "$install_dir/simplytranslate/templates/index.html"
|
||||||
ynh_replace_string -m "$old_st_path/switchlanguages" -r "$new_st_path/switchlanguages" -f "$install_dir/simplytranslate/templates/index.html"
|
ynh_replace -m "$old_st_path/switchlanguages" -r "$new_st_path/switchlanguages" -f "$install_dir/simplytranslate/templates/index.html"
|
||||||
ynh_replace_string -m "\"$old_st_path/\"" -r "\"$new_st_path/\"" -f "$install_dir/simplytranslate/templates/prefs.html"
|
ynh_replace -m "\"$old_st_path/\"" -r "\"$new_st_path/\"" -f "$install_dir/simplytranslate/templates/prefs.html"
|
||||||
ynh_replace_string -m "$old_st_path/prefs" -r "$new_st_path/prefs" -f "$install_dir/simplytranslate/templates/prefs.html"
|
ynh_replace -m "$old_st_path/prefs" -r "$new_st_path/prefs" -f "$install_dir/simplytranslate/templates/prefs.html"
|
||||||
ynh_replace_string -m "$old_st_path/api" -r "$new_st_path/api" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "$old_st_path/api" -r "$new_st_path/api" -f "$install_dir/simplytranslate/main.py"
|
||||||
ynh_replace_string -m "$old_st_path/prefs" -r "$new_st_path/prefs" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "$old_st_path/prefs" -r "$new_st_path/prefs" -f "$install_dir/simplytranslate/main.py"
|
||||||
ynh_replace_string -m "$old_st_path/switchlanguages" -r "$new_st_path/switchlanguages" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "$old_st_path/switchlanguages" -r "$new_st_path/switchlanguages" -f "$install_dir/simplytranslate/main.py"
|
||||||
ynh_replace_string -m "f\"$old_st_path/?" -r "f\"$new_st_path/?" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "f\"$old_st_path/?" -r "f\"$new_st_path/?" -f "$install_dir/simplytranslate/main.py"
|
||||||
ynh_replace_string -m "\"$old_st_path/\"" -r "\"$new_st_path/\"" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "\"$old_st_path/\"" -r "\"$new_st_path/\"" -f "$install_dir/simplytranslate/main.py"
|
||||||
fi
|
fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
|
||||||
#=================================================
|
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service=$app --action="start"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
ynh_script_progression "Change of URL completed for $app"
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
install_dir=$(ynh_app_setting_get --key=install_dir)
|
||||||
port=$(ynh_app_setting_get -a $app -k port)
|
port=$(ynh_app_setting_get -a $app -k port)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -18,15 +18,12 @@ port=$(ynh_app_setting_get -a $app -k port)
|
||||||
ynh_app_config_apply() {
|
ynh_app_config_apply() {
|
||||||
_ynh_app_config_apply
|
_ynh_app_config_apply
|
||||||
|
|
||||||
ynh_add_config --template="config.conf.template" --destination="$install_dir/simplytranslate/config.conf"
|
ynh_config_add --template="config.conf.template" --destination="$install_dir/simplytranslate/config.conf"
|
||||||
|
|
||||||
chmod 400 "$install_dir/simplytranslate/config.conf"
|
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/simplytranslate/config.conf"
|
||||||
chown $app:$app "$install_dir/simplytranslate/config.conf"
|
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/simplytranslate/config.conf"
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_app_config_run $1
|
ynh_app_config_run $1
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -14,20 +8,19 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
ynh_script_progression "Setting up source files..."
|
||||||
|
|
||||||
ynh_setup_source --dest_dir="$install_dir/simplytranslate"
|
ynh_setup_source --dest_dir="$install_dir/simplytranslate"
|
||||||
|
|
||||||
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 | chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SYSTEM CONFIGURATION
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
ynh_script_progression "Adding system configurations related to $app..."
|
||||||
|
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
ynh_add_systemd_config
|
ynh_config_add_systemd
|
||||||
|
|
||||||
yunohost service add $app --description="Web interface for SimplyTranslate" --log="/var/log/$app/$app.log"
|
yunohost service add $app --description="Web interface for SimplyTranslate" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
@ -36,7 +29,7 @@ yunohost service add $app --description="Web interface for SimplyTranslate" --lo
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
ynh_script_progression "Adding $app's configuration..."
|
||||||
|
|
||||||
# some default config
|
# some default config
|
||||||
ynh_app_setting_set -a $app -k libretranslate_enable -v false
|
ynh_app_setting_set -a $app -k libretranslate_enable -v false
|
||||||
|
@ -56,10 +49,10 @@ deepl_enable=$(ynh_app_setting_get -a $app -k deepl_enable)
|
||||||
iciba_enable=$(ynh_app_setting_get -a $app -k iciba_enable)
|
iciba_enable=$(ynh_app_setting_get -a $app -k iciba_enable)
|
||||||
reverso_enable=$(ynh_app_setting_get -a $app -k reverso_enable)
|
reverso_enable=$(ynh_app_setting_get -a $app -k reverso_enable)
|
||||||
|
|
||||||
ynh_add_config --template="config.conf.template" --destination="$install_dir/simplytranslate/config.conf"
|
ynh_config_add --template="config.conf.template" --destination="$install_dir/simplytranslate/config.conf"
|
||||||
|
|
||||||
chmod 400 "$install_dir/simplytranslate/config.conf"
|
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/simplytranslate/config.conf"
|
||||||
chown $app:$app "$install_dir/simplytranslate/config.conf"
|
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/simplytranslate/config.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURATION FOR SUBPATH
|
# CONFIGURATION FOR SUBPATH
|
||||||
|
@ -71,21 +64,21 @@ else
|
||||||
st_path=$path
|
st_path=$path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_replace_string -m "\"/?engine" -r "\"$st_path/?engine" -f "$install_dir/simplytranslate/templates/index.html"
|
ynh_replace -m "\"/?engine" -r "\"$st_path/?engine" -f "$install_dir/simplytranslate/templates/index.html"
|
||||||
ynh_replace_string -m "/prefs" -r "$st_path/prefs" -f "$install_dir/simplytranslate/templates/index.html"
|
ynh_replace -m "/prefs" -r "$st_path/prefs" -f "$install_dir/simplytranslate/templates/index.html"
|
||||||
ynh_replace_string -m "/switchlanguages" -r "$st_path/switchlanguages" -f "$install_dir/simplytranslate/templates/index.html"
|
ynh_replace -m "/switchlanguages" -r "$st_path/switchlanguages" -f "$install_dir/simplytranslate/templates/index.html"
|
||||||
ynh_replace_string -m "\"/\"" -r "\"$st_path/\"" -f "$install_dir/simplytranslate/templates/prefs.html"
|
ynh_replace -m "\"/\"" -r "\"$st_path/\"" -f "$install_dir/simplytranslate/templates/prefs.html"
|
||||||
ynh_replace_string -m "/prefs" -r "$st_path/prefs" -f "$install_dir/simplytranslate/templates/prefs.html"
|
ynh_replace -m "/prefs" -r "$st_path/prefs" -f "$install_dir/simplytranslate/templates/prefs.html"
|
||||||
ynh_replace_string -m "/api" -r "$st_path/api" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "/api" -r "$st_path/api" -f "$install_dir/simplytranslate/main.py"
|
||||||
ynh_replace_string -m "/prefs" -r "$st_path/prefs" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "/prefs" -r "$st_path/prefs" -f "$install_dir/simplytranslate/main.py"
|
||||||
ynh_replace_string -m "/switchlanguages" -r "$st_path/switchlanguages" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "/switchlanguages" -r "$st_path/switchlanguages" -f "$install_dir/simplytranslate/main.py"
|
||||||
ynh_replace_string -m "f\"/?" -r "f\"$st_path/?" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "f\"/?" -r "f\"$st_path/?" -f "$install_dir/simplytranslate/main.py"
|
||||||
ynh_replace_string -m "\"/\"" -r "\"$st_path/\"" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "\"/\"" -r "\"$st_path/\"" -f "$install_dir/simplytranslate/main.py"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD THE APP
|
# BUILD THE APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building the app..." --weight=1
|
ynh_script_progression "Building the app..."
|
||||||
|
|
||||||
mkdir "$install_dir/venv"
|
mkdir "$install_dir/venv"
|
||||||
python3 -m venv "$install_dir/venv"
|
python3 -m venv "$install_dir/venv"
|
||||||
|
@ -93,16 +86,14 @@ python3 -m venv "$install_dir/venv"
|
||||||
|
|
||||||
chown -R $app:$app "$install_dir/venv"
|
chown -R $app:$app "$install_dir/venv"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service=$app --action="start"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
ynh_script_progression "Installation of $app completed"
|
||||||
|
|
|
@ -1,33 +1,28 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SYSTEM CONFIGURATIONS
|
# REMOVE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SYSTEMD SERVICE
|
# REMOVE SYSTEMD SERVICE
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
|
||||||
|
|
||||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
#=================================================
|
||||||
|
ynh_script_progression "Removing system configurations related to $app..."
|
||||||
|
|
||||||
|
if ynh_hide_warnings yunohost service status $app >/dev/null
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
ynh_script_progression "Removing $app service integration..."
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_remove_systemd_config
|
ynh_config_remove_systemd
|
||||||
|
|
||||||
ynh_remove_nginx_config
|
ynh_config_remove_nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression "Removal of $app completed"
|
||||||
|
|
|
@ -1,50 +1,41 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
ynh_script_progression "Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$install_dir"
|
ynh_restore "$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 | chown -R $app:www-data "$install_dir"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEM CONFIGURATIONS
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
ynh_script_progression "Restoring system configurations related to $app..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
ynh_restore "/etc/systemd/system/$app.service"
|
||||||
systemctl enable $app.service --quiet
|
systemctl enable $app.service --quiet
|
||||||
|
|
||||||
yunohost service add $app --description="Web interface for SimplyTranslate" --log="/var/log/$app/$app.log"
|
yunohost service add $app --description="Web interface for SimplyTranslate" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service=$app --action="start"
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemctl --service=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for $app" --last
|
ynh_script_progression "Restoration completed for $app"
|
||||||
|
|
|
@ -1,16 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT SOME CONFIG
|
# IMPORT SOME CONFIG
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -24,14 +16,12 @@ iciba_enable=$(ynh_app_setting_get -a $app -k iciba_enable)
|
||||||
reverso_enable=$(ynh_app_setting_get -a $app -k reverso_enable)
|
reverso_enable=$(ynh_app_setting_get -a $app -k reverso_enable)
|
||||||
port=$(ynh_app_setting_get -a $app -k port)
|
port=$(ynh_app_setting_get -a $app -k port)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD UPGRADE STEPS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
ynh_script_progression "Stopping $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service=$app --action="stop"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
||||||
|
@ -39,15 +29,15 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# 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
|
then
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
ynh_script_progression "Upgrading source files..."
|
||||||
|
|
||||||
ynh_setup_source --dest_dir="$install_dir/simplytranslate"
|
ynh_setup_source --dest_dir="$install_dir/simplytranslate"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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 | chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURATION FOR SUBPATH
|
# CONFIGURATION FOR SUBPATH
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -58,25 +48,25 @@ else
|
||||||
st_path=$path
|
st_path=$path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_replace_string -m "\"/?engine" -r "\"$st_path/?engine" -f "$install_dir/simplytranslate/templates/index.html"
|
ynh_replace -m "\"/?engine" -r "\"$st_path/?engine" -f "$install_dir/simplytranslate/templates/index.html"
|
||||||
ynh_replace_string -m "/prefs" -r "$st_path/prefs" -f "$install_dir/simplytranslate/templates/index.html"
|
ynh_replace -m "/prefs" -r "$st_path/prefs" -f "$install_dir/simplytranslate/templates/index.html"
|
||||||
ynh_replace_string -m "/switchlanguages" -r "$st_path/switchlanguages" -f "$install_dir/simplytranslate/templates/index.html"
|
ynh_replace -m "/switchlanguages" -r "$st_path/switchlanguages" -f "$install_dir/simplytranslate/templates/index.html"
|
||||||
ynh_replace_string -m "\"/\"" -r "\"$st_path/\"" -f "$install_dir/simplytranslate/templates/prefs.html"
|
ynh_replace -m "\"/\"" -r "\"$st_path/\"" -f "$install_dir/simplytranslate/templates/prefs.html"
|
||||||
ynh_replace_string -m "/prefs" -r "$st_path/prefs" -f "$install_dir/simplytranslate/templates/prefs.html"
|
ynh_replace -m "/prefs" -r "$st_path/prefs" -f "$install_dir/simplytranslate/templates/prefs.html"
|
||||||
ynh_replace_string -m "/api" -r "$st_path/api" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "/api" -r "$st_path/api" -f "$install_dir/simplytranslate/main.py"
|
||||||
ynh_replace_string -m "/prefs" -r "$st_path/prefs" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "/prefs" -r "$st_path/prefs" -f "$install_dir/simplytranslate/main.py"
|
||||||
ynh_replace_string -m "/switchlanguages" -r "$st_path/switchlanguages" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "/switchlanguages" -r "$st_path/switchlanguages" -f "$install_dir/simplytranslate/main.py"
|
||||||
ynh_replace_string -m "f\"/?" -r "f\"$st_path/?" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "f\"/?" -r "f\"$st_path/?" -f "$install_dir/simplytranslate/main.py"
|
||||||
ynh_replace_string -m "\"/\"" -r "\"$st_path/\"" -f "$install_dir/simplytranslate/main.py"
|
ynh_replace -m "\"/\"" -r "\"$st_path/\"" -f "$install_dir/simplytranslate/main.py"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REAPPLY SYSTEM CONFIGURATIONS
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||||
|
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
ynh_add_systemd_config
|
ynh_config_add_systemd
|
||||||
|
|
||||||
yunohost service add $app --description="Web interface for SimplyTranslate" --log="/var/log/$app/$app.log"
|
yunohost service add $app --description="Web interface for SimplyTranslate" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
|
@ -85,19 +75,19 @@ yunohost service add $app --description="Web interface for SimplyTranslate" --lo
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
ynh_script_progression "Updating configuration..."
|
||||||
|
|
||||||
ynh_add_config --template="config.conf.template" --destination="$install_dir/simplytranslate/config.conf"
|
ynh_config_add --template="config.conf.template" --destination="$install_dir/simplytranslate/config.conf"
|
||||||
|
|
||||||
chmod 400 "$install_dir/simplytranslate/config.conf"
|
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/simplytranslate/config.conf"
|
||||||
chown $app:$app "$install_dir/simplytranslate/config.conf"
|
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/simplytranslate/config.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REBUILDING THE APP
|
# REBUILDING THE APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Rebuilding the app..." --weight=1
|
ynh_script_progression "Rebuilding the app..."
|
||||||
|
|
||||||
ynh_secure_remove "$install_dir/venv"
|
ynh_safe_rm "$install_dir/venv"
|
||||||
mkdir "$install_dir/venv"
|
mkdir "$install_dir/venv"
|
||||||
python3 -m venv "$install_dir/venv"
|
python3 -m venv "$install_dir/venv"
|
||||||
"$install_dir/venv/bin/python3" -m pip install -r "$install_dir/simplytranslate/requirements.txt"
|
"$install_dir/venv/bin/python3" -m pip install -r "$install_dir/simplytranslate/requirements.txt"
|
||||||
|
@ -107,12 +97,12 @@ chown -R $app:$app "$install_dir/venv"
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service=$app --action="start"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# 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