/usr/share/ltsp/ltsp-server-common-functions is in ltsp-server 5.3.7-0ubuntu2.
This file is owned by root:root, with mode 0o644.
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 | # Common functions shared by LTSP scripts
die() {
echo "$@" >&2
exit 1
}
boolean_is_true(){
case $1 in
# match all cases of true|y|yes
[Tt][Rr][Uu][Ee]|[Yy]|[Yy][Ee][Ss]) return 0 ;;
*) return 1 ;;
esac
}
# list files in a directory consisting only of alphanumerics, hyphens and
# underscores
# $1 - directory to list
# $2 - optional prefix to limit which files are selected
run_parts_list() {
test $# -ge 1 || die "ERROR: Usage: run_parts_list <dir>"
if [ -d "$1" ]; then
find -L "$1" -mindepth 1 -maxdepth 1 -type f -name "$2*" |
sed -n '/.*\/[0-9a-zA-Z_\-]\{1,\}$/p' | sort -n
fi
}
detect_vendor() {
if [ -e /etc/sysconfig/ltspdist ]; then
. /etc/sysconfig/ltspdist
echo "$VENDORDEF"
else
echo $(lsb_release --id --short | tr " " "_")
fi
}
# Distros may override this function to implement their own
# architecture detection.
detect_arch() {
echo $(uname -m)
}
require_root()
{
if [ ${UID:-$(id -u)} -ne 0 ]; then
die "Superuser privileges are needed."
fi
}
# Remember mounted dirs so that it's easier to unmount them with a single call
# to umount_marked. They'll be unmounted in reverse order.
# Use the normal mount syntax, e.g.
# mark_mount -t proc proc "$ROOT/proc"
mark_mount() {
local dir
# The last parameter is the dir we need to remember to unmount
dir=$(eval "echo \$$#")
if mount "$@"; then
# Use newlines to separate dirs, in case they contain spaces
if [ -z "$MARKED_MOUNTS" ]; then
MARKED_MOUNTS="$dir"
else
MARKED_MOUNTS="$dir
$MARKED_MOUNTS"
fi
else
die "Could not mount $dir."
fi
}
umount_marked() {
[ -z "$MARKED_MOUNTS" ] && return
echo "$MARKED_MOUNTS" | while read dir; do
if ! umount "$dir"; then
echo "Couldn't unmount $dir." >&2
fi
done
}
# Source tool-specific functions, if they're provided.
# Recursive inclusions shouldn't ever happen, but let's prevent them anyway.
if [ -z "$ltsp_tool" ]; then
ltsp_tool=${0##*/}
if [ -f "/usr/share/ltsp/$ltsp_tool-functions" ]; then
. "/usr/share/ltsp/$ltsp_tool-functions"
fi
fi
|