mirror of
https://github.com/YunoHost-Apps/snweb_ynh.git
synced 2024-09-03 20:26:22 +02:00
Fix, Cleanup
This commit is contained in:
parent
23c080814d
commit
dd4c4d6f57
12 changed files with 198 additions and 231 deletions
|
@ -55,7 +55,7 @@ Can the app be used by multiple users? Yes
|
|||
|
||||
## Links
|
||||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/snweb_ynh/issues
|
||||
* Report a bug: https://github.com/FabianWilknes/snweb_ynh/issues
|
||||
* App website: https://standardnotes.org/
|
||||
* Upstream app repository: https://github.com/standardnotes/web
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
@ -66,11 +66,11 @@ Developers info
|
|||
----------------
|
||||
|
||||
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
|
||||
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/snweb_ynh/tree/testing).
|
||||
Please do your pull request to the [testing branch](https://github.com/FabianWilknes/snweb_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/snweb_ynh/tree/testing --debug
|
||||
sudo yunohost app install https://github.com/FabianWilkens/snweb_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade snweb -u https://github.com/YunoHost-Apps/snweb_ynh/tree/testing --debug
|
||||
sudo yunohost app upgrade snweb -u https://github.com/FabianWilkens/snweb_ynh/tree/testing --debug
|
||||
```
|
||||
|
|
|
@ -6,21 +6,16 @@
|
|||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
admin="john" (USER)
|
||||
language="en"
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
password="pass"
|
||||
port="666" (PORT)
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
setup_sub_dir=0
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=CommitHash
|
||||
upgrade=0 from_commit=
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
||||
|
@ -34,7 +29,7 @@
|
|||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=CommitHash
|
||||
name=Name and date of the commit.
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
|
||||
; commit=
|
||||
name=
|
||||
manifest_arg=domain=DOMAIN&is_public=1
|
||||
|
|
@ -1,41 +1,22 @@
|
|||
# upload max size
|
||||
client_max_body_size 25M;
|
||||
location __PATH__/ {
|
||||
alias __FINALPATH__/live/public ;
|
||||
|
||||
root __FINALPATH__/live/public;
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
location / {
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
proxy_set_header Accept-Encoding "";
|
||||
try_files $uri @proxy;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
proxy_pass http://127.0.0.1:__PORT____PATH__/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_buffering off;
|
||||
|
||||
# upload max size
|
||||
client_max_body_size 25M;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
more_clear_input_headers 'Accept-Encoding';
|
||||
}
|
||||
|
||||
location @proxy {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header Proxy "";
|
||||
proxy_pass_header Server;
|
||||
|
||||
proxy_pass http://127.0.0.1:__PORT__;
|
||||
proxy_buffering on;
|
||||
proxy_redirect off;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
#proxy_cache CACHE;
|
||||
proxy_cache_valid 200 7d;
|
||||
proxy_cache_valid 410 24h;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
add_header X-Cached $upstream_cache_status;
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
tcp_nodelay on;
|
||||
}
|
||||
|
||||
error_page 500 501 502 503 504 /500.html;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "Standard Notes - Web App",
|
||||
"name": "Standard Notes",
|
||||
"id": "snweb",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
|
@ -18,7 +18,7 @@
|
|||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx",
|
||||
"nginx",
|
||||
"mysql"
|
||||
],
|
||||
"arguments": {
|
||||
|
@ -28,27 +28,30 @@
|
|||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain name for snweb",
|
||||
"fr": "Choisissez un domaine pour snweb",
|
||||
"de": "Wähle einen Domain Namen für snweb"
|
||||
"fr": "Choisissez un domaine pour snweb",
|
||||
"de": "Wähle einen Domain Namen für snweb"
|
||||
},
|
||||
"example": "example.com"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"help": {
|
||||
"en": "A public application means that anyone can access this site."
|
||||
},
|
||||
"ask": {
|
||||
"en": "Is it a public application?",
|
||||
"fr": "Est-ce une application publique ?",
|
||||
"de": "Ist die Application Öffendlich?"
|
||||
"fr": "Est-ce une application publique ?",
|
||||
"de": "Ist die Application Öffendlich?"
|
||||
},
|
||||
"default": true
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "snserver_domain",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose the default Standard Notes Syncing Server",
|
||||
"de": "Wähle den Standard Notes Syncing Server"
|
||||
"de": "Wähle den Standard Notes Syncing Server"
|
||||
},
|
||||
"default": "sync.standardnotes.org"
|
||||
}
|
||||
|
|
|
@ -15,4 +15,4 @@
|
|||
---
|
||||
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
|
||||
|
||||
[/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/REPLACEBYYOURAPP_ynh%20PR-NUM-%20(USERNAME)/)
|
||||
[/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/snweb_ynh%20PR-NUM-%20(USERNAME)/)
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="\
|
||||
zlib1g-dev \
|
||||
libssl-dev \
|
||||
libjemalloc-dev \
|
||||
git \
|
||||
"
|
||||
zlib1g-dev \
|
||||
libssl-dev \
|
||||
libjemalloc-dev \
|
||||
git \
|
||||
"
|
||||
|
||||
RUBY_VERSION="2.7.2"
|
||||
NODEJS_VERSION="10"
|
||||
|
@ -26,21 +26,21 @@ COMMIT="31676f1cc61898147b363d442593870ae880d3e5"
|
|||
# (hence in user home dir, with prior loading of .profile, etc.)
|
||||
# usage: exec_login_as USER COMMAND [ARG ...]
|
||||
exec_login_as() {
|
||||
local user=$1
|
||||
shift 1
|
||||
exec_as $user --login "$@"
|
||||
local user=$1
|
||||
shift 1
|
||||
exec_as $user --login "$@"
|
||||
}
|
||||
# Execute a command as another user
|
||||
# usage: exec_as USER COMMAND [ARG ...]
|
||||
exec_as() {
|
||||
local user=$1
|
||||
shift 1
|
||||
|
||||
if [[ $user = $(whoami) ]]; then
|
||||
eval "$@"
|
||||
else
|
||||
sudo -u "$user" "$@"
|
||||
fi
|
||||
local user=$1
|
||||
shift 1
|
||||
|
||||
if [[ $user = $(whoami) ]]; then
|
||||
eval "$@"
|
||||
else
|
||||
sudo -u "$user" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
#================================================
|
||||
|
|
|
@ -15,8 +15,8 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
@ -24,7 +24,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -33,31 +33,24 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the main app directory..." --weight=1
|
||||
ynh_print_info "Backing up the main app directory..."
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up nginx web server configuration..." --weight=2
|
||||
ynh_print_info "Backing up nginx web server configuration..."
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
#ynh_script_progression --message="Backing up fail2ban configuration..." --weight=1
|
||||
#ynh_print_info "Backing up fail2ban configuration..."
|
||||
|
||||
#ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
||||
#ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
||||
|
@ -67,26 +60,19 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up logrotate configuration..." --weight=1
|
||||
ynh_print_info "Backing up logrotate configuration..."
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up systemd configuration..." --weight=1
|
||||
ynh_print_info "Backing up systemd configuration..."
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -25,7 +25,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
@ -34,16 +34,16 @@ port=$(ynh_app_setting_get --app=$app --key=port)
|
|||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1
|
||||
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
@ -55,13 +55,13 @@ ynh_abort_if_errors
|
|||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -69,37 +69,37 @@ fi
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Updating nginx web server configuration..." --weight=1
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the nginx config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config "port"
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config "port"
|
||||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -107,7 +107,7 @@ fi
|
|||
#=================================================
|
||||
|
||||
config_file="$final_path/live/.env"
|
||||
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$domain${path_url%/}" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$new_domain${new_path%/}" --target_file="$config_file"
|
||||
|
||||
#=================================================
|
||||
|
||||
|
@ -116,27 +116,20 @@ ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_str
|
|||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
sleep 10
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing settings..." --weight=2
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$new_domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$new_path
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --time --last
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
|
|
|
@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
@ -84,7 +84,7 @@ ynh_script_progression --message="Setting up source files..." --weight=16
|
|||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
git clone $SOURCE "$final_path/live" --quiet
|
||||
pushd "$final_path/live"
|
||||
git checkout $COMMIT --quiet
|
||||
git checkout $COMMIT --quiet
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
|
@ -108,7 +108,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
|
|||
#=================================================
|
||||
# INSTALLING RUBY AND BUNDLER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=212
|
||||
ynh_script_progression --message="Installing Ruby... ( This may take a while... )" --weight=100 #212
|
||||
|
||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
|
||||
|
@ -126,27 +126,27 @@ secret_key=$(ynh_string_random --length=48 | base64)
|
|||
ynh_replace_string --match_string="SECRET_KEY_BASE=test" --replace_string="SECRET_KEY_BASE=$secret_key" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$domain${path_url%/}" --target_file="$config_file"
|
||||
if [ "$snserver_domain" = "" ]; then
|
||||
snserver_domain="sync.standardnotes.org"
|
||||
snserver_domain="sync.standardnotes.org"
|
||||
fi
|
||||
ynh_replace_string --match_string="SF_DEFAULT_SERVER=http://localhost:3000" --replace_string="SF_DEFAULT_SERVER=https://$snserver_domain" --target_file="$config_file"
|
||||
|
||||
#=================================================
|
||||
# BUILDING
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building..." --weight=497
|
||||
ynh_script_progression --message="Building... ( This may take a while... )" --weight=100 #497
|
||||
|
||||
ENV_PATH="$ynh_node_load_PATH:/opt/rbenv/versions/$RUBY_VERSION/bin"
|
||||
|
||||
chown -R $app: "$final_path"
|
||||
|
||||
pushd "$final_path/live"
|
||||
git submodule update --init --recursive
|
||||
ynh_use_nodejs
|
||||
exec_as $app $ENV_PATH $ynh_npm ci
|
||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler
|
||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install
|
||||
exec_as $app $ENV_PATH $ynh_npm run bundle
|
||||
exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile
|
||||
git submodule update --init --recursive --quiet
|
||||
ynh_use_nodejs
|
||||
exec_as $app $ENV_PATH $ynh_npm --loglevel=error ci
|
||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler --quiet
|
||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install --quiet
|
||||
exec_as $app $ENV_PATH $ynh_npm --loglevel=error run bundle
|
||||
exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile --quiet
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
|
@ -157,9 +157,9 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=3
|
|||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config --others_var="\
|
||||
port \
|
||||
ENV_PATH \
|
||||
RUBY_VERSION \
|
||||
port \
|
||||
ENV_PATH \
|
||||
RUBY_VERSION \
|
||||
"
|
||||
|
||||
#=================================================
|
||||
|
@ -183,6 +183,8 @@ chown -R root:root "$final_path"
|
|||
chown $app: "$final_path"
|
||||
mkdir -p $app: "$final_path/.config"
|
||||
chown $app: "$final_path/.config"
|
||||
mkdir -p $app: "$final_path/.cache"
|
||||
chown $app: "$final_path/.cache"
|
||||
mkdir -p "$final_path/live/log"
|
||||
chown -R $app: "$final_path/live/log"
|
||||
mkdir -p "$final_path/live/public"
|
||||
|
@ -217,7 +219,7 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
sleep 10
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
|
@ -227,8 +229,8 @@ ynh_script_progression --message="Configuring SSOwat..." --weight=2
|
|||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# Create the visitors permission if needed
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
# Create the visitors permission if needed
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -30,8 +30,8 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
# 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
|
||||
ynh_script_progression --message="Removing $app service..." --weight=1
|
||||
yunohost service remove $app
|
||||
ynh_script_progression --message="Removing $app service..." --weight=1
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -83,8 +83,8 @@ ynh_secure_remove --file="/var/log/$app"
|
|||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
ynh_script_progression --message="Closing port $port..." --weight=1
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
ynh_script_progression --message="Closing port $port..." --weight=1
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -16,8 +16,8 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
#### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
#### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
@ -39,9 +39,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -81,7 +81,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
|
|||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=294
|
||||
ynh_script_progression --message="Reinstalling dependencies... ( This may take a while... )" --weight=100 #294
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
@ -93,20 +93,21 @@ ynh_install_ruby --ruby_version=$RUBY_VERSION
|
|||
#=================================================
|
||||
# BUILDING
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling $app..." --weight=222
|
||||
ynh_script_progression --message="Reinstalling $app... ( This may take a while... )" --weight=100 #222
|
||||
|
||||
|
||||
ynh_use_nodejs
|
||||
ENV_PATH="$ynh_node_load_PATH:/opt/rbenv/versions/$RUBY_VERSION/bin"
|
||||
|
||||
chown -R $app: "$final_path"
|
||||
|
||||
pushd "$final_path/live"
|
||||
git submodule update --init --recursive
|
||||
exec_as $app $ENV_PATH $ynh_npm ci
|
||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler
|
||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install
|
||||
exec_as $app $ENV_PATH $ynh_npm run bundle
|
||||
exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile
|
||||
git submodule update --init --recursive --quiet
|
||||
ynh_use_nodejs
|
||||
exec_as $app $ENV_PATH $ynh_npm --loglevel=error ci
|
||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler --quiet
|
||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install --quiet
|
||||
exec_as $app $ENV_PATH $ynh_npm --loglevel=error run bundle
|
||||
exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile --quiet
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
|
@ -129,13 +130,16 @@ mkdir -p "$final_path/live/tmp"
|
|||
chown -R $app: "$final_path/live/tmp"
|
||||
chown $app: "$final_path/live/Gemfile.lock"
|
||||
|
||||
mkdir -p "/var/log/$app"
|
||||
chown -R $app: "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
|
@ -149,6 +153,7 @@ yunohost service add $app --description "Standard Notes" --log "/var/log/$app/$a
|
|||
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
sleep 10
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
|
|
124
scripts/upgrade
124
scripts/upgrade
|
@ -43,17 +43,17 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||
is_public=1
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||
is_public=0
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/opt/yunohost/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
final_path=/opt/yunohost/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -64,8 +64,8 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
|
|||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
@ -93,24 +93,24 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
|
|||
#=================================================
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=17
|
||||
# Backup files to keep
|
||||
tmpdir=$(mktemp -d)
|
||||
if [ -d $final_path/live/log ] ; then
|
||||
cp -Rp $final_path/live/log $tmpdir
|
||||
fi
|
||||
# Remove destination directory
|
||||
ynh_secure_remove --file=$final_path
|
||||
# Download
|
||||
mkdir -p "$final_path"
|
||||
git clone $SOURCE "$final_path/live" --quiet
|
||||
pushd "$final_path/live"
|
||||
git checkout $COMMIT --quiet
|
||||
popd
|
||||
# Restore files
|
||||
if [ -d $tmpdir/log ] ; then
|
||||
cp -Rp $tmpdir/log "$final_path/live"
|
||||
fi
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=17
|
||||
# Backup files to keep
|
||||
tmpdir=$(mktemp -d)
|
||||
if [ -d $final_path/live/log ] ; then
|
||||
cp -Rp $final_path/live/log $tmpdir
|
||||
fi
|
||||
# Remove destination directory
|
||||
ynh_secure_remove --file=$final_path
|
||||
# Download
|
||||
mkdir -p "$final_path"
|
||||
git clone $SOURCE "$final_path/live" --quiet
|
||||
pushd "$final_path/live"
|
||||
git checkout $COMMIT --quiet
|
||||
popd
|
||||
# Restore files
|
||||
if [ -d $tmpdir/log ] ; then
|
||||
cp -Rp $tmpdir/log "$final_path/live"
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -135,29 +135,28 @@ ynh_system_user_create --username=$app --home_dir=$final_path
|
|||
#=================================================
|
||||
# INSTALLING RUBY AND BUNDLER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=331
|
||||
ynh_script_progression --message="Installing Ruby... ( This may take a while... )" --weight=100 #331
|
||||
|
||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
config_file="$final_path/live/.env"
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Modifying a config file..." --weight=2
|
||||
|
||||
config_file="$final_path/live/.env"
|
||||
cp -f ../conf/env.sample $config_file
|
||||
|
||||
ynh_replace_string --match_string="RAILS_ENV=development" --replace_string="RAILS_ENV=production" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="PORT=3001" --replace_string="PORT=$port" --target_file="$config_file"
|
||||
secret_key=$(ynh_string_random --length=48 | base64)
|
||||
ynh_replace_string --match_string="SECRET_KEY_BASE=test" --replace_string="SECRET_KEY_BASE=$secret_key" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$domain${path_url%/}" --target_file="$config_file"
|
||||
if [ "$snserver_domain" = "" ]; then
|
||||
snserver_domain="sync.standardnotes.org"
|
||||
fi
|
||||
ynh_replace_string --match_string="SF_DEFAULT_SERVER=http://localhost:3000" --replace_string="SF_DEFAULT_SERVER=https://$snserver_domain" --target_file="$config_file"
|
||||
ynh_script_progression --message="Modifying a config file..." --weight=2
|
||||
|
||||
cp -f ../conf/env.sample $config_file
|
||||
ynh_replace_string --match_string="RAILS_ENV=development" --replace_string="RAILS_ENV=production" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="PORT=3001" --replace_string="PORT=$port" --target_file="$config_file"
|
||||
secret_key=$(ynh_string_random --length=48 | base64)
|
||||
ynh_replace_string --match_string="SECRET_KEY_BASE=test" --replace_string="SECRET_KEY_BASE=$secret_key" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="APP_HOST=http://localhost:3001" --replace_string="APP_HOST=https://$domain${path_url%/}" --target_file="$config_file"
|
||||
if [ "$snserver_domain" = "" ]; then
|
||||
snserver_domain="sync.standardnotes.org"
|
||||
fi
|
||||
ynh_replace_string --match_string="SF_DEFAULT_SERVER=http://localhost:3000" --replace_string="SF_DEFAULT_SERVER=https://$snserver_domain" --target_file="$config_file"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -165,21 +164,21 @@ fi
|
|||
#=================================================
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Building..." --weight=131
|
||||
|
||||
ENV_PATH="$ynh_node_load_PATH:/opt/rbenv/versions/$RUBY_VERSION/bin"
|
||||
|
||||
chown -R $app: "$final_path"
|
||||
|
||||
pushd "$final_path/live"
|
||||
git submodule update --init --recursive
|
||||
ynh_use_nodejs
|
||||
exec_as $app $ENV_PATH $ynh_npm ci
|
||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler
|
||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install
|
||||
exec_as $app $ENV_PATH $ynh_npm run bundle
|
||||
exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile
|
||||
popd
|
||||
ynh_script_progression --message="Building... ( This may take a while... )" --weight=100 #131
|
||||
|
||||
ENV_PATH="$ynh_node_load_PATH:/opt/rbenv/versions/$RUBY_VERSION/bin"
|
||||
|
||||
chown -R $app: "$final_path"
|
||||
|
||||
pushd "$final_path/live"
|
||||
git submodule update --init --recursive --quiet
|
||||
ynh_use_nodejs
|
||||
exec_as $app $ENV_PATH $ynh_npm --loglevel=error ci
|
||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/gem install bundler --quiet
|
||||
env PATH=$ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundler install --quiet
|
||||
exec_as $app $ENV_PATH $ynh_npm --loglevel=error run bundle
|
||||
exec_as $app $ENV_PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile --quiet
|
||||
popd
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -189,9 +188,9 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=4
|
|||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config --others_var="\
|
||||
port \
|
||||
ENV_PATH \
|
||||
RUBY_VERSION \
|
||||
port \
|
||||
ENV_PATH \
|
||||
RUBY_VERSION \
|
||||
"
|
||||
|
||||
#=================================================
|
||||
|
@ -213,6 +212,8 @@ chown -R root:root "$final_path"
|
|||
chown $app: "$final_path"
|
||||
mkdir -p $app: "$final_path/.config"
|
||||
chown $app: "$final_path/.config"
|
||||
mkdir -p $app: "$final_path/.cache"
|
||||
chown $app: "$final_path/.cache"
|
||||
mkdir -p "$final_path/live/log"
|
||||
chown -R $app: "$final_path/live/log"
|
||||
mkdir -p "$final_path/live/public"
|
||||
|
@ -247,6 +248,7 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2
|
|||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
sleep 10
|
||||
|
||||
#=================================================
|
||||
# UPGRADE FAIL2BAN
|
||||
|
@ -264,8 +266,8 @@ ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=2
|
|||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# Create the visitors permission if needed
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
# Create the visitors permission if needed
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue