aboutsummaryrefslogtreecommitdiff
path: root/scripts/install
diff options
context:
space:
mode:
authoryalh76 <yalh@yahoo.com>2019-08-11 00:20:48 +0200
committeryalh76 <yalh@yahoo.com>2019-08-11 00:20:48 +0200
commit1e9663438eb0dd3535ced7086547a0da62bdaad2 (patch)
tree30f662eb2ad4c2fd15554c96c5c241b5d8f547d8 /scripts/install
parent5c325134b146e75b388f83df5730b988d096fdc4 (diff)
downloadmastodon_ynh-1e9663438eb0dd3535ced7086547a0da62bdaad2.tar.gz
mastodon_ynh-1e9663438eb0dd3535ced7086547a0da62bdaad2.tar.bz2
mastodon_ynh-1e9663438eb0dd3535ced7086547a0da62bdaad2.zip
managing swap
Diffstat (limited to 'scripts/install')
-rw-r--r--scripts/install27
1 files changed, 17 insertions, 10 deletions
diff --git a/scripts/install b/scripts/install
index 5bc5c23..daa4153 100644
--- a/scripts/install
+++ b/scripts/install
@@ -10,6 +10,7 @@ source _common.sh
source ynh_install_ruby
source ynh_add_extra_apt_repos__3
source ynh_send_readme_to_admin__2
+source ynh_add_swap
source /usr/share/yunohost/helpers
#=================================================
@@ -44,16 +45,6 @@ ynh_script_progression --message="Validating installation parameters..." --weigh
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
-if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
- # TODO : to be factorized into a helper someday ? ;)
- MEM=$(free | grep "^Mem" | awk '{print $2}')
- SWAP=$(free | grep "^Swap" | awk '{print $2}')
- TOTAL_MEM_AND_SWAP=$(( ( $MEM+$SWAP ) / 1024 )) # In MB
-
- [[ $TOTAL_MEM_AND_SWAP -gt 2500 ]] || ynh_die "You need at least 2500 Mo of RAM+Swap to install Mastodon. Please consult the README to learn how to add swap."
-
-fi
-
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
@@ -134,6 +125,22 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# SPECIFIC SETUP
#=================================================
+# 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