Skip to content

Commit

Permalink
Simplify: systemd_swapon
Browse files Browse the repository at this point in the history
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
  • Loading branch information
nefelim4ag committed Sep 26, 2017
1 parent ab8b63c commit 11f1baf
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions systemd-swap
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ get_fs_type(){ stat -f "$1" | grep Type: | tr -s ' ' | cut -d' ' -f7; }

################################################################################
# Systemd swap unit generator
UNIT_PATH=/run/systemd/system/

systemd_swapon(){
UNIT_PATH=/run/systemd/system/
export What Priority Options
for i in "$@"; do
case $i in
Expand All @@ -45,11 +44,7 @@ systemd_swapon(){
done
[ ! -z "$What" ] || return 1
What="$(realpath $What)"
UNIT_NAME="$What"
UNIT_NAME="$(echo $UNIT_NAME | sed -e 's#^/##g')" # Cleanup leading slash
UNIT_NAME="${UNIT_NAME//-/\\x2d}" # Fix '-' for unit name
UNIT_NAME="${UNIT_NAME//@/\\x40}" # Fix '@' for unit name
UNIT_NAME="${UNIT_NAME//\//-}" # Replace '/' with -
UNIT_NAME="$(systemd-escape -p $What)"
{
echo '[Swap]'
echo "What=$What"
Expand Down

0 comments on commit 11f1baf

Please sign in to comment.