1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cac-proxy_ynh.git synced 2024-09-03 18:16:07 +02:00

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-30 22:42:33 +02:00 committed by Alexandre Aubin
parent 4b2c813db1
commit 6670b97d54
10 changed files with 95 additions and 164 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*~ *~
*.sw[op] *.sw[op]
.DS_Store

View file

@ -8,7 +8,7 @@ User=__APP__
Group=__APP__ Group=__APP__
EnvironmentFile=__INSTALL_DIR__/.env EnvironmentFile=__INSTALL_DIR__/.env
WorkingDirectory=__INSTALL_DIR__/package/ WorkingDirectory=__INSTALL_DIR__/package/
ExecStart=__YNH_NODE__ ./src/server.js ExecStart=__NODEJS_DIR__/node ./src/server.js
StandardOutput=append:/var/log/__APP__/__APP__.log StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit StandardError=inherit

View file

@ -16,7 +16,8 @@ license = "MIT"
code = "https://github.com/gcollin/cookie-aware-cors-proxy" code = "https://github.com/gcollin/cookie-aware-cors-proxy"
[integration] [integration]
yunohost = ">= 11.1.9" yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = ["amd64"] architectures = ["amd64"]
multi_instance = false multi_instance = false
ldap = "not_relevant" ldap = "not_relevant"

View file

@ -1,54 +1,42 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#================================================= #=================================================
nodejs_version=16 nodejs_version=16
#=================================================
# PERSONAL HELPERS
#=================================================
_generate_env_file() { _generate_env_file() {
# We must use chrome sandbox for kernels 5.x, 6.x doesn't need it anymore # We must use chrome sandbox for kernels 5.x, 6.x doesn't need it anymore
kernel_release=$(uname -r) kernel_release=$(uname -r)
if [[ $kernel_release == 5.* ]]; then if [[ $kernel_release == 5.* ]]; then
bypass_sandbox="TRUE" bypass_sandbox="TRUE"
if [ $install_chromium -eq 1 ]; then if [ $install_chromium -eq 1 ]; then
ynh_print_warn --message="Using non sandboxed chromium as kernel release is less than 6.x" ynh_print_warn "Using non sandboxed chromium as kernel release is less than 6.x"
fi fi
else else
bypass_sandbox="FALSE" bypass_sandbox="FALSE"
fi fi
ynh_add_config --template=".env" --destination="$install_dir/.env" ynh_config_add --template=".env" --destination="$install_dir/.env"
chmod 400 "$install_dir/.env" #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"
chown $app:$app "$install_dir/.env" #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"
} }
_install_restart_script_and_sudoers() { _install_restart_script_and_sudoers() {
# Enable restarting of services from ssh # Enable restarting of services from ssh
ynh_add_config --template="restart-proxy.sh" --destination="$install_dir/restart-proxy.sh" ynh_config_add --template="restart-proxy.sh" --destination="$install_dir/restart-proxy.sh"
chown "$app:$app" "$install_dir/restart-proxy.sh" chown "$app:$app" "$install_dir/restart-proxy.sh"
chmod o-rwx,gu=rwx "$install_dir/restart-proxy.sh" chmod o-rwx,gu=rwx "$install_dir/restart-proxy.sh"
# Add sudoers file for this specific command # Add sudoers file for this specific command
ynh_add_config --template="cac-proxy-sudoers" --destination="/etc/sudoers.d/$app-sudoers" ynh_config_add --template="cac-proxy-sudoers" --destination="/etc/sudoers.d/$app-sudoers"
chown root:root "/etc/sudoers.d/$app-sudoers" #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 root:root "/etc/sudoers.d/$app-sudoers"
chmod o-rwx,gu=r "/etc/sudoers.d/$app-sudoers" #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 o-rwx,gu=r "/etc/sudoers.d/$app-sudoers"
} }
_remove_restart_script_and_sudoers() { _remove_restart_script_and_sudoers() {
if [ -f "/etc/sudoers.d/$app-sudoers" ]; then if [ -f "/etc/sudoers.d/$app-sudoers" ]; then
ynh_secure_remove --file="/etc/sudoers.d/$app-sudoers" ynh_safe_rm "/etc/sudoers.d/$app-sudoers"
fi fi
} }
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,19 +1,10 @@
#!/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..."
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs ### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
### to be backuped and not an actual copy of any file. The actual backup that ### to be backuped and not an actual copy of any file. The actual backup that
@ -24,33 +15,33 @@ 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
#================================================= #=================================================
if [ -n "$public_key" ]; then if [ -n "$public_key" ]; then
ynh_backup --src_path="/etc/sudoers.d/$app-sudoers" ynh_backup "/etc/sudoers.d/$app-sudoers"
fi fi
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup "/etc/logrotate.d/$app"
#================================================= #=================================================
# 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)."

View file

@ -1,49 +1,39 @@
#!/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
#================================================= #=================================================
ynh_script_progression --message="Updating .env configuration..." ynh_script_progression "Updating .env configuration..."
ynh_backup_if_checksum_is_different --file="$install_dir/.env" ynh_backup_if_checksum_is_different "$install_dir/.env"
_generate_env_file _generate_env_file
#=================================================
# 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"

View file

@ -1,43 +1,35 @@
#!/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
#================================================= #=================================================
# INSTALL NODEJS # INSTALL NODEJS
#================================================= #=================================================
ynh_script_progression --message="Installing NodeJS..." --weight=3 ynh_script_progression "Installing NodeJS..."
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_nodejs_install
ynh_use_nodejs
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=6 ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from amd64.src # Download, check integrity, uncompress and patch the source from amd64.src
ynh_setup_source --dest_dir="$install_dir/package" ynh_setup_source --dest_dir="$install_dir/package"
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 | 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 | chown -R $app:$app "$install_dir"
#================================================= #=================================================
# ADD SSH ACCESS # ADD SSH ACCESS
#================================================= #=================================================
if [ -n "$public_key" ]; then if [ -n "$public_key" ]; then
ynh_script_progression --message="Enabling ssh access for dev..." --weight=1 ynh_script_progression "Enabling ssh access for dev..."
# enable ssh access to the files for updates # enable ssh access to the files for updates
# todo: Secure it more with https://github.com/YunoHost-Apps/ssh_chroot_dir_ynh # todo: Secure it more with https://github.com/YunoHost-Apps/ssh_chroot_dir_ynh
mkdir --parents "$install_dir/.ssh" mkdir --parents "$install_dir/.ssh"
ynh_add_config --template="authorized_keys" --destination="$install_dir/.ssh/authorized_keys" ynh_config_add --template="authorized_keys" --destination="$install_dir/.ssh/authorized_keys"
chown -R "$app:$app" "$install_dir/.ssh" chown -R "$app:$app" "$install_dir/.ssh"
chmod 700 "$install_dir/.ssh" chmod 700 "$install_dir/.ssh"
@ -50,45 +42,45 @@ fi
# Install chromium # Install chromium
#================================================= #=================================================
if [ $install_chromium -eq 1 ]; then if [ $install_chromium -eq 1 ]; then
ynh_script_progression --message="Installing Chromium..." --weight=8 ynh_script_progression "Installing Chromium..."
pushd "$install_dir/package" pushd "$install_dir/package"
ynh_exec_as "$app" $ynh_node_load_PATH $ynh_node "./node_modules/puppeteer/install.js" ynh_exec_as_app node_load_PATH node "./node_modules/puppeteer/install.js"
popd popd
fi fi
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression "Adding $app's configuration..."
_generate_env_file _generate_env_file
#================================================= #=================================================
# 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 # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_config_add_systemd
yunohost service add $app --description="A Cors proxy letting the browser manages cookies and redirects." --log="/var/log/$app/$app.log" yunohost service add $app --description="A Cors proxy letting the browser manages cookies and redirects." --log="/var/log/$app/$app.log"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_config_add_logrotate
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression "Starting $app's systemd service..."
# 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"

View file

@ -1,51 +1,39 @@
#!/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
#================================================= #=================================================
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; then if ynh_hide_warnings yunohost service status $app >/dev/null; then
yunohost service remove $app yunohost service remove $app
fi fi
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_config_remove_nginx
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_config_remove_systemd
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_config_remove_logrotate
_remove_restart_script_and_sudoers _remove_restart_script_and_sudoers
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing NodeJS..." --weight=2 ynh_script_progression "Removing NodeJS..."
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_nodejs --nodejs_version=$nodejs_version ynh_nodejs_remove --nodejs_version=$nodejs_version
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/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
@ -13,13 +7,12 @@ 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"
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"
#Make sure the .ssh and files have the correct access rights #Make sure the .ssh and files have the correct access rights
if [ -n "$public_key" ]; then if [ -n "$public_key" ]; then
chown -R $app:$app "$install_dir/.ssh" chown -R $app:$app "$install_dir/.ssh"
@ -34,38 +27,37 @@ fi
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling NodeJS..." --weight=21 ynh_script_progression "Reinstalling NodeJS..."
# Define and install dependencies # Define and install dependencies
ynh_install_nodejs --nodejs_version="$nodejs_version" ynh_nodejs_install
ynh_use_nodejs
#================================================= #=================================================
# 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/logrotate.d/$app" ynh_restore "/etc/logrotate.d/$app"
mkdir --parents /var/log/$app mkdir --parents /var/log/$app
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="A Cors proxy letting the browser manages cookies and redirects." --log="/var/log/$app/$app.log" yunohost service add $app --description="A Cors proxy letting the browser manages cookies and redirects." --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's services..." --weight=1 ynh_script_progression "Reloading NGINX web server and $app's services..."
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"

View file

@ -1,67 +1,56 @@
#!/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)
#=================================================
# 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"
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression "Ensuring downward compatibility..."
# Missing settings ? # Missing settings ?
if [ -z "${public_key+x}" ]; then if [ -z "${public_key+x}" ]; then
public_key="" public_key=""
ynh_app_setting_set --app="$app" --key=public_key --value="$public_key" ynh_app_setting_set --key=public_key --value="$public_key"
fi fi
if [ -z "${install_chromium+x}" ]; then if [ -z "${install_chromium+x}" ]; then
install_chromium="false" install_chromium="false"
ynh_app_setting_set --app="$app" --key=install_chromium --value="$install_chromium" ynh_app_setting_set --key=install_chromium --value="$install_chromium"
fi fi
#================================================= #=================================================
# INSTALL NODEJS # INSTALL NODEJS
#================================================= #=================================================
ynh_script_progression --message="Upgrading NodeJS..." --weight=3 ynh_script_progression "Upgrading NodeJS..."
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_nodejs_install
ynh_use_nodejs
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]; then # FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
ynh_script_progression --message="Upgrading source files..." --weight=6 if ynh_app_upstream_version_changed; then
ynh_script_progression "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from amd64.src # Download, check integrity, uncompress and patch the source from amd64.src
ynh_setup_source --dest_dir="$install_dir/package" --full_replace=1 ynh_setup_source --dest_dir="$install_dir/package" --full_replace
fi fi
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 | 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 | chown -R $app:$app "$install_dir"
if [ -n "$public_key" ]; then if [ -n "$public_key" ]; then
ynh_script_progression --message="Enabling ssh access for dev..." --weight=1 ynh_script_progression "Enabling ssh access for dev..."
# enable ssh access to the files for updates # enable ssh access to the files for updates
# todo: Secure it more with https://github.com/YunoHost-Apps/ssh_chroot_dir_ynh # todo: Secure it more with https://github.com/YunoHost-Apps/ssh_chroot_dir_ynh
mkdir --parents "$install_dir/.ssh" mkdir --parents "$install_dir/.ssh"
ynh_add_config --template="authorized_keys" --destination="$install_dir/.ssh/authorized_keys" ynh_config_add --template="authorized_keys" --destination="$install_dir/.ssh/authorized_keys"
chown -R "$app:$app" "$install_dir/.ssh" chown -R "$app:$app" "$install_dir/.ssh"
chmod 700 "$install_dir/.ssh" chmod 700 "$install_dir/.ssh"
@ -70,52 +59,51 @@ if [ -n "$public_key" ]; then
_install_restart_script_and_sudoers _install_restart_script_and_sudoers
fi fi
#================================================= #=================================================
# Install chromium # Install chromium
#================================================= #=================================================
if [ "$install_chromium" -eq 1 ]; then if [ "$install_chromium" -eq 1 ]; then
ynh_script_progression --message="Upgrading Chromium..." --weight=8 ynh_script_progression "Upgrading Chromium..."
# Remove old versions of chrome # Remove old versions of chrome
ynh_secure_remove --file="$install_dir/.cache/puppeteer/chrome" ynh_safe_rm "$install_dir/.cache/puppeteer/chrome"
pushd "$install_dir/package" pushd "$install_dir/package"
ynh_exec_as "$app" $ynh_node_load_PATH $ynh_node "./node_modules/puppeteer/install.js" ynh_exec_as_app node_load_PATH node "./node_modules/puppeteer/install.js"
popd popd
fi fi
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_script_progression "Updating configuration..."
_generate_env_file _generate_env_file
#================================================= #=================================================
# 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 # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_config_add_systemd
yunohost service add $app --description="A Cors proxy letting the browser manages cookies and redirects." --log="/var/log/$app/$app.log" yunohost service add $app --description="A Cors proxy letting the browser manages cookies and redirects." --log="/var/log/$app/$app.log"
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append ynh_config_add_logrotate
#================================================= #=================================================
# 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"