pool-addcd
# This file 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 file 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 file, if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
usage_message () {
echo "Usage: $0 cd-iso-directory cd-contents-directory version-string cd-name cd-mirror-dir iso-name [--verbose]"
}
pushd () {
OLDCURDIR="$(pwd)"
cd "$1"
}
popd () {
cd "$OLDCURDIR"
}
CDBASEDIR=$(readlink --no-newline --canonicalize-existing "$1")
if [ -z "$CDBASEDIR" ]; then
usage_message
echo "Unknown cd base directory"
exit 1
fi
CONTENTSDIR=$(readlink --no-newline --canonicalize-existing "$2")
if [ -z "$CONTENTSDIR" ]; then
usage_message
echo "Unknown directory for CD contents"
exit 1
fi
VERSION="$3"
if [ -z "$VERSION" ]; then
usage_message
echo "Unknown version"
exit 1
fi
NAME="$4"
if [ -z "$NAME" ]; then
usage_message
echo "Unknown cd name"
exit 1
fi
MIRRORDIR=$(readlink --no-newline --canonicalize-existing "$5")
if [ -z "$MIRRORDIR" ]; then
usage_message
echo "Unknown mirror directory"
exit 1
fi
ISONAME="$6"
if [ -z "$ISONAME" ]; then
usage_message
echo "Unknown ISO image name"
exit 1
fi
VERBOSE=FALSE
if [ "$7" = "--verbose" ]; then
VERBOSE=TRUE
fi
[ "$VERBOSE" = "TRUE" ] && echo cd contents: $CONTENTSDIR
[ "$VERBOSE" = "TRUE" ] && echo mirror: $MIRRORDIR
if [ "$VERBOSE" = "TRUE" ]; then
echo "CDBASEDIR=$CDBASEDIR"
echo "CONTENTSDIR=$CONTENTSDIR"
echo "VERSION=$VERSION"
echo "NAME=$NAME"
echo "MIRRORDIR=$MIRRORDIR"
echo "ISONAME=$ISONAME"
echo "mkdir -p $CONTENTSDIR/$VERSION/$NAME"
fi
VERBOSE_ARG=
[ "$VERBOSE" = "TRUE" ] && VERBOSE_ARG="--verbose"
echo " Adding $ISONAME"
mkdir -p $CONTENTSDIR/$VERSION/$NAME || exit 1
if [ -z "$(cat /etc/fstab | grep $CONTENTSDIR/$VERSION/$NAME\ )" ]; then
sudo pool-addcd-to-fstab "$CDBASEDIR" "$VERSION" "$ISONAME" "$CONTENTSDIR" "$VERSION" "$NAME"
fi
COMMAND="pool-addcd-files $CONTENTSDIR/$VERSION/$NAME $MIRRORDIR $VERBOSE_ARG"
[ "$VERBOSE" = "TRUE" ] && echo "$COMMAND"
$COMMAND || exit 1
exit 0