82 lines
2.4 KiB
Bash
Executable File
82 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# This shell script was written in order to help you to create and maintain your
|
|
# local mirrors of MOS and/or Ubuntu. You could use this script as a cron job.
|
|
# Dependencies: rsync, wget, gpg, docker + dpkg-dev (only for partial Ubuntu mirror)
|
|
|
|
usage(){
|
|
cat <<EOF
|
|
Usage: fuel-createmirror [-h|--help] | [mos|ubuntu]
|
|
Create and update local mirrors of MOS and/or Ubuntu.
|
|
|
|
USAGE
|
|
-----
|
|
|
|
-h| --help This help screen.
|
|
|
|
Actions could be one of:
|
|
|
|
mos Create/Update MOS local mirror only
|
|
ubuntu Create/Update Ubuntu local mirror only
|
|
|
|
If no parameters specified, script will Create/Update both MOS and
|
|
Ubuntu mirrors.
|
|
|
|
Script will print directory names which can be used as respective
|
|
repository URLs on the "Settings" page of cluster setup, i.e.
|
|
file:///var/www/nailgun/ubuntu-part
|
|
|
|
CUSTOMIZATION
|
|
-------------
|
|
|
|
The following configuration directives could be used to modify the
|
|
script behavior.
|
|
|
|
$BINROOT/conf/common.cfg:
|
|
|
|
FUEL_VERSION - set the current Fuel version here. If running on
|
|
Fuel node, script will autodetect Fuel version,
|
|
otherwize you should set the version manually.
|
|
|
|
$BINROOT/conf/ubuntu.cfg:
|
|
|
|
UPSTREAM - hostname of Ubuntu mirror. Only rsync mirrors are
|
|
supported!
|
|
|
|
PARTIAL_UPSTREAM:
|
|
0 - script will mirror all packages from specified distibutions
|
|
and components. Upstream mirror structure will be preserved.
|
|
1 - (default) script will download only packages required for
|
|
MOS. Script will create partial repository with the "main"
|
|
component only, original mirror structure will not be preserved.
|
|
|
|
EOF
|
|
}
|
|
|
|
die() { echo "$@" 1>&2 ; exit 1; }
|
|
|
|
BINROOT=$(dirname `readlink -f "$0"`)
|
|
|
|
if [[ ( "$1" == "--help" ) || ( "$1" == "-h" ) ]]; then
|
|
usage
|
|
exit 0
|
|
fi
|
|
|
|
. $BINROOT/config/common.cfg
|
|
|
|
mkdir -p ${MIRROR_ROOT} || die "Cannot create ${MIRROR_ROOT}, exiting."
|
|
mkdir -p ${LOG_ROOT} || die "Cannot create ${LOG_ROOT}, exiting."
|
|
|
|
[ "$1" != "ubuntu" ] && $BINROOT/deb-mirror $BINROOT/config/mos-ubuntu-updatesonly.cfg
|
|
[ "$1" != "mos" ] && $BINROOT/deb-mirror $BINROOT/config/ubuntu.cfg
|
|
|
|
[ "$1" != "ubuntu" ] && . $BINROOT/config/mos-ubuntu-updatesonly.cfg && echo " * INFO: MOS mirror was created at: $LOCAL_DIR"
|
|
if [[ "$1" != "mos" ]]; then
|
|
. $BINROOT/config/ubuntu.cfg
|
|
if [[ $PARTIAL_UPSTREAM = "1" ]]; then
|
|
echo " * INFO: Ubuntu partial mirror was created at: $PARTIAL_UPSTREAM_PATH"
|
|
else
|
|
echo " * INFO: Ubuntu mirror was created at: $LOCAL_DIR"
|
|
fi
|
|
fi
|