diff options
| author | yalh76 <yalh@yahoo.com> | 2019-08-11 15:58:52 +0200 |
|---|---|---|
| committer | yalh76 <yalh@yahoo.com> | 2019-08-11 15:58:52 +0200 |
| commit | b199de81f9241d0c07ccdd35bf0a8794d855bba6 (patch) | |
| tree | 56b38dfd6947b00e8e1d3b7e7cb7b0ff2de5c749 /scripts | |
| parent | d406a87de2856be91b82005517106bab0622d28b (diff) | |
| download | mastodon_ynh-b199de81f9241d0c07ccdd35bf0a8794d855bba6.tar.gz mastodon_ynh-b199de81f9241d0c07ccdd35bf0a8794d855bba6.tar.bz2 mastodon_ynh-b199de81f9241d0c07ccdd35bf0a8794d855bba6.zip | |
Add swap during upgrade and restore
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/restore | 18 | ||||
| -rw-r--r-- | scripts/upgrade | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/scripts/restore b/scripts/restore index 59e71fc..1d8180d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,6 +10,8 @@ source ../settings/scripts/_common.sh source ../settings/scripts/ynh_install_ruby source ../settings/scripts/ynh_add_extra_apt_repos__3 +source ../settings/scripts/ynh_add_swap +source ../settings/scripts/ynh_check_ram source /usr/share/yunohost/helpers #================================================= @@ -81,6 +83,22 @@ chown -R $app: $final_path #================================================= # SPECIFIC RESTORATION #================================================= +# ADD SWAP IF NEEDED +#================================================= + +total_memory=$(ynh_check_ram) +total_swap=$(ynh_check_ram --only_swap) +swap_needed=0 + +if [ $total_memory -lt 2560 ]; then + # Need a minimum of 8Go of memory + swap_needed=$((2560 - $total_memory)) +fi + +ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 +ynh_add_swap --size=$swap_needed + +#================================================= # REINSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=63 diff --git a/scripts/upgrade b/scripts/upgrade index 46e7229..b35d643 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,6 +9,8 @@ source _common.sh source ynh_install_ruby source ynh_add_extra_apt_repos__3 +source ynh_add_swap +source ynh_check_ram source /usr/share/yunohost/helpers #================================================= @@ -206,6 +208,22 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SPECIFIC UPGRADE #================================================= +# ADD SWAP IF NEEDED +#================================================= + +total_memory=$(ynh_check_ram) +total_swap=$(ynh_check_ram --only_swap) +swap_needed=0 + +if [ $total_memory -lt 2560 ]; then + # Need a minimum of 8Go of memory + swap_needed=$((2560 - $total_memory)) +fi + +ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 +ynh_add_swap --size=$swap_needed + +#================================================= # INSTALLING RUBY AND BUNDLER #================================================= ynh_script_progression --message="Installing Ruby..." --weight=424 |
