mirror of
https://github.com/YunoHost-Apps/lingva_ynh.git
synced 2024-09-03 19:36:20 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
7061cb7b2b
commit
e2b71ceeb5
10 changed files with 105 additions and 168 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
*~
|
*~
|
||||||
*.sw[op]
|
*.sw[op]
|
||||||
|
.DS_Store
|
||||||
|
|
|
@ -6,7 +6,7 @@ After=network.target
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
Environment=__YNH_NODE_LOAD_PATH__
|
Environment=PATH=__PATH_WITH_NODEJS__
|
||||||
WorkingDirectory=__INSTALL_DIR__/
|
WorkingDirectory=__INSTALL_DIR__/
|
||||||
ExecStart=yarn run next start -p __PORT__
|
ExecStart=yarn run next start -p __PORT__
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@ demo = "https://lingva.ml"
|
||||||
code = "https://github.com/thedaviddelta/lingva-translate"
|
code = "https://github.com/thedaviddelta/lingva-translate"
|
||||||
|
|
||||||
[integration]
|
[integration]
|
||||||
yunohost = ">= 11.1.19"
|
yunohost = ">= 11.2.18"
|
||||||
|
helpers_version = "2.1"
|
||||||
architectures = "all"
|
architectures = "all"
|
||||||
multi_instance = true
|
multi_instance = true
|
||||||
ldap = false
|
ldap = false
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
nodejs_version=18
|
nodejs_version=18
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# PERSONAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# EXPERIMENTAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# FUTURE OFFICIAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
|
@ -1,31 +1,22 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
# 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
|
||||||
|
|
||||||
#=================================================
|
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
|
||||||
|
@ -33,10 +24,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,39 +1,31 @@
|
||||||
#!/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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHANGE THE URL IN .ENV.LOCAL AND REBUILD THE APP
|
# CHANGE THE URL IN .ENV.LOCAL AND REBUILD THE APP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Setting the new URL..." --weight=1
|
ynh_script_progression "Setting the new URL..."
|
||||||
|
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_replace_string --match_string="NEXT_PUBLIC_SITE_DOMAIN=$old_domain$old_path" --replace_string="NEXT_PUBLIC_SITE_DOMAIN=$new_domain$new_path" --target_file="$install_dir/.env.local"
|
ynh_replace --match="NEXT_PUBLIC_SITE_DOMAIN=$old_domain$old_path" --replace="NEXT_PUBLIC_SITE_DOMAIN=$new_domain$new_path" --file="$install_dir/.env.local"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]
|
||||||
|
@ -52,45 +44,42 @@ then
|
||||||
next_path=$new_path
|
next_path=$new_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_add_config --template="manifest.json" --destination="$install_dir/public/manifest.json"
|
ynh_config_add --template="manifest.json" --destination="$install_dir/public/manifest.json"
|
||||||
|
|
||||||
ynh_add_config --template="next.config.js" --destination="$install_dir/next.config.js"
|
ynh_config_add --template="next.config.js" --destination="$install_dir/next.config.js"
|
||||||
|
|
||||||
ynh_replace_string --match_string="src={useColorModeValue(\"$old_next_path/banner_light.svg\", \"$old_next_path/banner_dark.svg\")}" --replace_string="src={useColorModeValue(\"$new_next_path/banner_light.svg\", \"$new_next_path/banner_dark.svg\")}" --target_file="$install_dir/components/Header.tsx"
|
ynh_replace --match="src={useColorModeValue(\"$old_next_path/banner_light.svg\", \"$old_next_path/banner_dark.svg\")}" --replace="src={useColorModeValue(\"$new_next_path/banner_light.svg\", \"$new_next_path/banner_dark.svg\")}" --file="$install_dir/components/Header.tsx"
|
||||||
|
|
||||||
ynh_replace_string --match_string="href=\"$old_next_path/favicon" --replace_string="href=\"$new_next_path/favicon" --target_file="$install_dir/components/CustomHead.tsx"
|
ynh_replace --match="href=\"$old_next_path/favicon" --replace="href=\"$new_next_path/favicon" --file="$install_dir/components/CustomHead.tsx"
|
||||||
|
|
||||||
ynh_replace_string --match_string="href=\"$old_next_path/apple" --replace_string="href=\"$new_next_path/apple" --target_file="$install_dir/components/CustomHead.tsx"
|
ynh_replace --match="href=\"$old_next_path/apple" --replace="href=\"$new_next_path/apple" --file="$install_dir/components/CustomHead.tsx"
|
||||||
|
|
||||||
ynh_replace_string --match_string="href=\"$old_next_path/manifest" --replace_string="href=\"$new_next_path/manifest" --target_file="$install_dir/components/CustomHead.tsx"
|
ynh_replace --match="href=\"$old_next_path/manifest" --replace="href=\"$new_next_path/manifest" --file="$install_dir/components/CustomHead.tsx"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown $app:www-data "$install_dir/public/manifest.json"
|
chown $app:www-data "$install_dir/public/manifest.json"
|
||||||
chown $app:www-data "$install_dir/next.config.js"
|
#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:www-data "$install_dir/next.config.js"
|
||||||
chmod 664 "$install_dir/public/manifest.json"
|
chmod 664 "$install_dir/public/manifest.json"
|
||||||
chmod 664 "$install_dir/next.config.js"
|
#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 664 "$install_dir/next.config.js"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REBUILDING AND INSTALL THE APP
|
# REBUILDING AND INSTALL THE APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Rebuilding the app..." --weight=1
|
ynh_script_progression "Rebuilding the app..."
|
||||||
|
|
||||||
ynh_use_nodejs
|
ynh_hide_warnings yarn --cwd "$install_dir" build
|
||||||
ynh_exec_warn_less yarn --cwd "$install_dir" build
|
|
||||||
|
|
||||||
chown -R $app:$app "$install_dir/.next"
|
chown -R $app:$app "$install_dir/.next"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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"
|
||||||
|
|
|
@ -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,39 +8,38 @@ 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..."
|
||||||
|
|
||||||
# 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 --dest_dir="$install_dir"
|
ynh_setup_source --dest_dir="$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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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..."
|
||||||
|
|
||||||
# Create a dedicated NGINX config using the conf/nginx.conf template
|
# Create a dedicated NGINX config using the conf/nginx.conf template
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# APP INITIAL CONFIGURATION
|
# APP INITIAL CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
ynh_script_progression "Adding $app's configuration..."
|
||||||
|
|
||||||
ynh_add_config --template=".env.local" --destination="$install_dir/.env.local"
|
ynh_config_add --template=".env.local" --destination="$install_dir/.env.local"
|
||||||
|
|
||||||
chmod 400 "$install_dir/.env.local"
|
#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/.env.local"
|
||||||
chown $app:$app "$install_dir/.env.local"
|
#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/.env.local"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURATION FOR SUBPATH
|
# CONFIGURATION FOR SUBPATH
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_secure_remove --file="$install_dir/public/manifest.json"
|
ynh_safe_rm "$install_dir/public/manifest.json"
|
||||||
ynh_secure_remove --file="$install_dir/next.config.js"
|
ynh_safe_rm "$install_dir/next.config.js"
|
||||||
|
|
||||||
if [ "$path" = "/" ]; then
|
if [ "$path" = "/" ]; then
|
||||||
next_path=""
|
next_path=""
|
||||||
|
@ -54,53 +47,51 @@ else
|
||||||
next_path=$path
|
next_path=$path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_add_config --template="manifest.json" --destination="$install_dir/public/manifest.json"
|
ynh_config_add --template="manifest.json" --destination="$install_dir/public/manifest.json"
|
||||||
|
|
||||||
ynh_add_config --template="next.config.js" --destination="$install_dir/next.config.js"
|
ynh_config_add --template="next.config.js" --destination="$install_dir/next.config.js"
|
||||||
|
|
||||||
ynh_replace_string --match_string="src={useColorModeValue(\"/banner_light.svg\", \"/banner_dark.svg\")}" --replace_string="src={useColorModeValue(\"$next_path/banner_light.svg\", \"$next_path/banner_dark.svg\")}" --target_file="$install_dir/components/Header.tsx"
|
ynh_replace --match="src={useColorModeValue(\"/banner_light.svg\", \"/banner_dark.svg\")}" --replace="src={useColorModeValue(\"$next_path/banner_light.svg\", \"$next_path/banner_dark.svg\")}" --file="$install_dir/components/Header.tsx"
|
||||||
|
|
||||||
ynh_replace_string --match_string="href=\"/favicon" --replace_string="href=\"$next_path/favicon" --target_file="$install_dir/components/CustomHead.tsx"
|
ynh_replace --match="href=\"/favicon" --replace="href=\"$next_path/favicon" --file="$install_dir/components/CustomHead.tsx"
|
||||||
|
|
||||||
ynh_replace_string --match_string="href=\"/apple" --replace_string="href=\"$next_path/apple" --target_file="$install_dir/components/CustomHead.tsx"
|
ynh_replace --match="href=\"/apple" --replace="href=\"$next_path/apple" --file="$install_dir/components/CustomHead.tsx"
|
||||||
|
|
||||||
ynh_replace_string --match_string="href=\"/manifest" --replace_string="href=\"$next_path/manifest" --target_file="$install_dir/components/CustomHead.tsx"
|
ynh_replace --match="href=\"/manifest" --replace="href=\"$next_path/manifest" --file="$install_dir/components/CustomHead.tsx"
|
||||||
|
|
||||||
chown $app:www-data "$install_dir/public/manifest.json"
|
chown $app:www-data "$install_dir/public/manifest.json"
|
||||||
chown $app:www-data "$install_dir/next.config.js"
|
#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:www-data "$install_dir/next.config.js"
|
||||||
chmod 664 "$install_dir/public/manifest.json"
|
chmod 664 "$install_dir/public/manifest.json"
|
||||||
chmod 664 "$install_dir/next.config.js"
|
#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 664 "$install_dir/next.config.js"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD AND INSTALL THE APP
|
# BUILD AND INSTALL THE APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building the app..." --weight=1
|
ynh_script_progression "Building the app..."
|
||||||
|
|
||||||
|
ynh_nodejs_install
|
||||||
|
|
||||||
ynh_install_nodejs --nodejs_version=$nodejs_version
|
|
||||||
ynh_use_nodejs
|
|
||||||
yarn config set enableTelemetry 0
|
yarn config set enableTelemetry 0
|
||||||
ynh_exec_warn_less yarn --cwd "$install_dir" install
|
ynh_hide_warnings yarn --cwd "$install_dir" install
|
||||||
yarn --cwd "$install_dir" run next telemetry disable
|
yarn --cwd "$install_dir" run next telemetry disable
|
||||||
ynh_exec_warn_less yarn --cwd "$install_dir" build
|
ynh_hide_warnings yarn --cwd "$install_dir" build
|
||||||
|
|
||||||
chown -R $app:$app "$install_dir/node_modules"
|
chown -R $app:$app "$install_dir/node_modules"
|
||||||
chown -R $app:$app "$install_dir/.next"
|
chown -R $app:$app "$install_dir/.next"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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_add_systemd_config
|
ynh_config_add_systemd
|
||||||
|
|
||||||
yunohost service add $app --description="alternative to google translate" --log="/var/log/$app/$app.log"
|
yunohost service add $app --description="alternative to google translate" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
# Start a systemd service
|
# Start a 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,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
|
||||||
|
|
||||||
|
@ -13,24 +7,25 @@ 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
|
ynh_script_progression "Removing system configurations related to $app..."
|
||||||
|
|
||||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
# 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
|
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
|
||||||
|
|
||||||
ynh_secure_remove --file="/var/log/$app/$app.log"
|
#REMOVEME? (Apps should not remove their log dir during remove ... this should only happen if --purge is used, and be handled by the core...) ynh_safe_rm "/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression "Removal of $app completed"
|
||||||
|
|
|
@ -1,54 +1,44 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
# 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
|
||||||
|
|
||||||
# starting nodejs for fresh install
|
# starting nodejs for fresh install
|
||||||
ynh_install_nodejs --nodejs_version=$nodejs_version
|
ynh_nodejs_install
|
||||||
ynh_use_nodejs
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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
|
||||||
#=================================================
|
#=================================================
|
||||||
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="alternative to google translate" --log="/var/log/$app/$app.log"
|
yunohost service add $app --description="alternative to google translate" --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,22 +1,14 @@
|
||||||
#!/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)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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...)
|
||||||
|
@ -24,42 +16,42 @@ 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..."
|
||||||
|
|
||||||
# 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 --dest_dir="$install_dir"
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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..."
|
||||||
|
|
||||||
# Create a dedicated NGINX config using the conf/nginx.conf template
|
# Create a dedicated NGINX config using the conf/nginx.conf template
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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=".env.local" --destination="$install_dir/.env.local"
|
ynh_config_add --template=".env.local" --destination="$install_dir/.env.local"
|
||||||
|
|
||||||
chmod 400 "$install_dir/.env.local"
|
#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/.env.local"
|
||||||
chown $app:$app "$install_dir/.env.local"
|
#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/.env.local"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURATION FOR SUBPATH
|
# CONFIGURATION FOR SUBPATH
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_secure_remove --file="$install_dir/public/manifest.json"
|
ynh_safe_rm "$install_dir/public/manifest.json"
|
||||||
ynh_secure_remove --file="$install_dir/next.config.js"
|
ynh_safe_rm "$install_dir/next.config.js"
|
||||||
|
|
||||||
if [ "$path" = "/" ]; then
|
if [ "$path" = "/" ]; then
|
||||||
next_path=""
|
next_path=""
|
||||||
|
@ -67,31 +59,30 @@ else
|
||||||
next_path=$path
|
next_path=$path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_add_config --template="manifest.json" --destination="$install_dir/public/manifest.json"
|
ynh_config_add --template="manifest.json" --destination="$install_dir/public/manifest.json"
|
||||||
|
|
||||||
ynh_add_config --template="next.config.js" --destination="$install_dir/next.config.js"
|
ynh_config_add --template="next.config.js" --destination="$install_dir/next.config.js"
|
||||||
|
|
||||||
ynh_replace_string --match_string="src={useColorModeValue(\"/banner_light.svg\", \"/banner_dark.svg\")}" --replace_string="src={useColorModeValue(\"$next_path/banner_light.svg\", \"$next_path/banner_dark.svg\")}" --target_file="$install_dir/components/Header.tsx"
|
ynh_replace --match="src={useColorModeValue(\"/banner_light.svg\", \"/banner_dark.svg\")}" --replace="src={useColorModeValue(\"$next_path/banner_light.svg\", \"$next_path/banner_dark.svg\")}" --file="$install_dir/components/Header.tsx"
|
||||||
|
|
||||||
ynh_replace_string --match_string="href=\"/favicon" --replace_string="href=\"$next_path/favicon" --target_file="$install_dir/components/CustomHead.tsx"
|
ynh_replace --match="href=\"/favicon" --replace="href=\"$next_path/favicon" --file="$install_dir/components/CustomHead.tsx"
|
||||||
|
|
||||||
ynh_replace_string --match_string="href=\"/apple" --replace_string="href=\"$next_path/apple" --target_file="$install_dir/components/CustomHead.tsx"
|
ynh_replace --match="href=\"/apple" --replace="href=\"$next_path/apple" --file="$install_dir/components/CustomHead.tsx"
|
||||||
|
|
||||||
ynh_replace_string --match_string="href=\"/manifest" --replace_string="href=\"$next_path/manifest" --target_file="$install_dir/components/CustomHead.tsx"
|
ynh_replace --match="href=\"/manifest" --replace="href=\"$next_path/manifest" --file="$install_dir/components/CustomHead.tsx"
|
||||||
|
|
||||||
chown $app:www-data "$install_dir/public/manifest.json"
|
chown $app:www-data "$install_dir/public/manifest.json"
|
||||||
chown $app:www-data "$install_dir/next.config.js"
|
#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:www-data "$install_dir/next.config.js"
|
||||||
chmod 664 "$install_dir/public/manifest.json"
|
chmod 664 "$install_dir/public/manifest.json"
|
||||||
chmod 664 "$install_dir/next.config.js"
|
#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 664 "$install_dir/next.config.js"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REBUILD AND INSTALL THE APP
|
# REBUILD AND INSTALL THE APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Rebuilding the app..." --weight=1
|
ynh_script_progression "Rebuilding the app..."
|
||||||
|
|
||||||
ynh_use_nodejs
|
ynh_hide_warnings yarn --cwd "$install_dir" install
|
||||||
ynh_exec_warn_less yarn --cwd "$install_dir" install
|
ynh_hide_warnings yarn --cwd "$install_dir" build
|
||||||
ynh_exec_warn_less yarn --cwd "$install_dir" build
|
|
||||||
|
|
||||||
chown -R $app:$app "$install_dir/node_modules"
|
chown -R $app:$app "$install_dir/node_modules"
|
||||||
chown -R $app:$app "$install_dir/.next"
|
chown -R $app:$app "$install_dir/.next"
|
||||||
|
@ -99,17 +90,17 @@ chown -R $app:$app "$install_dir/.next"
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_config_add_systemd
|
||||||
|
|
||||||
yunohost service add $app --description="alternative to google translate" --log="/var/log/$app/$app.log"
|
yunohost service add $app --description="alternative to google translate" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
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