Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mailinabox
Commits
083e3cf7
Commit
083e3cf7
authored
Mar 23, 2016
by
Joshua Tauberer
Browse files
Options
Browse Files
Download
Plain Diff
merge #757 (squashed) - add swap space to low-memory systems
parents
3d4cabbc
696bbe4e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
CHANGELOG.md
CHANGELOG.md
+1
-0
system.sh
setup/system.sh
+54
-0
No files found.
CHANGELOG.md
View file @
083e3cf7
...
@@ -11,6 +11,7 @@ Control panel:
...
@@ -11,6 +11,7 @@ Control panel:
Setup:
Setup:
*
A swap file is now created if system memory is less than 2GB, 5GB of free disk space is available, and if no swap file yet exists.
*
Setup dialogs did not appear correctly when connecting to SSH using Putty on Windows.
*
Setup dialogs did not appear correctly when connecting to SSH using Putty on Windows.
v0.17b (March 1, 2016)
v0.17b (March 1, 2016)
...
...
setup/system.sh
View file @
083e3cf7
...
@@ -4,6 +4,60 @@ source setup/functions.sh # load our functions
...
@@ -4,6 +4,60 @@ source setup/functions.sh # load our functions
# Basic System Configuration
# Basic System Configuration
# -------------------------
# -------------------------
# ### Add swap space to the system
# If the physical memory of the system is below 2GB it is wise to create a
# swap file. This will make the system more resiliant to memory spikes and
# prevent for instance spam filtering from crashing
# We will create a 1G file, this should be a good balance between disk usage
# and buffers for the system. We will only allocate this file if there is more
# than 5GB of disk space available
# The following checks are performed:
# - Check if swap is currently mountend by looking at /proc/swaps
# - Check if the user intents to activate swap on next boot by checking fstab entries.
# - Check if a swapfile already exists
# - Check if the root file system is not btrfs, might be an incompatible version with
# swapfiles. User should hanle it them selves.
# - Check the memory requirements
# - Check available diskspace
# See https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
# for reference
SWAP_MOUNTED
=
$(
cat
/proc/swaps |
tail
-n
+2
)
SWAP_IN_FSTAB
=
$(
grep
"swap"
/etc/fstab
)
ROOT_IS_BTRFS
=
$(
grep
"
\/
.*btrfs"
/proc/mounts
)
TOTAL_PHYSICAL_MEM
=
$(
head
-n
1 /proc/meminfo |
awk
'{print $2}'
)
AVAILABLE_DISK_SPACE
=
$(
df
/
--output
=
avail |
tail
-n
1
)
if
[
-z
"
$SWAP_MOUNTED
"
]
&&
[
-z
"
$SWAP_IN_FSTAB
"
]
&&
[
!
-e
/swapfile
]
&&
[
-z
"
$ROOT_IS_BTRFS
"
]
&&
[
$TOTAL_PHYSICAL_MEM
-lt
1900000
]
&&
[
$AVAILABLE_DISK_SPACE
-gt
5242880
]
then
echo
"Adding a swap file to the system..."
# Allocate and activate the swap file. Allocate in 1KB chuncks
# doing it in one go, could fail on low memory systems
dd
if
=
/dev/zero
of
=
/swapfile
bs
=
1024
count
=
$[
1024
*
1024]
status
=
none
if
[
-e
/swapfile
]
;
then
chmod
600 /swapfile
hide_output mkswap /swapfile
swapon /swapfile
fi
# Check if swap is mounted then activate on boot
if
swapon
-s
|
grep
-q
"
\/
swapfile"
;
then
echo
"/swapfile none swap sw 0 0"
>>
/etc/fstab
else
echo
"ERROR: Swap allocation failed"
fi
fi
# ### Add Mail-in-a-Box's PPA.
# ### Add Mail-in-a-Box's PPA.
# We've built several .deb packages on our own that we want to include.
# We've built several .deb packages on our own that we want to include.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment