/usr/sbin/nbdswapd is in ltsp-server 5.5.1-1ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #!/bin/sh
#
# Copyright (c) 2006 Vagrant Cascadian <vagrant@freegeek.org>
#
# 2006, Oliver Grawert <ogra@canonical.com>
# 2008, Warren Togami <wtogami@redhat.com>
# Vagrant Cascadian <vagrant@freegeek.org>
# Eric Harrison <eharrison@k12linux.mesd.k12.or.us>
# 2012, Alkis Georgopoulos <alkisg@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, you can find it on the World Wide
# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
# Generates a swap file to be exported with nbd-server.
#
# When called with no parameters, it assumes that it was ran from inetd,
# and it launches nbd-server in order to serve it.
# An inetd configuration line like the following is needed in that case:
# 9572 stream tcp nowait nobody /usr/sbin/tcpd /usr/sbin/nbdswapd
#
# When called with one parameter, it assumes that it was ran from nbd-server,
# so it just creates the specified swap file and exits.
# The nbd-server configuration section is expected to look similar to this:
# [swap]
# exportname = /tmp/nbd-swap/%s
# prerun = nbdswapd %s
# postrun = rm -f %s
# Fail on error, to notify nbd-server that the swap file wasn't created.
set -e
# Default sparse swapfile size, in MB
SIZE=512
# Default to running mkswap
RUN_MKSWAP=true
# Allow overriding the defaults from a configuration file
if [ -f /etc/ltsp/nbdswapd.conf ]; then
. /etc/ltsp/nbdswapd.conf
fi
# Abort if liveimg
if grep -q "liveimg" /proc/cmdline; then
exit 1
fi
test $# -eq 0 && inetd=true
if [ -n "$inetd" ]; then
if [ -n "$SWAPDIR" ]; then
if [ -d "$SWAPDIR" ] && [ -w "$SWAPDIR" ]; then
TEMPFILE_OPTS="${SWAPDIR}/XXXXXX"
else
echo "ERROR: not a directory or not writeable: $SWAPDIR" >&2
exit 1
fi
fi
if [ -z "$SWAP" ]; then
SWAP=$(mktemp $TEMPFILE_OPTS)
fi
else
SWAP="$1"
SWAPDIR=${SWAP%/*}
test -d "$SWAPDIR" || mkdir -p "$SWAPDIR"
fi
# generate the swap file
dd if=/dev/zero of="$SWAP" bs=1M count=0 seek="$SIZE" 2> /dev/null
chmod 600 "$SWAP"
if [ "$RUN_MKSWAP" = "true" ]; then
mkswap "$SWAP" > /dev/null
fi
if [ -n "$inetd" ]; then
# start the swap server
nbd-server 0 "$SWAP" $NBD_SERVER_OPTS -C /dev/null > /dev/null 2>&1 || true
# clean up the swap file
rm -f "$SWAP"
fi
|