mirror of
https://github.com/YunoHost-Apps/gitlab_ynh.git
synced 2024-09-03 18:36:35 +02:00
prevent swaping on SD card
This commit is contained in:
parent
eb564f9ad9
commit
ee160ea534
1 changed files with 17 additions and 15 deletions
|
@ -36,20 +36,6 @@ bool_to_true_false () {
|
|||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Check if the device of the main mountpoint "/" is an SD card
|
||||
#
|
||||
# return 1 if it's an SD card, else 0
|
||||
_ynh_is_main_device_is_sd_card () {
|
||||
local main_device=$(lsblk --output PKNAME --noheadings $(findmnt / --nofsroot --uniq --output source --noheadings --first-only))
|
||||
|
||||
if echo $main_device | grep --quiet "mmc" && [ $(cat /sys/block/$main_device/queue/rotational) -eq 0 ]
|
||||
then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Add swap
|
||||
#
|
||||
# usage: ynh_add_swap --size=SWAP in Mb
|
||||
|
@ -70,7 +56,7 @@ ynh_add_swap () {
|
|||
SD_CARD_CAN_SWAP=${SD_CARD_CAN_SWAP:-0}
|
||||
|
||||
# Swap on SD card only if it's is specified
|
||||
if [ _ynh_is_main_device_is_sd_card ] && [ "$SD_CARD_CAN_SWAP" == "0" ]
|
||||
if ynh_is_main_device_is_sd_card && [ "$SD_CARD_CAN_SWAP" == "0" ]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
@ -122,6 +108,22 @@ ynh_del_swap () {
|
|||
fi
|
||||
}
|
||||
|
||||
# Check if the device of the main mountpoint "/" is an SD card
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# return 0 if it's an SD card, else 1
|
||||
ynh_is_main_device_is_sd_card () {
|
||||
local main_device=$(lsblk --output PKNAME --noheadings $(findmnt / --nofsroot --uniq --output source --noheadings --first-only))
|
||||
|
||||
if echo $main_device | grep --quiet "mmc" && [ $(tail -n1 /sys/block/$main_device/queue/rotational) == "0" ]
|
||||
then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check the amount of available RAM
|
||||
#
|
||||
# usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram]
|
||||
|
|
Loading…
Add table
Reference in a new issue