Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P453
staging-ms-be-01.sh
Active
Public
Actions
Authored by
thcipriani
on Mar 30 2015, 6:07 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F107106: staging-ms-be-01.sh
Mar 30 2015, 6:07 PM
2015-03-30 18:07:14 (UTC+0)
Subscribers
None
#!/usr/bin/env bash
# Creates, formats and mounts swift storage loop drives
# should be idempotent, probably isn't -- caveat emptor
printf
'This script creates and mounts some loop back devices for swift, you good? [y/N] '
read
ans
if
[
!
"
$ans
"
=
'y'
]
&&
[
!
"
$ans
"
=
'Y'
]
;
then
printf
"Answer: '
${
ans
}
' was not 'Y' or 'y', exiting...\n"
exit
fi
config
=
'/etc/swift'
storage
=
'/srv/swift-storage'
images
=
"
${
storage
}
/images"
mkdir -p
"
${
images
}
"
# https://wikitech.wikimedia.org/wiki/Swift/Setup_New_Swift_Cluster#Setup_file_systems
image
=
"
${
images
}
/swift-sdb.img"
mount_point
=
"
${
storage
}
/sdb1"
label
=
"swift-sdb1"
mkdir -p
"
${
mount_point
}
"
if
[
! -f
"
${
image
}
"
]
;
then
touch
"
${
image
}
"
# resize img file to 5G
truncate -s 10G
"
${
image
}
"
# format
/sbin/mkfs.xfs -f -i
size
=
512
-L
"
${
label
}
"
"
${
image
}
"
if
! egrep -q
"
${
mount_point
}
"
/proc/mounts
;
then
mount -t xfs -o loop,rw,noatime,nodiratime,nobarrier,logbufs
=
8
"
${
image
}
"
"
${
mount_point
}
"
chown -R swift:swift
"
${
mount_point
}
"
else
printf
'[$(tput red)ERROR$(tput sgr0)] Mount point %s already exists'
"
${
mount_point
}
"
exit
1
fi
else
printf
'[$(tput red)ERROR$(tput sgr0)] File %s already exists'
"
${
image
}
"
exit
1
fi
Event Timeline
thcipriani
edited the content of this paste.
(Show Details)
Mar 30 2015, 6:07 PM
2015-03-30 18:07:14 (UTC+0)
thcipriani
changed the title of this paste from untitled to
staging-ms-be-01.sh
.
thcipriani
updated the paste's language from
autodetect
to
bash
.
Log In to Comment