Skip to content

Commit

Permalink
FreeBSD/init-ceph: Make init-ceph work under FreeBSD for init-system
Browse files Browse the repository at this point in the history
 - FreeBSD find does not have printf option
 - ulimit has different grammar
 - use the packaged getopt in /usr/local

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
  • Loading branch information
wjwithagen committed Feb 1, 2017
1 parent 6995d2c commit 11c66ee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ceph_common.sh
Expand Up @@ -159,7 +159,8 @@ do_root_cmd_okfail() {
get_local_daemon_list() {
type=$1
if [ -d "/var/lib/ceph/$type" ]; then
for i in `find -L /var/lib/ceph/$type -mindepth 1 -maxdepth 1 -type d -printf '%f\n'`; do
for p in `find -L /var/lib/ceph/$type -mindepth 1 -maxdepth 1 -type d'`; do
i=`basename $p`
if [ -e "/var/lib/ceph/$type/$i/sysvinit" ]; then
id=`echo $i | sed 's/[^-]*-//'`
local="$local $type.$id"
Expand Down
19 changes: 16 additions & 3 deletions src/init-ceph.in
Expand Up @@ -50,6 +50,18 @@ if [ -n "$CEPH_BIN" ] && [ -n "$CEPH_ROOT" ] && [ -n "$CEPH_BUILD_DIR" ]; then
ASSUME_DEV=1
fi

if [ `uname` = FreeBSD ]; then
GETOPT=/usr/local/bin/getopt
ULIMIT="limit descriptors"
else
GETOPT=getoption
ULIMIT="ulimit -n"
fi

if id ceph > /dev/null; then
SETUSER=" --setuser ceph --setgroup ceph"
fi

usage_exit() {
echo "usage: $0 [options] {start|stop|restart|condrestart} [mon|osd|mds]..."
printf "Core options:\n"
Expand Down Expand Up @@ -137,7 +149,7 @@ stop_daemon() {
## command line options
options=

OPTS=$(getopt -n 'init-ceph' -o 'hvam:c:' -l 'help,verbose,valgrind,novalgrind,allhosts,restart,norestart,btrfs,nobtrfs,fsmount,nofsmount,btrfsumount,fsumount,conf:,cluster:,hostname:' -- "$@")
OPTS=$(${GETOPT} -n 'init-ceph' -o 'hvam:c:' -l 'help,verbose,valgrind,novalgrind,allhosts,restart,norestart,btrfs,nobtrfs,fsmount,nofsmount,btrfsumount,fsumount,conf:,cluster:,hostname:' -- "$@")
if [ $? != 0 ]
then
exit 1
Expand Down Expand Up @@ -348,11 +360,11 @@ for name in $what; do
[ -n "$valgrind" ] && wrap="$wrap valgrind $valgrind"

[ -n "$wrap" ] && runmode="-f &" && runarg="-f"
[ -n "$max_open_files" ] && files="ulimit -n $max_open_files;"
[ -n "$max_open_files" ] && files="${ULIMIT} $max_open_files;"

[ -n "$TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES" ] && tcmalloc="TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES=$TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES"

cmd="$files $tcmalloc $wrap $cmd --cluster $cluster --setuser ceph --setgroup ceph $runmode"
cmd="$files $tcmalloc $wrap $cmd --cluster $cluster ${SETUSER} $runmode"

if [ $dofsmount -eq 1 ] && [ -n "$fs_devs" ]; then
get_conf pre_mount "true" "pre mount command"
Expand Down Expand Up @@ -463,6 +475,7 @@ for name in $what; do
if daemon_is_running $name ceph-$type $id $pid_file; then
printf "$name: running "
do_cmd "$BINDIR/ceph --admin-daemon $asok version 2>/dev/null" || echo unknown
[ `uname` = FreeBSD ] && echo
elif [ -e "$pid_file" ]; then
# daemon is dead, but pid file still exists
echo "$name: dead."
Expand Down

0 comments on commit 11c66ee

Please sign in to comment.